Skip to content

Instantly share code, notes, and snippets.

@marcusstenbeck
Last active January 17, 2018 20:02
Show Gist options
  • Save marcusstenbeck/b3cc6def21b2dd2fd7e08bbd65c6492c to your computer and use it in GitHub Desktop.
Save marcusstenbeck/b3cc6def21b2dd2fd7e08bbd65c6492c to your computer and use it in GitHub Desktop.
const { makeExecutableSchema } = require('graphql-tools');
const { GraphQLDateTime } = require('graphql-iso-date');
const gql = require('graphql-tag');
const { createStore } = require('../event-store');
const addShow = require('../commands/addShow');
const getShows = require('../queries/getShow');
const eventStore = createStore();
const typeDefs = gql`
scalar DateTime
type Show {
title: String!
time: DateTime!
host: String!
location: String!
}
type Query {
allShows: [Show!]!
}
type Mutation {
addShow(
title: String!
time: DateTime!
host: String!
location: String!
): Boolean
}
`;
module.exports = makeExecutableSchema({
typeDefs,
resolvers: {
DateTime: GraphQLDateTime,
Query: {
allShows: () => getShows(eventStore)
},
Mutation: {
addShow: (_, data) => {
addShow(eventStore, data);
return true;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment