Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @ts-check
- const { graphql } = require('graphql');
- const { makeExecutableSchema } = require('graphql-tools');
- const schema = makeExecutableSchema({
- typeDefs: `
- type Query {
- get(input: Input!): String!
- }
- type Mutation {
- create(input: Input!): String!
- }
- input Input {
- id: String!
- }
- `,
- resolvers: {
- Query: {
- get(_, args) {
- console.log(args.input);
- return 'Blah';
- }
- },
- Mutation: {
- create(_, args) {
- console.log(args.input);
- return 'Blah';
- }
- }
- }
- });
- graphql({
- schema,
- source: 'mutation { create(input: { id:"123" })}'
- }).then(result => {
- console.log(result);
- });
- graphql({
- schema,
- source: 'query { get(input: { id:"123" })}'
- }).then(result => {
- console.log(result);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement