daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top