Skip to content

Make GraphQL depth and complexity limits configurable and add rejection tests #44

Description

@priscaenoch

Problem

src/graphql/plugins.ts wires depthLimit(MAX_DEPTH) and a query-complexity plugin into the GraphQL server (src/graphql/index.ts), which is good, but MAX_DEPTH and the complexity ceiling are hardcoded constants and there are no tests proving that oversized queries are actually rejected. These limits are the primary defense against expensive/abusive GraphQL queries, so they need to be tunable per environment and verified.

What needs to be done

  • Read the depth limit and complexity ceiling from environment variables with the current values as defaults.
  • Document the variables in .env.example and the README.
  • Add tests that submit a query exceeding the depth limit and one exceeding the complexity limit and assert both are rejected with a clear error.
  • Add a test that a normal query within limits succeeds.

Files

  • src/graphql/plugins.ts, src/graphql/index.ts
  • .env.example, README.md

Acceptance deliverables

  • Depth and complexity limits are configurable via env with safe defaults.
  • Oversized queries are provably rejected.
  • All CI checks pass; the change cannot be merged until CI is green.

Tests to pass

  • Test: a query deeper than the limit is rejected.
  • Test: a query above the complexity ceiling is rejected.
  • Test: a valid query within limits succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions