antv-l7/node_modules/graphql-type-json
thinkinggis f7e5376b7d fix(fix css): fix css png 2019-11-22 18:04:14 +08:00
..
lib fix(fix css): fix css png 2019-11-22 18:04:14 +08:00
LICENSE fix(fix css): fix css png 2019-11-22 18:04:14 +08:00
README.md fix(fix css): fix css png 2019-11-22 18:04:14 +08:00
package.json fix(fix css): fix css png 2019-11-22 18:04:14 +08:00

README.md

graphql-type-json Travis npm

JSON scalar type for GraphQL.js.

Codecov

Usage

This package exports a JSON scalar GraphQL.js type:

import GraphQLJSON from 'graphql-type-json';

Programmatically-constructed schemas

You can use this in a programmatically-constructed schema as with any other scalar type:

import { GraphQLObjectType } from 'graphql';
import GraphQLJSON from 'graphql-type-json';

export default new GraphQLObjectType({
  name: 'MyType',

  fields: {
    myField: { type: GraphQLJSON },
  },
});

SDL with GraphQL-tools

When using the SDL with GraphQL-tools, define GraphQLJSON as the resolver for the appropriate scalar type in your schema:

import { makeExecutableSchema } from 'graphql-tools';
import GraphQLJSON from 'graphql-type-json';

const typeDefs = `
scalar JSON

type MyType {
  myField: JSON
}

# ...
`;

const resolvers = {
  JSON: GraphQLJSON,
};

export default makeExecutableSchema({ typeDefs, resolvers });