graphql-schema-collector
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

graphql-loader

Instantiate a GraphQL Schema by loading GraphQL Schema Language files based on a glob pattern

  • Allows creation of GraphQL Schema via GraphQL schema language shorthand
  • Supports splitting the schema into modules
  • Parse and validate schema files

Installation

npm install --save graphql @creditkarma/graphql-loader

Usage

Given the following files

schema/schema.graphql

schema {
  query: RootQuery
}

schema/rootQuery.graphql

type RootQuery {
  testString: String
}

Create a schema with the following code:

const loader = require('@creditkarma/graphql-loader')
 
loader.loadSchema('./schema/*.graphql', (err, schema) => {
  console.log(schema.getQueryType().toString())
})

Create a schema using promises:

const loader = require('@creditkarma/graphql-loader')
 
loader.loadSchema('./schema/*.graphql').then((schema) => {
  console.log(schema.getQueryType().toString())
})

Create a schema using sync:

const loader = require('@creditkarma/graphql-loader')
 
const schema = loader.loadSchema.sync('./schema/*.graphql')
console.log(schema.getQueryType().toString())
 

Development

Install dependencies with

npm install
npm run typings

Build

npm run build

Run test in watch mode

npm run test:watch

Contributing

For more information about contributing new features and bug fixes, see our Contribution Guidelines. External contributors must sign Contributor License Agreement (CLA)

License

This project is licensed under Apache License Version 2.0

Readme

Keywords

Package Sidebar

Install

npm i graphql-schema-collector

Weekly Downloads

4

Version

0.2.5

License

Apache-2.0

Last publish

Collaborators

  • veeramarni