Created
July 8, 2019 10:10
-
-
Save daniele-zurico/3426ac27193e99872ab35c73fbe480cd to your computer and use it in GitHub Desktop.
This file contains 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 {gql} = require('apollo-server'); | |
const typeDefs = gql` | |
extend type Query { | |
author(id: ID!): Author | |
authors: [Author] | |
} | |
type Author { | |
id: ID! | |
name: String | |
surname: String | |
} | |
`; | |
const resolvers = { | |
Query: { | |
author(_, {id}) { | |
return { | |
id, | |
name: 'Daniele', | |
surname: 'Zurico' | |
} | |
}, | |
authors() { | |
return [ | |
{ | |
id: Math.round(Math.random() * 100000), | |
name: 'Daniele', | |
surname: 'Zurico', | |
}, | |
{ | |
id: Math.round(Math.random() * 100000), | |
name: 'Alex', | |
surname: 'Michaels', | |
} | |
] | |
} | |
} | |
}; | |
module.exports = { | |
typeDefs, | |
resolvers | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment