Skip to content

Reject enum values, interface fields and union members that a type declares twice in 15.0.0 #863

Open

Description

@oryan-block

Since #855, extensions are merged into the type they extend. When a type ends up declaring an enum value, interface field or union member twice, e.g. in the type and again in an extension, tools keeps the first one and logs a warning:

enum Color { RED }
extend enum Color { RED GREEN }

Type 'Color' declares value 'RED' more than once, only the first one is kept.

graphql-java's SchemaGenerator rejects these schemas, and the spec doesn't allow an extension to redeclare what the type already has. But they built before #855, since the extension used to replace the type, so failing on them has to wait for a major release.

Keeping the first one hides mistakes though. interface Node { id: ID } plus extend interface Node { id: String } builds with id: ID, and only a log line says the extension's id was dropped.

What to change

  • replace the warning in SchemaParser#warnRepeated with a SchemaError that names the type and the repeated value, field or member
  • drop the distinctBy { it.name } on the enum values in createEnumObject and the interface fields in createInterfaceObject
  • move the repeats out of TypeExtensionTest.repeats and extensions without a type keep building into a test for the error
  • mention it in the 15.0.0 release notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions