-
-
Notifications
You must be signed in to change notification settings - Fork 500
Description
I believe I'm running into an issue where I can't have fields on implementers of interfaces, have fields with different implementations that also implement a common interface.
For example, I'm trying to create a schema like this:
schema @link(
url: "https://specs.apollo.dev/federation/v2.7",
import: ["@key", "@interfaceObject", "@shareable", "@inaccessible"]
) {
query: RootQueryType
}
type RootQueryType {
events: [Event]
}
interface Event {
id: ID!
Team: Team
}
type SportsballEvent implements Event {
id: ID!
ballColor: String
Team: SportsballTeam
}
type BasketWeavingEvent implements Event {
id: ID!
basketType: String
Team: BasketWeavingTeam
}
interface Team {
id: ID!
}
type SportsballTeam implements Team {
id: ID!
sportsballPlayers: [String!]!
}
type BasketWeavingTeam implements Team {
id: ID!
basketWeavingPlayers: [String!]!
}
Notably SportsballEvent.Team
and BasketWeavingEvent.Team
are different types (SportsballTeam
and BasketWeavingTeam
respectively) yet implement the common interface defined on the parent of SportsballEvent
and BasketWeavingEvent
- Team
. However, the check for subtypes found here:
async-graphql/src/dynamic/type_ref.rs
Line 121 in 75a9d14
pub(crate) fn is_subtype(&self, sub: &TypeRef) -> bool { |
Expected Behavior
I should be able to create a schema like this
Actual Behavior
Error: Field "SportsballEvent.Team" is not sub-type of "Event.Team"
Other
It looks like that is_subtype
is stripping out null
and list
types around a type and comparing they are the same. I may be unclear on what subtype
means here, but It seems to basically just be checking type equality (maybe stripping out nills
but not checking "inheritance"?
I can potentially look into fixing this. However, I'm just wanted to check if i'm on the correct track here. I suppose it might be tricky since you are only getting the TypeRef
s at this point and don't know what types have been registered or their interface/implementer relationship.