Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. // @ts-check
  2. const { graphql } = require('graphql');
  3. const { makeExecutableSchema } = require('graphql-tools');
  4.  
  5. const schema = makeExecutableSchema({
  6. typeDefs: `
  7. type Query {
  8. get(input: Input!): String!
  9. }
  10.  
  11. type Mutation {
  12. create(input: Input!): String!
  13. }
  14.  
  15. input Input {
  16. id: String!
  17. }
  18. `,
  19. resolvers: {
  20. Query: {
  21. get(_, args) {
  22. console.log(args.input);
  23. return 'Blah';
  24. }
  25. },
  26. Mutation: {
  27. create(_, args) {
  28. console.log(args.input);
  29. return 'Blah';
  30. }
  31. }
  32. }
  33. });
  34.  
  35. graphql({
  36. schema,
  37. source: 'mutation { create(input: { id:"123" })}'
  38. }).then(result => {
  39. console.log(result);
  40. });
  41.  
  42. graphql({
  43. schema,
  44. source: 'query { get(input: { id:"123" })}'
  45. }).then(result => {
  46. console.log(result);
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement