Guest User

Untitled

a guest
Apr 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import {makeExecutableSchema} from 'graphql-tools';
  2.  
  3. const typeDefs = `
  4. type Query {
  5. message(id: ID!): String!
  6. }
  7.  
  8. type Mutation {
  9. message(id: ID!): String!
  10. }
  11. `
  12.  
  13. const resolvers = {
  14. Query: {
  15. message: (_, {id}) => new Promise(resolve => {
  16. setTimeout(function() {
  17. let message = `response to message ${id}`;
  18. console.log(message)
  19. resolve(message);
  20. }, Math.random() * 10000)
  21. })
  22. },
  23. Mutation: {
  24. message: (_, {id}) => new Promise(resolve => {
  25. setTimeout(function() {
  26. let message = `response to message ${id}`;
  27. console.log(message)
  28. resolve(message);
  29. }, Math.random() * 10000)
  30. })
  31. }
  32. }
  33.  
  34. const schema = makeExecutableSchema({typeDefs, resolvers});
  35. export {
  36. schema
  37. };
Add Comment
Please, Sign In to add comment