Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/graphql-compose/graphql-compose-examples

Live examples of schemas builded with graphql-compose
https://github.com/graphql-compose/graphql-compose-examples

graphql graphql-compose graphql-server

Last synced: 1 day ago
JSON representation

Live examples of schemas builded with graphql-compose

Awesome Lists containing this project

README

        

## This is example app of `graphql-compose`

[![Travis](https://img.shields.io/travis/graphql-compose/graphql-compose-examples.svg?maxAge=2592000)](https://travis-ci.org/graphql-compose/graphql-compose-examples)

Live example on Heroku: [https://graphql-compose.herokuapp.com/](https://graphql-compose.herokuapp.com/)

```bash
yarn install
yarn seed && yarn dev
open http://localhost:3000
```

## User: simple schema with one type
This [example](https://github.com/graphql-compose/graphql-compose-examples/tree/master/examples/user) has simple User mongoose model that supports bunch of CRUD operations.

```js
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](https://github.com/graphql-compose/graphql-compose-examples/tree/master/examples/userForRelay) 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](https://github.com/graphql-compose/graphql-compose-examples/tree/master/examples/northwind), [Client app code](https://github.com/nodkz/relay-northwind-app), [Live demo of client](https://nodkz.github.io/relay-northwind/).

![relay-northwind-app](https://cloud.githubusercontent.com/assets/1946920/18013918/488e6830-6be2-11e6-84b6-884c8ab971ac.gif)

## Elasticsearch REST API wrapper

This [schema](https://github.com/graphql-compose/graphql-compose-examples/tree/master/examples/elasticsearch) uses [graphql-compose-elasticsearch](https://github.com/graphql-compose/graphql-compose-elasticsearch) module and provides full API available in the official elasticsearch module.

screen shot 2017-03-07 at 22 26 17