Skip to content

Commit

Permalink
major version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
onprem committed Aug 18, 2019
1 parent 2d53030 commit 63fd893
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 144 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
},
"license": "MIT",
"dependencies": {
"apollo-server": "^2.6.1",
"apollo-server": "^2.8.1",
"bcrypt": "^3.0.6",
"dotenv": "^8.0.0",
"graphql": "^14.3.1",
"dotenv": "^8.1.0",
"graphql": "^14.4.2",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.2.7"
"mongodb": "^3.3.0"
},
"devDependencies": {
"nodemon": "^1.19.1"
Expand Down
20 changes: 17 additions & 3 deletions src/resolvers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { AuthenticationError } = require('apollo-server');
const { AuthenticationError, UserInputError } = require('apollo-server');
const bcrypt = require('bcrypt');
const ObjectId = require('mongodb').ObjectId;
const jwt = require('jsonwebtoken');
Expand Down Expand Up @@ -51,6 +51,17 @@ const resolvers = {
return users[0].todos;
}
},
Todo: {
user: async ( todo, _, context ) => {
if(todo.user){
return todo.user;
}
return {
id: context.id,
email: context.email
}
}
},
Mutation: {
login: async ( _, args, context ) =>{
//console.log( args, context.token );
Expand All @@ -71,7 +82,7 @@ const resolvers = {
throw new AuthenticationError("Invalid password");
}
//console.log(data);
return null;
throw new AuthenticationError("Invalid username or password");
},
signup: async ( _, args, context ) => {
const data = await context.db.collection('users').find({ email: args.email }).project({ _id: 1 }).toArray();
Expand All @@ -85,7 +96,10 @@ const resolvers = {
email: args.email
};
}
return null;
else {
throw new UserInputError('Email already registered');
}
throw new UserInputError('Some error occured');
},
addTodo: async ( _, args, context ) => {
if( context.isValid ) {
Expand Down
Loading

0 comments on commit 63fd893

Please sign in to comment.