enisdenjo / graphql-composite

MIT License
5 stars 0 forks source link

Detect unresolvable fields in object types implementing the interface #30

Closed kamilkisiela closed 3 months ago

kamilkisiela commented 3 months ago

We've got a case like this:

A

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

interface Post {
  id: ID!
  createdAt: String!
}

type ImagePost implements Post @key(fields: "id") {
  id: ID!
  createdAt: String!
}

type Query {
  feed: [Post]
}

B

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

interface Post {
  id: ID!
  createdAt: String!
}

type TextPost implements Post @key(fields: "id") {
  id: ID!
  createdAt: String!
  body: String!
}

interface AnotherPost {
  id: ID!
  createdAt: String!
}

type ImagePost implements AnotherPost @key(fields: "id") {
  id: ID!
  createdAt: String! @override(from: "a") # it makes the ImagePost.createdAt in A unresolvable
}

Currently the query planner is not aware of ImagePost.createdAt being not resolvable in subgraph A. It probably only looks at the interface field and its availability in subgraphs.

There's another case but with @external annotation used in place of @override.

Once we push a fix, it should cover both scenarios.