Skip to content

No error thrown when query value first exceeds max query amount #3012

@hsdonkin

Description

@hsdonkin

Description

When a query is made exceeding the max query amount, no error is thrown to indicate that the value of first exceeds the amount. Instead, the query succeeds, but returns only the max query amount.

We expected some type of error, since the max query amount is not visible for a user of the API.

https://www.wpgraphql.com/filters/graphql_connection_max_query_amount

Steps to reproduce

Reproducible in repl:

{
  posts(first:10000000){
    nodes {
      id
    }
  }
}
{
  "data": {
    "posts": {
      "nodes": [
        {
          "id": "cG9zdDox"
        }
      ]
    }
  },
  "extensions": {
    "debug": [
      {
        "type": "DEBUG_LOGS_INACTIVE",
        "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled."
      }
    ]
  }
}

Additional context

This could be part of a larger conversation around query costs, which is how Shopify handles this issue with their GraphQL API.

https://shopify.engineering/rate-limiting-graphql-apis-calculating-query-complexity

{
  "errors": [
    {
      "message": "Query cost is 2002, which exceeds the single query max cost limit (1000).\n\nSee https://shopify.dev/concepts/about-apis/rate-limits for more information on how the\ncost of a query is calculated.\n\nTo query larger amounts of data with fewer limits, bulk operations should be used instead.\nSee https://shopify.dev/api/usage/bulk-operations/queries for usage details.\n",
      "extensions": {
        "code": "MAX_COST_EXCEEDED",
        "cost": 2002,
        "maxCost": 1000,
        "documentation": "https://shopify.dev/api/usage/rate-limits"
      }
    }
  ]
}

WPGraphQL Version

1.19.0

WordPress Version

N/A

PHP Version

N/A

Additional environment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: discussionRequires a discussion to proceedneeds: reviewer responseThis needs the attention of a codeowner or maintainertype: enhancementImprovements to existing functionality

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions