Skip to content

SchemaUsageReport is not visiting applied directives #3267

Closed
@felipe-gdr

Description

@felipe-gdr

Describe the bug
SchemaUsageReport is not visiting GraphQLAppliedDirectives, this can sometimes result in SchemaUsage giving incorrect information about whether a directive is being referenced.

To Reproduce

  • create a schema that contains a directive definition and a field that uses that directive
  • manipulate the schema, clearing the list of directives from the field, and adding the applied directive back to it.
    For example:
List<GraphQLAppliedDirectives> directives = fieldDef.getAppliedDirectives();
fieldDef.transform(f -> f.clearDirectives().replaceAppliedDirectives(directives))
  • at this point the field should have an empty list of GraphQLDirective, and a list of GraphQLAppliedDirective containing 1 item
  • run the schema through SchemaUsage and check if the directive is being referenced:
schemaUsage.isStronglyReferenced(schema, "directiveName")

expected behaviour: isStronglyReferenced should return true, since the directive is applied to the field
actual behaviour: isStronglyReferenced returns false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions