Repository navigation
Warn about a field that an object or input type declares twice - #920
Merged
Merged
Conversation
The last declaration of a repeated field is kept without a word, whether the repeat is between a type and its extension, between two extensions or inside one definition. Log a WARN that names the type, the field and the kept declaration, like enum values, interface fields and union members already do. 15.0.0 will throw instead.
|
This was referenced Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Refs #865
Checklist
Description
A field that an object or input type declares twice builds without a word today. The repeat can be between a type and its extension, between two extensions or inside one definition. Objects keep the last declaration. Inputs keep the type's own over an extension's, since extensions are applied first, and the last one otherwise. #916 turns this into a
SchemaErrorin 15.0.0, but enum values, interface fields and union members are the only repeats that warn in 14.x. So this logs a WARN for objects and inputs too, to ship in 14.5.0 before the break:It names the declaration the schema keeps instead of saying "the first one", since for objects and inputs it usually isn't. The warning reads the same field list the builder applies, so the two can't disagree. A declaration without a source location, e.g. one from a
TypeDefinitionFactory, gets "only one of them is kept" instead. The location is where the declaration starts, which is its description when it has one, like graphql-java's own locations.Nothing else changes. The same fields are kept, in the same order.
Checked with a new
type-extensions-repeated-fieldsprobe scenario (object and input repeats in all three places) on graphql-java 26.1 and 25.1. This branch logs one WARN per repeat, master logs none, and the printed schema and query results are identical on both. Each type still warns once with a directive wiring registered (the schema gets built twice then), on the query type, on a type used in several places and on an input that's built on demand. With two schema files, the location names the right file.mvn clean verifypasses on the default graphql-java and on-Dgraphql-java.version=25.1, 412 tests each.Release note: a field that an object or input type declares twice, in the type and an extension, in two extensions or inside one definition, now logs a WARN that names the type, the field and the declaration that's kept. This becomes an error in 15.0.0 (#865).