Last active
June 7, 2019 22:26
-
-
Save felipe-ssilva/7e917dc9e88e6c800c18586141ef757e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const typeDefs = ` | |
type Mutation { | |
updateUser(id: ID!, name: String!, email: String!): User | |
} | |
`; | |
const resolvers = { | |
Mutation: { | |
updateUser: (_, { id, name, email }) => { | |
const user = find(users, { id: id }); | |
if (!user) { | |
throw new Error(`Couldn’t find user with id ${id}`); | |
} | |
user.name = name; | |
user.email = email; | |
return user; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment