Inspired by graph.ql
, graphql-tools
, and graphql-helpers
.
There are various libraries out there providing utilities for GraphQL and even the reference implementation itself is adding new utilities. So why do we need another one?
None of those libraries let you build GraphQL types using the schema language. This prevents gradual adoption of the tools and makes code separation and isolation a nightmare.
With graphql-utilities
it's simple. build
makes it extremely simple to build a GraphQL type.
build(`
type Query {
ok: Boolean!
}
`);
/* is equivalent to */
new GraphQLObjectType({
name: 'Query',
fields: () => ({
ok: { type: new GraphQLNonNull(GraphQLBoolean) },
}),
})
npm install --save graphql-utilities
import { build } from 'graphql-utilities';
// you can build a type
const Record = build(`
interface Record {
id: ID!
}
`);
// or you can build a schema
const Schema = build(`
schema {
query: Query
}
type Query {
ok: Boolean!
}
`);
- Add detailed API docs.
-
Makebuild
configuration interchangeable with types. -
Allowbuild
to accept a flag to skip inferred schema.
MIT