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

INTERFACE_OBJECT_USAGE_ERROR when using @interfaceObject and contributing fields to an implementing type #3185

Open
oskargotte opened this issue Nov 13, 2024 · 0 comments

Comments

@oskargotte
Copy link

Issue Description

I'm trying to compose a supergraph where one of the subgraph is referencing an interface from the other subgraph with the @interfaceObject directive. It is not adding any fields, it just needs to define the type to be able to use it in queries. However, the subgraph also extends one of the implementing types with a field and hence I get the INTERFACE_OBJECT_USAGE_ERROR with the error message
Interface type "Media" is defined as an @interfaceObject in subgraph "b" so that subgraph should not define any of the implementation types of "Media", but it defines type "Movie"

The documentation says that
"If a subgraph contributes entity fields via @interfaceObject, it "gives up" the ability to contribute fields to any individual entity that implements that interface."

But in this case I'm not contributing any fields to the interface via @interfaceObject so I would argue that the compose validation is a bit too restrictive in this case.

The following schemas can be used for reproduction

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

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

type Movie implements Media @key(fields: "id") {
  id: ID!
  title: String!
}
type Media @key(fields: "id", resolvable: false) @interfaceObject {
  id: ID!
}

type Movie @key(fields: "id") {
  id: ID!
  imdbScore: Int!
}

type Query {
  numberOneMedia: Media!
}

Link to Reproduction

https://codesandbox.io/p/devbox/amazing-dirac-mrm9sj

Reproduction Steps

Go to the sandbox and check the terminal output or try to compose the schemas above into a supergraph with rover.

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