https://github.com/migueloller/graphql-utilities
Build GraphQL types using the schema language.
https://github.com/migueloller/graphql-utilities
graphql graphql-js graphql-schema graphql-types graphql-utilities
Last synced: 5 months ago
JSON representation
Build GraphQL types using the schema language.
- Host: GitHub
- URL: https://github.com/migueloller/graphql-utilities
- Owner: migueloller
- License: mit
- Created: 2016-09-05T05:01:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-01T06:39:17.000Z (over 8 years ago)
- Last Synced: 2025-02-01T07:31:40.728Z (5 months ago)
- Topics: graphql, graphql-js, graphql-schema, graphql-types, graphql-utilities
- Language: JavaScript
- Homepage:
- Size: 69.3 KB
- Stars: 35
- Watchers: 5
- Forks: 4
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-utilities
[](https://badge.fury.io/js/graphql-utilities) [](https://travis-ci.org/bloveit/graphql-utilities) [](https://coveralls.io/github/bloveit/graphql-utilities?branch=master)Inspired by [`graph.ql`](https://github.com/MatthewMueller/graph.ql), [`graphql-tools`](https://github.com/apollostack/graphql-tools), and [`graphql-helpers`](https://github.com/depop/graphql-helpers).
## Why?
There are various libraries out there providing utilities for GraphQL and even the [reference implementation](https://github.com/graphql/graphql-js) itself is adding [new utilities](https://github.com/graphql/graphql-js/pull/471). 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.
```js
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
```js
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