Description
The Type System spec, under Input objects, states (emphasis mine):
The
Object
type defined above is inappropriate for re-use here, becauseObject
s can contain fields that express circular references or 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.
The reference implementation indeed disallows interfaces and unions in inputs, implying the above sentence should be understood as a rule forbidding them and not just a recommendation against using them.
On the other hand, the implementation allows circular references in GraphQLInputObjectType
s.
E.g. the following is a legal declaration (ArticleInputType
referring to ArticleInputType
):
const ArticleInputType = new GraphQLInputObjectType({
name: 'ArticleInput',
fields: () => ({
id: { type: GraphQLInt },
title: { type: new GraphQLNonNull(GraphQLString) },
body: { type: GraphQLString },
relatedArticles: { type: new GraphQLList(ArticleInputType) }
})
});
This implies the sentence from the spec should be understood as a recommendation.
I suggest the wording in the corresponding spec section is changed to be consistent with the reference implementation or vice versa.
The current state leads to inconsistencies between the reference and other implementations, depending on their interpretation of the spec.