(阿波罗)GraphQL合并模式
我使用GraphQL工具/阿波罗提供的库。
它可以远程GraphQL架构合并为一个嵌套结构?
假设我有n
远程模式,我想从不同模式的Query
,Mutation
和Subscription
合并成一个单一的架构,除了每个远程模式被划归自己type
。
假设我们有一个名为MenuX
与远程模式:
type Item {
id: Int!
description: String
cost: Int
}
type Query {
items: [Item]
}
并呼吁远程模式MenuY
有:
type Item {
id: Int!
name: String
cost: Int
}
type Query {
items: [Item]
}
我想架构合并成一个单一的模式,但根据自己的类型。一个人为的例子:
type MenuXItem {
id: Int!
description: String
cost: Int
}
type MenuYItem {
id: Int!
name: String
cost: Int
}
type MenuXQuery {
items: [MenuXItem]
}
type MenuYQuery {
items: [MenuYItem]
}
type Query {
MenuX: MenuXItem
MenuY: MenuYItem
}
正如我们可以看到,Query
下键入它包含包含来自远程模式查询式两种新类型。从架构Item
MenuX
已更名利用从graphql-tools
变压器,同样Item
从MenuY
已经转变以及架构。
但是,它可能转化结构呢?
随着实际的远程模式,我们正在寻找在数百种来自每个模式,理想情况下,我想不污染根类型和GraphiQL反省文档。
回答如下:没有为盖茨比包含你想要做什么变压器插件:https://github/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/transforms.js
它的命名空间类型现有GraphQL模式,让你最终:
type Namespace1Item {
...
}
type Namespace2Item {
...
}
type Namespace1Query {
items: [Namespace1Item]
}
type Namespace2Query {
items: [Namespace2Item]
}
type Query {
namespace1: Namespace1Query
namespace2: Namespace2Query
}
所以,如果你改变你的模式和他们合并他们,你应该是不错的。
(阿波罗)GraphQL合并模式
我使用GraphQL工具/阿波罗提供的库。
它可以远程GraphQL架构合并为一个嵌套结构?
假设我有n
远程模式,我想从不同模式的Query
,Mutation
和Subscription
合并成一个单一的架构,除了每个远程模式被划归自己type
。
假设我们有一个名为MenuX
与远程模式:
type Item {
id: Int!
description: String
cost: Int
}
type Query {
items: [Item]
}
并呼吁远程模式MenuY
有:
type Item {
id: Int!
name: String
cost: Int
}
type Query {
items: [Item]
}
我想架构合并成一个单一的模式,但根据自己的类型。一个人为的例子:
type MenuXItem {
id: Int!
description: String
cost: Int
}
type MenuYItem {
id: Int!
name: String
cost: Int
}
type MenuXQuery {
items: [MenuXItem]
}
type MenuYQuery {
items: [MenuYItem]
}
type Query {
MenuX: MenuXItem
MenuY: MenuYItem
}
正如我们可以看到,Query
下键入它包含包含来自远程模式查询式两种新类型。从架构Item
MenuX
已更名利用从graphql-tools
变压器,同样Item
从MenuY
已经转变以及架构。
但是,它可能转化结构呢?
随着实际的远程模式,我们正在寻找在数百种来自每个模式,理想情况下,我想不污染根类型和GraphiQL反省文档。
回答如下:没有为盖茨比包含你想要做什么变压器插件:https://github/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/transforms.js
它的命名空间类型现有GraphQL模式,让你最终:
type Namespace1Item {
...
}
type Namespace2Item {
...
}
type Namespace1Query {
items: [Namespace1Item]
}
type Namespace2Query {
items: [Namespace2Item]
}
type Query {
namespace1: Namespace1Query
namespace2: Namespace2Query
}
所以,如果你改变你的模式和他们合并他们,你应该是不错的。