Created
January 21, 2019 10:24
-
-
Save chathuranga94/f8f2d10cfb41fcbc5509c15b57c56a0a to your computer and use it in GitHub Desktop.
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
const typeDefs = gql` | |
type Query { | |
Posts: [Post], | |
} | |
type Mutation { | |
addPost(title: String!, content: String!): [Post] | |
} | |
type Post { | |
title: String | |
content: String | |
} | |
`; | |
const resolvers = { | |
Query: { | |
Posts: () => posts, | |
}, | |
Mutation: { | |
addPost: (obj, args) => { | |
posts.push({title: args.title, content: args.content}); | |
return posts; | |
} | |
} | |
}; | |
let posts = [ | |
{ title: 'Harry Potter', content: 'J.K. Rowling',}, | |
{ title: 'Jurassic Park', content: 'Michael Crichton',}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment