Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow @external partial references without redefining entire type #2990

Open
smyrick opened this issue Apr 26, 2024 · 0 comments
Open

Allow @external partial references without redefining entire type #2990

smyrick opened this issue Apr 26, 2024 · 0 comments

Comments

@smyrick
Copy link
Member

smyrick commented Apr 26, 2024

Today if I need to reference a type because I am using something like @requires, I need to mark the type and field as @external. However if this type also has more fields which I don't reference in my @requires and I do not include them in my separate definition, I get the Federation hint INCONSISTENT_OBJECT_VALUE_TYPE_FIELD.

For example

Subgraph One

extend schema
    @link(
        url: "https://specs.apollo.dev/federation/v2.5",
        import: ["@key", "@requires", "@external", "@shareable"]
    )

type Query {
  locations: [Locations]
}

type Location @key(fields: "id"){
    id: ID!
    name: String!
    description: String!
    foo: Foo
}

type Foo {
    a: String
    b: String
    c: String
}

Subgraph Two

extend schema
    @link(
        url: "https://specs.apollo.dev/federation/v2.5",
        import: ["@key", "@requires", "@external", "@shareable", "@inaccessible"]
    )

type Location @key(fields: "id") {
    id: ID!
    overallRating: Float @requires(fields: "foo { a }")
    foo: Foo @external
}

type Foo {
    a: String @external
}

This composes without errors but I do get a HINT

HINT: [INCONSISTENT_OBJECT_VALUE_TYPE_FIELD]: Field "Foo.b" of non-entity object type "Foo" is defined in some but not all subgraphs that define "Foo": "Foo.b" is defined in subgraph "locations" but not in subgraph "reviews".
HINT: [INCONSISTENT_OBJECT_VALUE_TYPE_FIELD]: Field "Foo.c" of non-entity object type "Foo" is defined in some but not all subgraphs that define "Foo": "Foo.c" is defined in subgraph "locations" but not in subgraph "reviews".

What I would like

In subgraph two (reviews), it would be nice to not have to redefine the entire Foo type when I am only using it for @external references and I only need to reference Foo.a.

If I now update the Foo type to include a new field Foo.d, I have to go to many locations to do that when it is not even used there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant