Starter project from a GraphQL course on Udemy.com - Section 3!
- Run
npm install --legacy-peer-deps
in the root of the project to install dependencies - Access the application at
localhost:4000
in your browser
Starter project from a GraphQL course on Udemy.com - Section 3!
In the starter package, I found the below code:
function login({ email, password, req }) {
return new Promise((resolve, reject) => {
passport.authenticate('local', (err, user) => {
if (!user) { reject('Invalid credentials.') }
req.login(user, () => resolve(user));
})({ body: { email, password } });
});
}
The passport documentation suggests that calling authenticate on passport automatically calls login. So, I believe there is no need to call login again.
Note: passport.authenticate() middleware invokes req.login() automatically. This function is primarily used when users sign up, during which req.login() can be invoked to automatically log in the newly registered user.
If you install from npm install. You will probably get maximum call stack size exeeded I dont know the reasons but I found solution here npm/npm#20402 hope it helps ~
npm install
and then npm run dev
after that i got this error:
RootQueryType fields must be an object with field names as keys or a function which returns such an object.
npm version 5.3.0 (also tried with 3.8.0)
using nodemon: "*" added to package.json since not in project.
~/work/auth-graphql-starter (master)*> npm run dev
> [email protected] dev /Users/kkras2/work/NikeDev/mywork/auth-graphql-starter
> nodemon index.js --ignore client
[nodemon] 1.11.0
[nodemon] to restart at any time, enter 'rs'
[nodemon] watching: *.*
[nodemon] starting 'node index.js'
/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/jsutils/invariant.js:19
throw new Error(message);
^
Error: RootQueryType fields must be an object with field names as keys or a function which returns such an object.
at invariant (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/jsutils/invariant.js:19:11)
at defineFieldMap (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/type/definition.js:312:27)
at GraphQLObjectType.getFields (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/type/definition.js:276:44)
at /Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/type/schema.js:207:27
at typeMapReducer (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/type/schema.js:219:7)
at Array.reduce (native)
at new GraphQLSchema (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/node_modules/graphql/type/schema.js:95:34)
at Object.<anonymous> (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/server/schema/schema.js:6:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/kkras2/work/NikeDev/mywork/auth-graphql-starter/server/server.js:9:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
[nodemon] app crashed - waiting for file changes before starting...
~/work/auth-graphql-starter (master)*> npm -v
As a result I'm blocked in this course.
Not sure if you were expecting nodemon to have been installed globally, but as it isn't installed via the base package.json configuration the >npm run dev macro fails out of the box.
Should add nodemon to the list of project dependencies (or this is what I did) to get it fixed.
Can you please add a support for SQL databases?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.