Skip to content

SchemaPrinter doesn't work consistently with OneOf versus Deprecated directives #3357

@arlampin

Description

@arlampin

Describe the bug
Using

SchemaPrinter.ExcludeGraphQLSpecifiedDirectivesPredicate

works differently regarding OneOf and Deprecated directives. With ExcludeGraphQLSpecifiedDirectivesPredicate, both directive definitions are removed from generated file, but with OneOf, also directive's usage is removed from types.

So for example

input SomeType @oneOf {
  field1: String
  field2: Int
}

becomes

input SomeType {
  field1: String
  field2: Int
}

This doesn't happen with Deprecated, they are still present in the schema.

Also I didn't test with other directives.

To Reproduce
OneOf Directive is added with:

newInputObject()
            .withDirective(Directives.OneOfDirective)
            ...

and deprecated with:

newFieldDefinition()
            .deprecate("This field is deprecated")
            ...

SchemaPrinter is used as:

new SchemaPrinter(SchemaPrinter.Options.defaultOptions()
            .includeDirectives(SchemaPrinter.ExcludeGraphQLSpecifiedDirectivesPredicate))

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep-openTells Stale Bot to keep PRs and issues open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions