Skip to content

Commit

Permalink
Updated docs port [skip_publish] [deploy_docs]
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaakher committed Sep 22, 2023
1 parent 186f21b commit 5e87226
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 47 deletions.
44 changes: 21 additions & 23 deletions User.resolver.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@

const User = require('./models/User');
module.exports = {
Query: {
async getUsers() {
return await User.find();
},
async getUser(_, { id }) {
return await User.findById({_id : id});
}
const User = require("./models/User");
module.exports = {
Query: {
async getUsers() {
return await User.find();
},
Mutation: {
async createUser(_, { input }) {
const newUser = new User(input);
return await newUser.save();
},
async updateUser(_, { id, input }) {
return await User.findByIdAndUpdate(id, input, { new: true });
},
async deleteUser(_, { id }) {
return await User.findByIdAndDelete({_id :id});
}
}
async getUser(_, { id }) {
return await User.findById({ _id: id });
},
},
Mutation: {
async createUser(_, { input }) {
const newUser = new User(input);
return await newUser.save();
},
async updateUser(_, { id, input }) {
return await User.findByIdAndUpdate(id, input, { new: true });
},
async deleteUser(_, { id }) {
return await User.findByIdAndDelete({ _id: id });
},
},
};

42 changes: 19 additions & 23 deletions User.type.graphql
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@

type User {
name: String
email: String
password: String
}
input UserInput {
name: String
email: String
password: String
}
type Query {
getUsers: [User]
getUser(_id : ID): User

}
type Mutation {
createUser(input: UserInput): User
updateUser(_id: ID, input: UserInput): User
deleteUser(_id: ID): User
}


type User {
name: String
email: String
password: String
}
input UserInput {
name: String
email: String
password: String
}
type Query {
getUsers: [User]
getUser(_id: ID): User
}
type Mutation {
createUser(input: UserInput): User
updateUser(_id: ID, input: UserInput): User
deleteUser(_id: ID): User
}
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
"start": "next start -p 3033"
},
"author": "Sikka Software <[email protected]>",
"license": "MIT",
Expand Down

0 comments on commit 5e87226

Please sign in to comment.