Skip to content

feat(http): validate standard request encoding - #2010

Open
simPod wants to merge 1 commit into
feat/http-status-codesfrom
feat/http-request-validation
Open

simPod wants to merge 1 commit into
feat/http-status-codesfrom
feat/http-request-validation

Conversation

@simPod

@simPod simPod commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

The legacy request parser accepts aliases and parameter shapes that do not match the GraphQL-over-HTTP request format. In the opt-in mode, validate raw JSON POST bodies and GET parameters by their exact names and types. Preserve nested JSON objects, ignore unknown properties, and do not infer legacy persisted-query identifiers.

Keep batching available through the existing queryBatching option so applications can enable GraphQL-over-HTTP without losing it. Accept non-empty JSON POST batches as an extension. Reject the whole batch before execution if any entry has an invalid request shape. Accepted batches return 200 application/json with one result per operation in request order, including individual GraphQL errors.

Form encodings, raw application/graphql bodies, and legacy persisted-query aliases remain in legacy mode. Applications supplying pre-parsed OperationParams still own parameter validation. Hosting applications remain responsible for authentication, authorization, CORS, CSRF protection, and resource limits.

Stack: #2007 → #2008 → #2009 → #2010.

Changelog

  • Add strict GraphQL-over-HTTP request parsing for PHP-global and PSR-7 requests while retaining opt-in query batching.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

PHP query-parameter normalization allows an unknown property to overwrite the executed document in both PSR-7 and globals request paths, requiring name-preserving decoding and regression tests.

1 open issue
What changed in this PR

Adds opt-in strict request parsing to the GraphQL-over-HTTP stack, building on response negotiation and status mapping while preserving legacy-mode behavior.

Changes:

  • Validates GET parameters and raw JSON POST bodies, preserving nested objects and rejecting batches.
  • Integrates strict parsing into PHP-global and PSR-7 request handling, with HTTP-specific errors.
  • Adds parser and integration tests and documents supported behavior and application responsibilities.
File Description
tests/​Server/​HttpServerTest.php Tests raw-body parsing, batch rejection, and request-error responses.
tests/​Server/​HttpRequestParserTest.php Tests strict parameter types, aliases, and object preservation.
src/​Server/​StandardServer.php Routes opt-in requests through strict parsing and rejects pre-parsed batches.
src/​Server/​HttpRequestParser.php Implements method-specific request validation.
src/​Server/​HttpRequestError.php Carries request-error status codes and headers.
src/​Server/​HttpHelper.php Applies parsing-error status codes and headers to responses.
src/​Server/​Helper.php Bypasses legacy parameter validation in opt-in mode.
docs/​executing-queries.md Documents strict parsing, legacy-only features, and integration responsibilities.

Review effort: Balanced

Comment thread src/Server/StandardServer.php Resolved
@simPod
simPod force-pushed the feat/http-request-validation branch from a54352c to 09dbb72 Compare November 14, 2026 21:02
@simPod
simPod requested a balanced review from Copilot November 14, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The parser rejects valid requests by misreading semicolons inside quoted header parameters and treating null GET variables or extensions as invalid rather than omitted.

3 open issues

Review effort: Balanced

Comment thread src/Server/HttpRequestParser.php Resolved
Comment thread src/Server/HttpRequestParser.php Resolved
@simPod
simPod force-pushed the feat/http-request-validation branch from 09dbb72 to 9621dec Compare November 15, 2026 07:54
@simPod
simPod requested a balanced review from Copilot November 15, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the opt-in strict request-parsing changes.

1 open issue
2 resolved since last review

Review effort: Balanced

@simPod
simPod added this pull request to stack #2011 November 15, 2026 08:23
@simPod
simPod marked this pull request as ready for review November 15, 2026 08:31
Comment on lines +137 to +139
if ($this->config->getGraphQLOverHttp()) {
throw new HttpRequestError('GraphQL-over-HTTP requests must contain one operation, not a batch', 422);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a though choice.

I understand the graphql-over-http spec did not come to a conclusion, but outright rejecting it makes incredible hard imho to upgrade graphql-php and switch to it.

Why don't just apply graphql-over-http to the single request and retain batching as extension?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I’ve kept batching as an opt-in extension through the existing queryBatching setting. Each entry follows the same request validation rules as a single request. Accepted batches return 200 application/json with one result per operation in request order, including any individual GraphQL errors.

@simPod
simPod force-pushed the feat/http-request-validation branch from 9621dec to adddad3 Compare November 18, 2026 11:24
@simPod
simPod removed this pull request from stack #2011 November 18, 2026 11:26
@simPod
simPod added this pull request to stack #2016 November 18, 2026 11:27
Validate raw JSON POST bodies and GET parameters when GraphQL-over-HTTP is enabled.
Preserve nested JSON objects and ignore unknown request properties.

Keep query batching available as an opt-in extension. Validate all batch entries
before execution, then return ordered individual results in one JSON response.
Leave single-request and legacy behavior unchanged.
@simPod
simPod force-pushed the feat/http-request-validation branch from adddad3 to 335f83c Compare November 18, 2026 14:11

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants