Skip to content

Resolver between schemas fragment not honouring interfaces #1434

@m-sanders

Description

@m-sanders

Hello

I think I might be missing something here but I am seeing some unexpected failures when extending an externally stitched schema and querying on either the interface or concrete type.

A quick example. Say I have the below resolver that adds stock data onto a product:

resolvers: {
  Product: {
    stockRecord: {
      fragment: ` ... on IProduct { id } `,
      resolve(obj, __, ___, info) {
        return info.mergeInfo?.delegateToSchema({
          schema: remote,
          operation: "query",
          fieldName: "stockRecord",
          args: { id: obj.id },
          info,
        });
      },
    },
  }
} 

When a user queries on the IProduct interface it works. However if the user queries on the concrete type Product that implements the IProduct interface, the resolver will not receive the id field. The same is true in reverse, if we were to change the resolver implementation to use the concrete type, the resolver will not receive the id field if the user queries on the interface type.

I have created a full reproduction here as I wasn't sure if it was another part of our application causing the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions