Skip to content

Instantly share code, notes, and snippets.

@alexandr-g
Created June 11, 2020 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandr-g/69d666ebbd960157fc733b3c38b344ea to your computer and use it in GitHub Desktop.
Save alexandr-g/69d666ebbd960157fc733b3c38b344ea to your computer and use it in GitHub Desktop.
apollo/type-defs.js
// apollo/revolvers.js
export const resolvers = {
Query: {
users(_parent, _args, _context, _info) {
return _context.db
.collection('users')
.findOne()
.then((data) => {
return data.users
})
},
},
}
// apollo/schema.js
import { makeExecutableSchema } from 'graphql-tools'
import { typeDefs } from './type-defs'
import { resolvers } from './resolvers'
export const schema = makeExecutableSchema({
typeDefs,
resolvers,
})
// apollo/type-defs.js
import gql from 'graphql-tag'
export const typeDefs = gql`
type User {
id: ID!
firstName: String!
lastName: String!
blog: String
stars: Int
}
type Query {
users: [User]!
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment