Last active
July 14, 2018 09:53
-
-
Save suciuvlad/d4ff7cf91fb7fa6fd8a25a3fa3a5c9e7 to your computer and use it in GitHub Desktop.
graphql-microservices-example
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
| import { makeExecutableSchema } from 'graphql-tools'; | |
| const movies = [ | |
| { id: 1, title: 'American Pie 2', releaseDate: 1980 }, | |
| { id: 2, title: 'Iron Man', releaseDate: 2001 } | |
| ]; | |
| const typeDefs = ` | |
| type Query { | |
| movies: [Movie] | |
| movie(movieId: ID!): Movie | |
| } | |
| type Movie { | |
| id: ID | |
| title: String | |
| releaseDate: Int | |
| } | |
| `; | |
| const resolvers = { | |
| Query: { | |
| movies: () => movies, | |
| movie(parent, args, context, info) { | |
| return movies.find((movie) => movie.id === Number(args.movieId)); | |
| } | |
| } | |
| }; | |
| export const schema = makeExecutableSchema({ | |
| typeDefs, | |
| resolvers, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment