Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link

Description

@tomasjancicka
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.