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
npm install --save graphql @creditkarma/graphql-loader
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())
Install dependencies with
npm install
npm run build
npm run test:watch
For more information about contributing new features and bug fixes, see our Contribution Guidelines. External contributors must sign Contributor License Agreement (CLA)
This project is licensed under Apache License Version 2.0