12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 'use strict'
- /* global wiki */
- const gql = require('graphql')
- const User = new gql.GraphQLObjectType({
- name: 'User',
- description: 'A User',
- fields() {
- return {
- id: {
- type: gql.GraphQLInt,
- resolve(usr) {
- return usr.id
- }
- },
- email: {
- type: gql.GraphQLString,
- resolve(usr) {
- return usr.email
- }
- },
- provider: {
- type: gql.GraphQLString,
- resolve(usr) {
- return usr.provider
- }
- },
- providerId: {
- type: gql.GraphQLString,
- resolve(usr) {
- return usr.providerId
- }
- }
- }
- }
- })
- const Query = new gql.GraphQLObjectType({
- name: 'Query',
- description: 'Root Query',
- fields() {
- return {
- users: {
- type: new gql.GraphQLList(User),
- args: {
- id: {
- type: gql.GraphQLInt
- },
- email: {
- type: gql.GraphQLString
- }
- },
- resolve(root, args) {
- return wiki.db.User.findAll({ where: args })
- }
- }
- }
- }
- })
- const Schema = new gql.GraphQLSchema({
- query: Query
- })
- module.exports = Schema
|