apollographql / federation

🌐  Build and scale a single data graph across multiple services with Apollo's federation gateway.
https://apollographql.com/docs/federation/
Other
666 stars 253 forks source link

Composition Failure due to INCONSISTENT_INPUT_OBJECT_FIELD lists unrelated subgraphs in message #2787

Open dusty2020 opened 1 year ago

dusty2020 commented 1 year ago

Issue Description

If I have subgraphs defined as follows:

[
        {
            "name": "cat",
            "sdl": "extend schema @link(url: \"https://specs.apollo.dev/link/v1.0\") @link(url: \"https://specs.apollo.dev/federation/v2.0\") input FoodInput { scoopsDryFood: Int, scoopsWetFood: Int }"
        },
        {
            "name": "dog",
            "sdl": "extend schema @link(url: \"https://specs.apollo.dev/link/v1.0\") @link(url: \"https://specs.apollo.dev/federation/v2.0\") input FoodInput { scoopsDryFood: Int }"
        },
        {
            "name": "racoon",
            "sdl": "type Query { eat: String }"
        },
        {
            "name": "chicken",
            "sdl": "type Chicken { name: String }"
        },
        {
            "name": "cow",
            "sdl": "extend schema @link(url: \"https://specs.apollo.dev/link/v1.0\") @link(url: \"https://specs.apollo.dev/federation/v2.0\") type Cow { name: String }"
        }
    ]

composition fails with message:

[INCONSISTENT_INPUT_OBJECT_FIELD]: Input object field "scoopsWetFood" will not be added to "FoodInput" in the supergraph as it does not appear in all subgraphs: it is defined in subgraph "cat" but not in subgraphs "chicken", "cow", "dog" and "racoon".

The message lists all subgraphs, even those without the type FoodInput so it makes it hard to know which subgraphs I need to look into. I would expect the message to be:

[INCONSISTENT_INPUT_OBJECT_FIELD]: Input object field "scoopsWetFood" will not be added to "FoodInput" in the supergraph as it does not appear in all subgraphs: it is defined in subgraph "cat" but not in subgraphs "dog".

Link to Reproduction

https://github.com/dusty2020/rover-testing

Reproduction Steps

git clone https://github.com/dusty2020/rover-testing.git
cd rover-testing
rover supergraph compose --config supergraph.json > supergraph.graphql
shifragoldstone commented 9 months ago

Experiencing the same issue. The message is confusing.

lorf commented 7 months ago

Same here with federation v2.7.2 and rover v0.23.0