Created
June 11, 2020 15:59
-
-
Save alexandr-g/69d666ebbd960157fc733b3c38b344ea to your computer and use it in GitHub Desktop.
apollo/type-defs.js
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
// apollo/revolvers.js | |
export const resolvers = { | |
Query: { | |
users(_parent, _args, _context, _info) { | |
return _context.db | |
.collection('users') | |
.findOne() | |
.then((data) => { | |
return data.users | |
}) | |
}, | |
}, | |
} |
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
// apollo/schema.js | |
import { makeExecutableSchema } from 'graphql-tools' | |
import { typeDefs } from './type-defs' | |
import { resolvers } from './resolvers' | |
export const schema = makeExecutableSchema({ | |
typeDefs, | |
resolvers, | |
}) |
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
// 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