Live examples of schemas builded with graphql-compose
graphql-compose
Live example on Heroku: https://graphql-compose.herokuapp.com/
npm install npm run seed && npm run start:watch open http://localhost:3000
This example has simple User mongoose model that supports bunch of CRUD operations.
const UserSchema = new mongoose.Schema({ name: String, // standard types age: { type: Number, index: true, }, languages: { type: [LanguagesSchema], // you may include other schemas (here included as array of embedded documents) default: [], }, contacts: { // another mongoose way for providing embedded documents email: String, phones: [String], // array of strings }, gender: { // enum field with values type: String, enum: ['male', 'female', 'ladyboy'], }, });
This schema shows all available CRUD operations which are compatible with Relay. It uses
graphql-compose-mongoseand
graphql-compose-relay: -
composeWithRelay(RootQueryTC)adds
nodefield to the RootQuery. Via
RootQuery.node(id)you may find objects by globally unique ID among all types. -
composeWithRelay(UserTC)- modify
UserTCgenerated by
graphql-compose-mongoose
idfield with Relay's globally unique ID - this type will be added to
NodeInterfacefor resolving via
RootQuery.node- for mutations will be added
clientMutationIdto input and output objects types - also all arguments in mutations will be moved into
inputarg
This is a sample data of some trading company, which consists from 8 models. All models has cross-relations to each other. This schema used in the Relay example app: Server schema code, Client app code, Live demo of client.
This schema uses graphql-compose-elasticsearch module and provides full API available in the official elasticsearch module.