graphql-utilities
v0.0.14
Published
Utilities for GraphQL
Downloads
251
Readme
graphql-utilities
Inspired by graph.ql
, graphql-tools
, and graphql-helpers
.
Why?
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) },
}),
})
Installation
npm install --save graphql-utilities
Getting Started
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!
}
`);
TODO
- [ ] Add detailed API docs.
- [x] ~~Make
build
configuration interchangeable with types.~~ - [x] ~~Allow
build
to accept a flag to skip inferred schema.~~
License
MIT