You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I have a union type and want to use it on @requires directive, it fails. When I use:
@RequiresDirective(fields =FieldSet("animal { ... on Dog { breed { name } } }"))
I get something like
com.expediagroup.graphql.generator.federation.exception.InvalidFederatedSchema: Invalid federated schema:
- @requires(fields = "animal { ... on Dog { breed { name } } }") directive on <...redacted...> specifies invalid field set - field set specifies field that does not exist, field=...
- @requires(fields = "animal { ... on Dog { breed { name } } }") directive on <...redacted...> specifies invalid field set - field set specifies field that does not exist, field=on
- @requires(fields = "animal { ... on Dog { breed { name } } }") directive on <...redacted...> specifies invalid field set - field set specifies field that does not exist, field=Dog
However, if I do not add the annotation & just edit federated schema, or remove validations by overriding didGenerateGraphQLType on FederatedSchemaGeneratorHooks. Subgraph is federated and works as expected
Expected behaviour
support for this kind of directives, without validation errors.
Also, would it make sense to make validator: FederatedSchemaValidator injectable on FederatedSchemaGeneratorHooks and open for overrides so that there was an easy way to disable validation in this kind of edge-case scenarios?
Hello 👋
Indeed this is a bug. Current fieldset validation logic is pretty crude and doesn't work with polymorphic types. Technically FieldSet can be any valid selection set so this validation should either be updated or removed altogether to avoid those issues.
Library Version
7.0.2
Describe the bug
When I have a union type and want to use it on
@requires
directive, it fails. When I use:I get something like
However, if I do not add the annotation & just edit federated schema, or remove validations by overriding
didGenerateGraphQLType
onFederatedSchemaGeneratorHooks
. Subgraph is federated and works as expectedExpected behaviour
support for this kind of directives, without validation errors.
Also, would it make sense to make
validator: FederatedSchemaValidator
injectable onFederatedSchemaGeneratorHooks
and open for overrides so that there was an easy way to disable validation in this kind of edge-case scenarios?Apollo mentions similar usage pattern on Provides directive documentation: https://www.apollographql.com/docs/federation/federated-types/federated-directives/#fields-1
The text was updated successfully, but these errors were encountered: