https://github.com/jimthedev/gra
a wrapper around GraphQL's type module. It makes the syntax slightly less repetitive.
https://github.com/jimthedev/gra
Last synced: about 2 months ago
JSON representation
a wrapper around GraphQL's type module. It makes the syntax slightly less repetitive.
- Host: GitHub
- URL: https://github.com/jimthedev/gra
- Owner: jimthedev
- Created: 2016-09-05T18:11:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-31T21:50:08.000Z (almost 8 years ago)
- Last Synced: 2025-04-03T13:40:22.003Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Description
**gra** is a wrapper around GraphQL's type module. It makes the syntax slightly less repetitive.
## Usage
### Install
```
npm install --save graphql
npm install --save gra
```### Use it
```
var g = require('gra');// Micro syntax
g.id // ==> GraphQLID,
g.i // ==> GraphQLInt,
g.f // ==> GraphQLFloat,
g.s // ==> GraphQLString,
g.b // ==> GraphQLBoolean,
g.o // ==> GraphQLObjectType,
g.l // ==> GraphQLList,
g.u // ==> GraphQLUnionType,
g.e // ==> GraphQLEnumType,
g.in // ==> GraphQLInputObjectType,
g.sc // ==> GraphQLScalarType,
g.if // ==> GraphQLInterfaceType,
g.nn // ==> GraphQLNonNull,
g.schema // ==> GraphQLSchema,// Short syntax
g.ident // ==> GraphQLID,
g.int // ==> GraphQLInt,
g.float // ==> GraphQLFloat,
g.str // ==> GraphQLString,
g.bool // ==> GraphQLBoolean,
g.obj // ==> GraphQLObjectType,
g.list // ==> GraphQLList,
g.union // ==> GraphQLUnionType,
g.enum // ==> GraphQLEnumType,
g.input // ==> GraphQLInputObjectType,
g.scal // ==> GraphQLScalarType,
g.inter // ==> GraphQLInterfaceType,
g.non // ==> GraphQLNonNull,
g.schema // ==> GraphQLSchema,// Medium syntax
g.identifier // ==> GraphQLID,
g.integer // ==> GraphQLInt,
g.float // ==> GraphQLFloat,
g.string // ==> GraphQLString,
g.boolean // ==> GraphQLBoolean,
g.object // ==> GraphQLObjectType,
g.list // ==> GraphQLList,
g.union // ==> GraphQLUnionType,
g.enum // ==> GraphQLEnumType,
g.inputObject // ==> GraphQLInputObjectType,
g.scalar // ==> GraphQLScalarType,
g.interface // ==> GraphQLInterfaceType,
g.nonNull // ==> GraphQLNonNull,
g.schema // ==> GraphQLSchema,```
So, using `g.i` or `g.int` or `g.integer` is the same as using `GraphQLInt`.You can mix and match micro, short, and medium syntax. They are all provided in various forms for convenience.
Each of the above can be used in place of its [more verbose cousin](http://graphql.org/docs/api-reference-type-system/).
GraphQL is a peerDependency of this project so you should not be hard coded to a specific GraphQL version.
## Inspiration
https://twitter.com/samerbuna/status/771719039441702912