Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FederatedSchemaValidator rejects nested union type field set #1939

Open
pdambrauskas opened this issue Mar 13, 2024 · 1 comment
Open

FederatedSchemaValidator rejects nested union type field set #1939

pdambrauskas opened this issue Mar 13, 2024 · 1 comment
Labels
type: bug Something isn't working

Comments

@pdambrauskas
Copy link
Contributor

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:

@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?

Apollo mentions similar usage pattern on Provides directive documentation: https://www.apollographql.com/docs/federation/federated-types/federated-directives/#fields-1

@pdambrauskas pdambrauskas added the type: bug Something isn't working label Mar 13, 2024
@dariuszkuc
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

No branches or pull requests

2 participants