Add support for extensions
See original GitHub issueIs your feature request related to a problem? Please describe.
Type extensions are part of the specification, and should therefore be supported. Type extensions, according to the linked spec, can be of the following types:
- ScalarTypeExtension (
extend scalar X
) - ObjectTypeExtension (
extend type X
) - InterfaceTypeExtension (
extend interface X
) - UnionTypeExtension (
extend union X
) - EnumTypeExtension (
extend enum X
) - InputObjectTypeExtension (
extend input X
)
Describe the solution you’d like
When defining type extensions in the SDL schema, they should be taken into account and “merged” with the extended type so that the code generation matches the actual schema.
We could (should?) also provide an option (generateExtensionFieldsResolvers
?) to consider all fields from Object Type Extensions as fields with resolvers, because it is likely that these fields require a special resolver implementation with a service call. (Should it be true by default? Maybe not.)
If we do this, maybe we should add a new option to do the opposite of fieldsWithResolvers
, like fieldsWithoutResolvers
, blacklisting some fields so that they are part of the generated POJO instead of being generated as part of the resolver interface.
The reason why I think we should do this is because if the user decides to generate resolvers for most fields that are part of extensions, but not all, it would be painful to list all of them in fieldsWithResolvers
. Instead, we should allow declaring generateExtensionFieldsResolvers
to handle the general case, and add some exceptions via fieldsWithoutResolvers
.
Describe alternatives you’ve considered
The alternative (current situation) is to force the user to declare all their types in the same schema, which is not ideal and sometimes impossible (in case of remote schema using federation).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:12 (8 by maintainers)
Top GitHub Comments
Thanks for your feature request. Current implementation of the library is not supporting extensions. I will work on this soon.
I ran into the same issue today when I wanted to extend an enum type. So when implementing this, it would be super nice if all type extensions would be supported.
extend scalar X
extend type X
extend interface X
extend union X
extend enum X
extend input X
I just wanted to mention this since the issue description suggests that there is only
extend type X
.