Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* @flow */
- import {
- GraphQLSchema,
- } from 'graphql';
- import { Registry } from 'graphql-helpers';
- import { middleware } from 'graphql-helpers/lib/contrib/relay';
- const registry = new Registry(middleware);
- registry.createType(`
- type User {
- username: String!
- }
- `);
- registry.createType(`
- type Query {
- user(username: String!): User
- }
- `);
- registry.createType(`
- type LoginPayload {
- token: String!
- }
- `);
- registry.createMutations(`
- type AuthMutations {
- login(username: String!, password: String!): LoginPayload
- }
- `, {
- login: ({username, password}) => ({
- token: `A super secure token ${username}/${password}`,
- }),
- });
- new GraphQLSchema({
- query: registry.getType('Query'),
- mutation: registry.getMutationType(),
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement