0.3.2 • Published 4 years ago

graphql-type-json v0.3.2

Weekly downloads
1,203,447
License
MIT
Repository
github
Last release
4 years ago

graphql-type-json Travis npm

JSON scalar types for GraphQL.js.

Codecov

Usage

This package exports a JSON value scalar GraphQL.js type:

import GraphQLJSON from 'graphql-type-json';

It also exports a JSON object scalar type:

import { GraphQLJSONObject } from 'graphql-type-json';

These types can also be imported as follows using CommonJS:

const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json');

GraphQLJSON can represent any JSON-serializable value, including scalars, arrays, and objects. GraphQLJSONObject represents specifically JSON objects, which covers many practical use cases for JSON scalars.

Programmatically-constructed schemas

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

import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json';

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

  fields: {
    myValue: { type: GraphQLJSON },
    myObject: { type: GraphQLJSONObject },
  },
});

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, { GraphQLJSONObject } from 'graphql-type-json';

const typeDefs = `
scalar JSON
scalar JSONObject

type MyType {
  myValue: JSON
  myObject: JSONObject
}

# ...
`;

const resolvers = {
  JSON: GraphQLJSON,
  JSONObject: GraphQLJSONObject,
};

export default makeExecutableSchema({ typeDefs, resolvers });
@withjoy/server-core@caravinci/arranger-server@yuants/server@shoptet/graphql@sprucelabs/spruce-skill@devopstation/graphnestjs-bookstore-mvc@zenofa/zegraphmelodi-data@aifedespaix/fdp-apicaoliao-plugin-graphql@etherspot/relaydigibuild-gtt-backendgqlx-apollo-express-server-v2page-metrics-root@deity/falcon-serversteezy-api@lysander6/directus@bitexchange-ltd/bitexchange-server-7.5.0-beta.3@rainbunny/api-core@startdt/cli-uijustt-tyx-newfp-operator@gomoko/core@flick/core@startdt/next-workcancerbero-backendcenhomenpm@kaviar/x-bundlehzero-cli-ui@xyo-network/sdk-diviner-nodejs@xyo-network/app-xyo-nodejsnocodb1gate-backendcompass-eth-db@scrumble/appsync-emulator-serverless@tealess/plugin-graphqlsubkitlec-event-logs-api@picker-cc/coreberserk-plugin-graphql@oss-stealth/typescript@knapsack/api-serveresm-payloadnocodb-dailytyx@everything-registry/sub-chunk-1786@itoa/itoa@itoa/keystone@graphql-reshape/scalars@puschel/hub@kiwicom/logmolekedro-viz@itandu/server@itandu/core-backendgraphql-schema-from-json@last-rev/graphql-contentful-core@lmkdbd/fib-app@lmos/graphql@livepeer/graphql-sdk@m7eio/mongo-graphql-starter@lowdefy/renderer@lowdefy/graphql@lerda/server@lerna-ui/server@mandalalabs/magishift.core@kamil.chm/swagger-to-graphql@k6js/core@k6js/ks-next@keystone-next/keystone@keystone-next/keystone-legacy@keystone-alpha/keystone@keystonejs/keystone@keystone-6-master/core@kfarranger/admin@kfarranger/schema@koakh/nestjs-package-jwt-authentication-graphql@koikorn/keystone@imec/duxis-auth@igloo-be-omnipartners/graphql-schema@ilink-dev/common@interactivethings/visualize-app@joelworsham/sequelize-graphql@jariz/amplify-appsync-simulator@ishtar-gate/dp-hasura@jobhopin/graphql@jpruden/openapi-to-graphql@jovens-genios/vue-components@joystream/warthog@gen3/guppy@graphnosql/directives@graphnosql/mongoose@marvi-io/admin@mathieudutour/gatsby@metahop/graphql@metmirr/warthog@jmnribeiro/loopback-graphql-relay@jmondi/prisma-generator-nestjs-graphql@teamstarter/graphql-web-hook@tegh/core
0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.4

7 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago