graphql-js-schema
Transforms the JSON representation of a GraphQL schema into a set of ES6 type modules.
Table Of Contents
Installation
With Yarn:
$ yarn global add graphql-js-schema
With NPM:
$ npm install -g graphql-js-schema
Examples
To transform a GraphQL schema file (as json) into a set of ES6 consumable modules, run the following command.
graphql-js-schema --schema-file ./schema.json --outdir schema --schema-bundle-name="Types"
This will create a directory called schema, and a root module called Schema
in
the file schema/types.js
. It will also collect all the non-scalar types in
schema/types/
, and export them. The top level bundle exists for convenience,
but you can consume these modules however you like.
API
Exports one function that transforms a schema object into a list of files and their associated bodies.
; ;
Schema Modules
; SchemaProductname // => ProductSchemaProductimplementsNode // => trueSchemaProductkind // => OBJECT // All type strings returned through `fieldBaseTypes` are available in the// schema for further exploration. SchemaProductfieldBaseTypesid // => IDSchemaProductfieldBaseTypeshandle // => StringSchemaProductfieldBaseTypesimages // => ImageSchemaProductfieldBaseTypesoptions // => ProductOptionSchemaProductfieldBaseTypesproductType // => StringSchemaProductfieldBaseTypespublishedAt // => DateTimeSchemaProductfieldBaseTypestags // => StringSchemaProductfieldBaseTypesvendor // => StringSchemaProductfieldBaseTypescollections // => CollectionConnectionSchemaProductfieldBaseTypesvariants // => ProductVariantConnectionSchemaProductfieldBaseTypescreatedAt // => DateTimeSchemaProductfieldBaseTypesupdatedAt // => DateTime
License
MIT, see LICENSE.md for details.