graphql-compose
graphql-compose
– provides a type registry with a bunch of methods for programmatic schema construction. It allows not only to extend types but also remove fields, interfaces, args. If you want to write your graphql schema generator – graphql-compose
is a good instrument for you.
- provides methods for editing GraphQL output/input types (add/remove fields/args/interfaces)
- introduces
Resolver
s – the named graphql fieldConfigs, which can be used for finding, updating, removing records - provides an easy way for creating relations between types via
Resolver
s - provides converter from
OutputType
toInputType
- provides
projection
parser from AST - provides
GraphQL schema language
for defining simple types - adds additional types
Date
,Json
And a little bit more
graphql-compose-[plugin]
– are declarative generators/plugins built on top of graphql-compose
, which take some ORMs, schema definitions and create GraphQL Models from them or modify existing GraphQL Types.
graphql-compose
Type generators built on top - graphql-compose-json - generates GraphQL type from JSON (a good helper for wrapping REST APIs)
- graphql-compose-mongoose - generates GraphQL types from mongoose (MongoDB models) with Resolvers.
- graphql-compose-elasticsearch - generates GraphQL types from elastic mappings; ElasticSearch REST API proxy via GraphQL.
- graphql-compose-aws - expose AWS Cloud API via GraphQL
Utility plugins:
- graphql-compose-relay - reassemble GraphQL types with
Relay
specific things, likeNode
type and interface,globalId
,clientMutationId
. - graphql-compose-connection - generates
connection
Resolver fromfindMany
andcount
Resolvers. - graphql-compose-dataloader - adds DataLoader to graphql-composer resolvers.
Documentation
Live Demos
- graphql-compose.herokuapp.com - Live demo of GraphQL Server (9 models, 14 files, ~750 LOC)
- nodkz.github.io/relay-northwind - Live demo of Relay client working with the server above (8 crazy pages, 47 files, ~3000 LOC)
Examples
Please follow Quick Start Guide for the complete example.
Here is just a demo of ambiguity ways of types definitions:
; // You may use SDL format for type definitionconst CityTC = schemaComposer; // Define type via Config objectconst CountryTC = schemaComposer; // Or via declarative methods define some additional fieldsCityTC; // Add resolver methodCityTC; // Remove `tz` field from schemaCityTC; // Add description to fieldCityTC; schemaComposerQuery; schemaComposerMutation; { Object; return resolvers;} // construct schema which can be passed to express-graphql, apollo-server or graphql-yogaconst schema = schemaComposer;
Contributors
This project exists thanks to all the people who contribute.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]