Skip to content

fix: always create field edges to current graphs field type #151

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

Merged
merged 6 commits into from
Jun 23, 2025

Conversation

n1ru4l
Copy link
Contributor

@n1ru4l n1ru4l commented Jun 17, 2025

No description provided.

Copy link
Contributor

github-actions bot commented Jun 17, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@theguild/federation-composition 0.18.4-alpha-20250620101817-dbe6437bfa41d31146f8d173cab98ac1b009768f npm ↗︎ unpkg ↗︎

@provides(fields: "bbbbbbbbbbbbb { aaaaaaaaaaaa { someField } }")
}

type AAAAAAAAAAAAA @key(fields: "id") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming the type in all subgraphs fixes the issue... So it must be some issue with the order of things...

- AAAAAAAAAAAAA
+ AAAAAAAAAAAA

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, if the field had a shorter name we attempted to create a edge from BBBBBBBBBBBBB.aaaaaaaaaaaa to SomeInterface/b instead of AAAAAAAAAAAAA/. 🤡

The changes in src/supergraph/validation/rules/satisfiablity/graph.ts should ensure we always create the field edges to the subgraph defined field type instead.

@n1ru4l n1ru4l marked this pull request as ready for review June 17, 2025 13:35
@n1ru4l n1ru4l changed the title test: expected abstract indexes to be defined fix: always create field edges to current graphs field type Jun 17, 2025
@n1ru4l n1ru4l requested a review from kamilkisiela June 17, 2025 13:35
type Post @key(fields: "id") {
id: ID!
author: User @provides(fields: "userId")
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1381,7 +1381,10 @@ export class Graph {
}
}

const outputTypeName = stripTypeModifiers(field.type);
// We always want to connect it to the field type within our graph not the field type from another graph/supergraph
const fieldType = field.byGraph.get(this.id)?.type ?? field.type;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@n1ru4l n1ru4l merged commit f9b9908 into main Jun 23, 2025
4 checks passed
@n1ru4l n1ru4l deleted the reproduction-expected-abstract-index branch June 23, 2025 09:09
n1ru4l pushed a commit that referenced this pull request Jun 23, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @theguild/[email protected]

### Patch Changes

-
[#151](#151)
[`f9b9908`](f9b9908)
Thanks [@n1ru4l](https://github.com/n1ru4l)! - Fix issue where the
satisfiability check raised an exception for fields that share different
object type and interface definitions across subgraphs.

-
[#152](#152)
[`e4440a1`](e4440a1)
Thanks [@n1ru4l](https://github.com/n1ru4l)! - Fix issue where scalar
type marked with `@inaccessible` does not fail the composition if all
usages are not marked with `@inaccessible`.

Composing the following subgraphs resulted in an invalid supergraph
instead of failing the composition.

    ```graphql
    # Subgraph A
    extend schema
      @link(
        url: "https://specs.apollo.dev/federation/v2.9"
        import: ["@inaccessible"]
      )

    type Query {
      a: Foo
    }

    scalar Foo
    ```

    ```graphql
    # Subgraph B
    extend schema
      @link(
        url: "https://specs.apollo.dev/federation/v2.9"
        import: ["@inaccessible"]
      )

    type Query {
      b: String
    }

    scalar Foo @inaccessible
    ```

Now it correctly raises a composition error with the message `Type "Foo"
is @inaccessible but is referenced by "Query.a", which is in the API
schema.`.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants