Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@Samjin
Copy link

@Samjin Samjin commented Jan 10, 2026

Problem

ExecutableNormalizedField.forEachFieldDefinition() and getOneFieldDefinition() call type.getField(fieldName) directly, bypassing the schema's configured GraphqlFieldVisibility.

This is inconsistent with other parts of graphql-java (validation, execution) that respect field visibility, and causes issues when:

  • A custom GraphqlFieldVisibility provides field definitions that differ from what's in the schema type (e.g., placeholder fields, virtual fields, or dynamically-computed fields)
  • Application code accesses DataFetchingEnvironment.getSelectionSet().getFields() in a DataFetcher
  • Normalization fails with "No field X found for type Y" because it bypasses the visibility

Reproduction

  1. Configure a custom GraphqlFieldVisibility that provides virtual/placeholder fields
  2. Execute a query that includes a field only available through the visibility
  3. Access DataFetchingEnvironment.getSelectionSet().getFields() in a DataFetcher
  4. Normalization fails because ExecutableNormalizedField.forEachFieldDefinition() calls type.getField() directly

Solution

Change the field lookup to use the schema's field visibility:

// Before
type.getField(fieldName)

// After  
schema.getCodeRegistry().getFieldVisibility().getFieldDefinition(type, fieldName)

Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this

@bbakerman bbakerman added this to the 26.x breaking changes milestone Jan 27, 2026
Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@bbakerman bbakerman merged commit 9f18071 into graphql-java:master Jan 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants