mirror of https://github.com/Requarks/wiki.git
8 changed files with 118 additions and 20 deletions
Split View
Diff Options
-
2package.json
-
4server/index.js
-
4server/middlewares/security.js
-
2server/models/user.js
-
20server/modules/auth.js
-
3server/modules/db.js
-
67server/modules/graphql.js
-
36yarn.lock
@ -0,0 +1,67 @@ |
|||
'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 |
Write
Preview
Loading…
Cancel
Save