Skip to content

Instantly share code, notes, and snippets.

@felipe-ssilva
Last active June 7, 2019 22:26
Show Gist options
  • Save felipe-ssilva/7e917dc9e88e6c800c18586141ef757e to your computer and use it in GitHub Desktop.
Save felipe-ssilva/7e917dc9e88e6c800c18586141ef757e to your computer and use it in GitHub Desktop.
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