Skip to content

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

Closed

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions