我有两个 GraphQL 模式,它们定义了两种不同的类型User
,它们是一对一的关系。它们中的每一个都实现了一组用于过滤的参数 ( filter
, , ...)。condition
// analyticsSchema
type User {
id: String!
actions: Int
}
// metadataSchema
type User {
id: String!
age: Int
}
这些类型是双向合并的:
const gatewaySchema = stitchSchemas({
subschemas: [
{
schema: analyticsSchema,
merge: {
User: {
fieldName: 'analyticsById',
selectionSet: '{ id }',
args: originalObject => ({ id: originalObject.id }),
},
},
},
{
schema: metadataSchema,
merge: {
User: {
fieldName: 'metadataById',
selectionSet: '{ id }',
args: originalObject => ({ id: originalObject.id }),
},
},
},
],
mergeTypes: true,
});
使用此实现,我无法访问所有字段以进行过滤:
// What I can do
query ExampleQuery {
allUsers(filter: { actions: { greaterThan: 10 }}) {
edges {
node {
id
actions
age
}
}
}
}
// What I would like to do
query ExampleQuery {
allUsers(filter: {actions: {greaterThan: 10}, age: {lessThan: 35}}) {
edges {
node {
id
actions
age
}
}
}
}
> Problem: Field "age" is not defined by type "UserFilter".
我的问题是,是否可以将所有过滤参数公开给生成的合并类型?或者,也许我走错路了?
注意:两个 GraphQL 端点都依赖,如果这很重要postgraphile
,我们正在使用postgraphile-plugin-connection-filter
插件。