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

[federation] support new @interfaceObject directive #73

Closed
dariuszkuc opened this issue Feb 17, 2023 · 1 comment · Fixed by #96
Closed

[federation] support new @interfaceObject directive #73

dariuszkuc opened this issue Feb 17, 2023 · 1 comment · Fixed by #96
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@dariuszkuc
Copy link

Apollo Federation v2.3 introduced new @interfaceObject directive that allows users to extend entity functionality through inheritance, i.e. given subgraph A

interface Product {
 id: ID!
 title: String
}

# Book entity with key
type Book implements Product @key(fields: "id") {
 id: ID!
 title: String
 pages: Int
}

# Movie entity with key
type Movie implements Product @key(fields: "id") {
 id: ID!
 title: String
 duration: Int
}

We can generically extend the Product interface in other subgraphs by treating it as local object type with @interfaceObject directive. This new directive informs composition logic that it is actually an entity interface. This allows us to add new functionality in subgraph B without knowing any existing implementation details (i.e. without knowing anything about Book and Movie types).

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

type Review {
 author: String
 text: String
 rating: Int
}

Additional resources:


New directive functionality can be tested using Apollo Federation Subgraph Compatibility NPX script (and Github Action). Example integration project is already provided in the subgraph compatibility testing repository.

@dariuszkuc
Copy link
Author

@kzlsakal kzlsakal added the enhancement New feature or request label Feb 22, 2023
@kzlsakal kzlsakal added the help wanted Extra attention is needed label Feb 6, 2024
@kzlsakal kzlsakal linked a pull request Apr 23, 2024 that will close this issue
@kzlsakal kzlsakal added this to the v1.0 milestone Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants