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

Schema::type_field should work for all variants of ExtendedType #892

Closed
tninesling opened this issue Jul 30, 2024 · 2 comments
Closed

Schema::type_field should work for all variants of ExtendedType #892

tninesling opened this issue Jul 30, 2024 · 2 comments
Labels

Comments

@tninesling
Copy link

Description

When processing operations in the demand control plugin, we traverse the ExecutableDocument and score each field based on its type and directives. Specifically, we check for directives applied to the schema. Since the router's request pipeline parses operations using the API schema instead of the supergraph schema, these directives on FieldDefinitions are stripped.

It has been suggested that we look up the supergraph schema's definitions using Schema::type_field, but this returns a NoSuchField error for scalars, unions, enums, and input objects. Instead, these variants should have the same definition lookup functionality as objects and interfaces.

Proposal

For variants of ExtendedType which do not already have it, add a field definition mapping equivalent to that on objects and interfaces: pub fields: IndexMap<Name, Component<FieldDefinition>>. Then use the new lookups inside Schema::type_field.

@tninesling
Copy link
Author

The lookup failure was caused by user error. This change is no longer required

@SimonSapin
Copy link
Contributor

For anyone finding this later: the type name given to Schema::type_field must be the type of the parent selection set (the type whose definition contains the field definition we want), not the type of the field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants