Skip to content

Make PageCursor types shareable for ApolloFederation #9851

Description

@nathan-turnis

Product

Hot Chocolate

Version

16.1.2

Link to minimal reproduction

protected override void Configure(IObjectTypeDescriptor<PageCursor> descriptor)

Steps to reproduce

  1. Set up GraphQL with .AddApolloFederation():
builder.Services.AddGraphQLServer()
.AddApolloFederation()
.AddTypes()
.AddFiltering()
.AddSorting()
.AddPagingArguments();
  1. Create query with paging
[QueryType]
public static partial class EmployeeResolver
{
      [UseConnection]
      public static async Task<PageConnection<Employee>> GetEmployeeByPageTest(AppDbContext db, QueryContext<Employee> query, PagingArguments args)
      {
          return await db.Employees.With(query).ToPageAsync(args);
      }
}
  1. Run multiple Subgraphs like this on an Supergraph using ApolloFederation

You get this error:

error[E029]: Encountered 2 build errors while trying to build a supergraph.

Caused by:
    INVALID_FIELD_SHARING: Non-shareable field "PageCursor.page" is resolved from multiple subgraphs: it is resolved from subgraphs "x" and "y" and defined as non-shareable in all of them
    INVALID_FIELD_SHARING: Non-shareable field "PageCursor.cursor" is resolved from multiple subgraphs: it is resolved from subgraphs "x" and "y" and defined as non-shareable in all of them

It seems like this was partially solved once before:
Issue: #7292
Pull Request: #7480

What is expected?

Supergraph compiles and runs without any additional configuration as seen here

What is actually happening?

Supergraph fails to compile due to non-shareable fields.

Relevant log output

error[E029]: Encountered 2 build errors while trying to build a supergraph.

Caused by:
    INVALID_FIELD_SHARING: Non-shareable field "PageCursor.page" is resolved from multiple subgraphs: it is resolved from subgraphs "x" and "y" and defined as non-shareable in all of them
    INVALID_FIELD_SHARING: Non-shareable field "PageCursor.cursor" is resolved from multiple subgraphs: it is resolved from subgraphs "x" and "y" and defined as non-shareable in all of them

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions