• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

graphql-compose/graphql-compose-examples

开源软件地址(OpenSource Url):

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

开源编程语言(OpenSource Language):

TypeScript 59.7%

开源软件介绍(OpenSource Introduction):

This is example app of graphql-compose

Travis

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

yarn install
yarn seed && yarn dev
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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap