graphql / graphql/graphql-spec
Covariance of arguments not possible for interface implementations
- Dominant language
- JavaScript
- Stars
- 14.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
In the spec as it stands, it does not appear to be possible to make variations on an interface's argument in its implementation, even if the subclass's arguments are functionally conformant to the interface's. Assume the following schema:
```
interface Object
children (filter: Object_Input_Object): Object
type SubObject implements Object
children (filter: SubObject_Input_Object): SubObject
```
In spite of the specific `SubObject` type being a correct implementation of the `Object` interface and their input objects being functionally the same, the schema is invalid since their arguments are not exactly the same.
This appears to be caused by the fact that there is no inheritance mechanism for input objects. The GraphQL type system has no way of knowing that the SubObject_Input_Object is a implementation of Object_Input_Object.
This would be useful, for example, in a situation such as this:
I define a `WorkOfArt` interface which can be filtered based on `date`, `author` and `price`. Then I define a `Sculpture` implementation. I want Scuplture to be filtered on `material` and `school`, but also based on all the `WorkOfArt` filters. I do not want the `WorkOfArt` interface to be filterable based on these fields since the majority of this interface's implementation do not have them defined.
Contributor guide
Assessment
This issue has not been assessed yet.