Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/graphql-compose/graphql-compose-examples
- Owner: graphql-compose
- Created: 2016-07-01T16:41:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:43:30.000Z (about 2 years ago)
- Last Synced: 2024-10-30T00:00:31.053Z (3 months ago)
- Topics: graphql, graphql-compose, graphql-server
- Language: TypeScript
- Homepage: https://graphql-compose.herokuapp.com/
- Size: 10.4 MB
- Stars: 184
- Watchers: 12
- Forks: 314
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
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'],
},
});
```## 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## 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.