Skip to content

Cascade removal of elements referencing emptied types in FieldVisibilitySchemaTransformation - #4570

Open
mohit32886 wants to merge 1 commit into
graphql-java:masterfrom
mohit32886:fix/4569-field-visibility-empty-types
Open

mohit32886 wants to merge 1 commit into
graphql-java:masterfrom
mohit32886:fix/4569-field-visibility-empty-types

Conversation

@mohit32886

Copy link
Copy Markdown

Summary

Fixes #4569

Previously, when VisibleFieldPredicate hid all fields of an object, interface, or input object type, FieldVisibilitySchemaTransformation deleted the emptied type without removing the schema elements that still referenced it (fields, input fields, arguments, union members, or interface implementations). During SchemaTransformer zip-up (or subsequent type reference resolution), this resulted in internal AssertException failures such as type can't be null or A Union type must define one or more member types..

Changes

  • Added a fixpoint DeletionPlan computation in FieldVisibilitySchemaTransformation that:
    • Evaluates field and input-field visibility predicates once upfront.
    • Iteratively marks emptied object, interface, input object, and union types (when all fields or all union members are removed) while keeping the root Query type so an emptied Query fails cleanly with InvalidSchemaException.
    • Cascades deletion to fields and input fields whose unwrapped type is marked for deletion.
  • Updated ElementRemovalVisitor to:
    • Delete arguments and applied directive arguments whose unwrapped type is in typesToDelete.
    • Remove deleted members from surviving GraphQLUnionTypes and deleted interfaces from GraphQLImplementingTypes (including when referenced via GraphQLTypeReference).
  • Added Spock tests in FieldVisibilitySchemaTransformationTest covering nullable/non-null/list fields, arguments, input fields, interfaces, unions (partial and full member removal), directive arguments, multi-hop cascades, GraphQLTypeReference schemas, and emptied root types.

Verification

  • Ran ./gradlew check — all 6,213 tests and verification checks (compileShadedJarConsumer, verifyOsgiManifest, verifyShadedClassAnnotations, archunit) passed.

…itySchemaTransformation

Compute a fixpoint deletion plan before transforming the schema so that when all fields of a type (or all members of a union) are hidden, referencing fields, input fields, arguments, applied directive arguments, and interface implementations are also cleanly removed instead of throwing AssertException.

Fixes graphql-java#4569

This branch has not been deployed

No deployments
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.

FieldVisibilitySchemaTransformation throws exception when referencing a type whose fields are all hidden

1 participant