输入扩展 graphql 模式上的其他输入

Input extend other input on graphql schema

是否有可能任何输入扩展 graphql 模式上的其他输入?

示例如下:

input PaginationInput{
    pageSize: Int
    pageNum: Int
}

# // example for extending input Pagination
input MyFilterInput implement_or_extend PaginationInput {
    attr1: String
}

type Query {

    usingMyFilter(filter: MyFilterInput): Any
}

有什么办法吗?

很遗憾,不能。ObjectType 可以使用 Interfaces 扩展抽象类型,但 InputType 不能。

GraphQL specs: Object types can contain fields that define arguments or contain references to interfaces and unions, neither of which is appropriate for use as an input argument. For this reason, input objects have a separate type in the system.

有一个 input extends ExistingInputType extension syntax in the specs,但这不会创建新类型,而是向现有输入添加新字段。