graphqltypegraphql

Input extend other input on graphql schema


Is it possible any input extend other input on graphql schema?

example below:

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
}

Is there any way to do this?


Solution

  • Unfortunately, No. An ObjectType can use Interfaces to extend abstract types, but an InputType cannot.

    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.

    There is an input extends ExistingInputType extension syntax in the specs, but this does not create a new type, but rather adds new fields to an existing input.