Skip to content

Instantly share code, notes, and snippets.

@daniele-zurico
Created July 8, 2019 10:10
Show Gist options
  • Save daniele-zurico/3426ac27193e99872ab35c73fbe480cd to your computer and use it in GitHub Desktop.
Save daniele-zurico/3426ac27193e99872ab35c73fbe480cd to your computer and use it in GitHub Desktop.
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