Skip to content

Instantly share code, notes, and snippets.

@suciuvlad
Last active July 14, 2018 09:53
Show Gist options
  • Select an option

  • Save suciuvlad/d4ff7cf91fb7fa6fd8a25a3fa3a5c9e7 to your computer and use it in GitHub Desktop.

Select an option

Save suciuvlad/d4ff7cf91fb7fa6fd8a25a3fa3a5c9e7 to your computer and use it in GitHub Desktop.
graphql-microservices-example
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