graphql-schema-collector
v0.2.5
Published
Build a GraphQL Schema by loading .graphql files based a glob pattern
Downloads
6
Readme
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