Skip to content

Instantly share code, notes, and snippets.

@SaraVieira
Created June 26, 2018 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaraVieira/f294a151bc73965961cbb2fd19a7c06e to your computer and use it in GitHub Desktop.
Save SaraVieira/f294a151bc73965961cbb2fd19a7c06e to your computer and use it in GitHub Desktop.
const resolvers = {
Query: {
movies: () => movies,
movie: (_, { id }) => movies.find(movie => movie.id == id)
},
Mutation: {
addMovie: (_, { title, year }) => {
const newMovie = {
title,
year,
id: randomId(10)
}
movies.push(newMovie)
return newMovie
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment