Allow providing additional types to schema build.#33
Conversation
With the current API, only concrete instances which are registered somewhere from the query or mutation root are registered. This makes writting tools to automatically generate types a PITA - specifically because you have to ensure there is at least one concrete instance of every type registered. This change provides a way to pass a set of types into the schema when building it, which will be added into the set of available types when replacing type references. An alternative could be to provide a resolver to GraphQLTypeReference, which would be used to resolve the type at build time - however, this method seems far less intrusive for existing consumers :-)
|
Thanks! Is this PR related to this one https://github.com/andimarek/graphql-java/pull/28 in your opinion? To understand the use-case better: Do I understand this right, that you generate the schema automatically and sometimes you have for example a InterfaceType and a some ObjectTypes implementing this Interface, but nobody is referencing the ObjectType, just the Interface? |
|
It's not directly related to #28. re use case: yes. the one that bit me was using a TypeReference everywhere a given type if mentioned is used (e.g, in parameters or return types), and so when it comes to building the schema, there is no reference to the actual ObjectType instance. |
There was a problem hiding this comment.
I would prefer not to use null ... just a empty set
and then assert that its not null
|
ok ... I understand .... interesting approach to use TypeReference as default. I comment on some minor issues I thought could be improved, but nothing seriously. |
|
pushed and update re null instead of empty set usage! |
Allow providing additional types to schema build.
|
Thanks |
With the current API, only concrete instances which are registered somewhere from the query or mutation root are registered. This makes writting tools to automatically generate types a PITA - specifically because you have to ensure there is at least one concrete instance of every type registered.
This change provides a way to pass a set of types into the schema when building it, which will be added into the set of available types when replacing type references.
An alternative could be to provide a resolver to GraphQLTypeReference, which would be used to resolve the type at build time - however, this method seems far less intrusive for existing consumers :-)