These are chat archives for graphql-java/graphql-java

30th
Jun 2017
Sanchay Javeria
@javeria2
Jun 30 2017 19:44
Hello, I had a slightly conceptual question. What exactly is GraphQLInputType and GraphQLOutputType? What's the difference between GraphQLInputType and GraphQLInputObjectType?
Can you explain this w the help of an example of a query/mutation?
Bojan Tomić
@kaqqao
Jun 30 2017 19:56

@javeria2 Output types are the type you return from queries/mutation. Input type are the one you take as an argument. E.g. if you had a mutation like this:

hero(episode: Episode): Character

Episode would be an input and Character an output type.

They belong to different hierarchies because they have to obey different rules
namely, input types can not be infinitely recursive, can not implement interfaces and can not be unions
GraphQLInputType is the supertype of all input types, of which GraphQLInputObjectType is just one, there are input types that are not objects, like scalars (strings, ints etc) and enums
scalars are input and output types at the same time, enums too
If you for example have a mutation that takes an object representing a user and returns an object representing a user, those two would have to be 2 distinct types, e.g. UserInput and User, where UserInput would be a GraphQLInputObjectType and User would be a GraphQLObjectType
Bojan Tomić
@kaqqao
Jun 30 2017 20:04
@javeria2 Did that help?
Sanchay Javeria
@javeria2
Jun 30 2017 20:04
thanks for clarifying a trivial doubt :thumbsup:
do scalars also inherit from GraphQLInputType?
Bojan Tomić
@kaqqao
Jun 30 2017 20:04
yup
Sanchay Javeria
@javeria2
Jun 30 2017 20:05
Perfect, thanks a lot!
Bojan Tomić
@kaqqao
Jun 30 2017 20:05
no worries