Sign up MongoDB Atlas to create database. watch video for help https://www.youtube.com/watch?v=WyVwfUo18pI&list=PLB97yPrFwo5i9zDrWfvkohPec3Q6EEC9J&index=9
inside client folder run the following command
npm start / ng serve
Need to run nodejs server to fetch data side by side
npm start
https://www.youtube.com/playlist?list=PLB97yPrFwo5i9zDrWfvkohPec3Q6EEC9J
https://javascript.plainenglish.io/use-of-apollo-angular-with-angular-522bcebf7bc8
In this video we will connect to MongoDB Atlas using mongoose and we will create User and Quote collection or model in Hindi https://www.youtube.com/watch?v=WyVwfUo18pI&list=PLB97yPrFwo5i9zDrWfvkohPec3Q6EEC9J&index=9
https://www.npmpeer.dev/packages/apollo-angular/compatibility
******************************** CREATE / INSERT USER ******************************************************
mutation createUser($userNew:UserInput!){
user: signupUser(userNew: $userNew){
_id
name
address
email
password
}
}
{
"userNew": {
"name": "Bill Gates",
"address": "USA",
"email": "bill@gmail.com",
"password": "12345"
}
}
{
"data": {
"user": {
"_id": "643d11eb0865201e4c93e0c1",
"name": "Bill Gates",
"address": "USA",
"email": "bill@gmail.com",
"password": "$2a$12$mG8So0yvN474R4yEOhwxJuxMz3H800XlT7rzvomi9KwikCvtwEV66"
}
}
}
*********************************** SIGN IN USER ***************************************************
mutation SigninUser($userSignin:UserSigninInput!) {
user:signinUser(userSignin:$userSignin) {
token
}
}
{
"userSignin": {
"email": "bill@gmail.com",
"password": "12345"
}
}
{
"data": {
"user": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDNkMTFlYjA4NjUyMDFlNGM5M2UwYzEiLCJpYXQiOjE2ODIxNDM2ODh9.kdd9K20VFm30LFnNwGqRBlToYuEClSRWvCmXxeW0BLQ"
}
}
}
******************************** CREATE QUOTE AFTER LOGIN ******************************************************
At first create valid token using SigninUser. Copy "token" from response and put HTTP HEADERS of createQuote mutation
mutation createQuote($name:String!){
createQuote(name:$name)
}
{
"name": "This is second quote"
}
{
"authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDNkMTFlYjA4NjUyMDFlNGM5M2UwYzEiLCJpYXQiOjE2ODIxNDk5NjN9.zGlp1eCEQvFb_GvdnnfLYdpcd63ZZbObAcPlo8DbyuE"
}
{
"data": {
"createQuote": "New Quote is saved successfully"
}
}
************************************ GET ALL USERS **************************************************
query getAllUsers{
usersAll{
_id
name
email
quotes{
name
by
}
}
}
{
"data": {
"usersAll": [
{
"_id": "643d11eb0865201e4c93e0c1",
"name": "Bill Gates",
"email": "bill@gmail.com",
"quotes": [
{
"name": "This is first quote",
"by": "643d11eb0865201e4c93e0c1"
}
]
},
{
"_id": "643e200c90b2a620e0ac075f",
"name": "James Gates",
"email": "james@gmail.com",
"quotes": []
}
]
}
}
************************************* GET ALL QUOTES *************************************************
query getAllQuotes{
quotesAll{
name
by
}
}
{
"data": {
"quotesAll": [
{
"name": "This is first quote",
"by": "643d11eb0865201e4c93e0c1"
}
]
}
}
********************************* GET ALL QUOTES WITH USERID & USER NAME ************************************
query getUserById($userID:ID!){
userById(_id: $userID){
_id
name
email
quotes{
name
}
}
}
{
"userID": "643d11eb0865201e4c93e0c1"
}
{
"data": {
"userById": {
"_id": "643d11eb0865201e4c93e0c1",
"name": "Bill Gates",
"email": "bill@gmail.com",
"quotes": [
{
"name": "This is first quote"
}
]
}
}
}
******************************** GET QUOTES BY USERID ******************************************************
query getQuoteByUserID($quoteBy:ID!){
iquote(by: $quoteBy){
name
}
}
{
"quoteBy": "643d11eb0865201e4c93e0c1"
}
{
"data": {
"iquote": [
{
"name": "This is first quote"
}
]
}
}