Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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