Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. /* @flow */
  2.  
  3. import {
  4. GraphQLSchema,
  5. } from 'graphql';
  6.  
  7. import { Registry } from 'graphql-helpers';
  8. import { middleware } from 'graphql-helpers/lib/contrib/relay';
  9.  
  10. const registry = new Registry(middleware);
  11.  
  12. registry.createType(`
  13. type User {
  14. username: String!
  15. }
  16. `);
  17.  
  18. registry.createType(`
  19. type Query {
  20. user(username: String!): User
  21. }
  22. `);
  23.  
  24. registry.createType(`
  25. type LoginPayload {
  26. token: String!
  27. }
  28. `);
  29.  
  30. registry.createMutations(`
  31. type AuthMutations {
  32. login(username: String!, password: String!): LoginPayload
  33. }
  34. `, {
  35. login: ({username, password}) => ({
  36. token: `A super secure token ${username}/${password}`,
  37. }),
  38. });
  39.  
  40. new GraphQLSchema({
  41. query: registry.getType('Query'),
  42. mutation: registry.getMutationType(),
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement