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

Composition error with @interfaceObject #80

Closed
zoontek opened this issue Jan 30, 2025 · 1 comment · Fixed by #82
Closed

Composition error with @interfaceObject #80

zoontek opened this issue Jan 30, 2025 · 1 comment · Fixed by #82
Assignees

Comments

@zoontek
Copy link

zoontek commented Jan 30, 2025

Hi folks! 👋

We are currently trying to migrate from Apollo GraphOS to Hive and it works mostly great, except for one thing: we use @interfaceObject in one place, and it doesn't appear to compose.

If we follow the Apollo example here and use those schemas:

# a.gql

directive @interfaceObject on OBJECT

extend schema
  @link(
    url: "https://specs.apollo.dev/federation/v2.6"
    import: ["@key", "@interfaceObject"]
  )

interface Media @key(fields: "id") {
  id: ID!
  title: String!
}

type Book implements Media @key(fields: "id") {
  id: ID!
  title: String!
}
# b.gql

directive @interfaceObject on OBJECT

extend schema
  @link(
    url: "https://specs.apollo.dev/federation/v2.6"
    import: ["@key", "@interfaceObject"]
  )

type Media @key(fields: "id") @interfaceObject {
  id: ID!
  reviews: [Review!]!
}

type Review {
  score: Int!
}

type Query {
  topRatedMedia: [Media!]!
}

They will not compose ❌:

[
  GraphQLError: The following supergraph API query:
  {
    topRatedMedia {
      ... on Book {
        reviews {
          ...
        }
      }
    }
  }
  cannot be satisfied by the subgraphs because:
  - from subgraph "a": cannot find field "Book.reviews".
      at check (file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/supergraph/validation/rules/satisfiablity-rule.js:56:33)
      at file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/supergraph/validation/rules/satisfiablity-rule.js:83:62
      at Set.forEach (<anonymous>)
      at Object.InterfaceTypeField (file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/supergraph/validation/rules/satisfiablity-rule.js:83:42)
      at file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/supergraph/composition/visitor.js:53:29
      at Map.forEach (<anonymous>)
      at visitSupergraphState (file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/supergraph/composition/visitor.js:44:36)
      at validateSupergraph (file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/supergraph/validation/validate-supergraph.js:74:5)
      at validate (file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/validate.js:118:30)
      at composeServices (file:///Users/zoontek/Projects/swan/interface-object-issue/node_modules/@theguild/federation-composition/esm/compose.js:13:30) {
    path: undefined,
    locations: undefined,
    extensions: { code: 'SATISFIABILITY_ERROR' }
  }
]

👉 If you want to reproduce the error quickly, clone this repository

@kamilkisiela
Copy link
Contributor

@zoontek It's now live on app.graphql-hive.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
2 participants