Giter VIP home page Giter VIP logo

graphql-compose-examples's Introduction

This is example app of graphql-compose

Travis

Live example on Heroku: https://graphql-compose.herokuapp.com/

npm install
npm run seed && npm run start:watch
open http://localhost:3000

User: simple schema with one type

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'],
  },
});

screen shot 2016-07-03 at 15 23 03

screen shot 2016-07-15 at 12 41 17

User for Relay: simple schema with one type

This schema shows all available CRUD operations which are compatible with Relay. It uses graphql-compose-mongose and graphql-compose-relay:

  • composeWithRelay(RootQueryTC) adds node field to the RootQuery. Via RootQuery.node(id) you may find objects by globally unique ID among all types.
  • composeWithRelay(UserTC) - modify UserTC generated by graphql-compose-mongoose
    • adds id field with Relay's globally unique ID
    • this type will be added to NodeInterface for resolving via RootQuery.node
    • for mutations will be added clientMutationId to input and output objects types
    • also all arguments in mutations will be moved into input arg

screen shot 2017-03-13 at 10 20 34

Northwind: complex schema with 8 models 🌢🌢🌢

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.

relay-northwind-app

Elasticsearch REST API wrapper

This schema uses graphql-compose-elasticsearch module and provides full API available in the official elasticsearch module.

screen shot 2017-03-07 at 22 26 17

graphql-compose-examples's People

Contributors

cellis avatar dependabot[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar katopz avatar nodkz avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.