Skip to content

Commit

Permalink
Add pushNotification mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-carbonne committed Feb 19, 2018
1 parent b27e300 commit 79e6a1a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/index.js
Expand Up @@ -7,9 +7,18 @@ const notifications = [];
const typeDefs = `
type Query { notifications: [Notification] }
type Notification { label: String }
type Mutation { pushNotification(label: String!): Notification }
`;
const resolvers = {
Query: { notifications: () => notifications },
Mutation: {
pushNotification: (root, args) => {
const newNotification = { label: args.label };
notifications.push(newNotification);

return newNotification;
},
},
};
const schema = makeExecutableSchema({ typeDefs, resolvers });

Expand Down

0 comments on commit 79e6a1a

Please sign in to comment.