Skip to content

MaxPageSize is not applied to PageConnection (Relative Cursor Paging) #8943

@tomasjancicka

Description

@tomasjancicka

Product

Hot Chocolate

Version

15.1.11

Link to minimal reproduction

https://github.com/tomasjancicka/HotChocolate-RelativeCursors-bug

Steps to reproduce

  1. Configure global paging options:
builder.Services
    .AddGraphQLServer()
    .ModifyPagingOptions(opt =>
    {
        opt.MaxPageSize = 5;
    });
  1. Configure per case options: [UseConnection(MaxPageSize = 3)]
  2. Execute a query with first: 10
query {
 testGlobalPagingOptions(first: 10, after: null, last: null, before: null) {
   edges {
     cursor
     node {
       id
       timestamp
       value
     }
   }
   pageInfo {
     endCursor
     hasNextPage
     hasPreviousPage
     startCursor
   }
 }
}
  1. Execute a second query with first: 5
query {
  testPerCasePagingOptions(first: 5, after: null, last: null, before: null) {
    edges {
      cursor
      node {
        id
        timestamp
        value
      }
    }
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }
  }
}

What is expected?

MaxPageSize (global or per case) should limit the number of items returned for PageConnection.
Expected response should be similar to this:

{
  "errors": [
    {
      "message": "The maximum allowed items per page were exceeded.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "testGlobalPagingOptions"
      ],
      "extensions": {
        "code": "HC0051",
        "fieldCoordinate": "Query.testGlobalPagingOptions",
        "requestedItems": 10,
        "maxAllowedItems": 5
      }
    }
  ],
  "data": {
    "testGlobalPagingOptions": null
  }
}

What is actually happening?

MaxPageSize option is ignored for PageConnection for both global configuration by .ModifyPagingOptions(...) and per case configuration[UseConnection(MaxPageSize = 3)]. The response contains the request number of items even though it exceeds the set limit.

Relevant log output

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions