Skip to content

Dynamic Schema doesn't support interfaces on subtypes #1692

@jeffutter

Description

@jeffutter

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:

pub(crate) fn is_subtype(&self, sub: &TypeRef) -> bool {
doesn't seem to recognize this.

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 TypeRefs at this point and don't know what types have been registered or their interface/implementer relationship.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions