Repository navigation
Conversation
f3483a8 to
a54352c
Compare
There was a problem hiding this comment.
🟡 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
a54352c to
09dbb72
Compare
09dbb72 to
9621dec
Compare
| if ($this->config->getGraphQLOverHttp()) { | ||
| throw new HttpRequestError('GraphQL-over-HTTP requests must contain one operation, not a batch', 422); | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
9621dec to
adddad3
Compare
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.
adddad3 to
335f83c
Compare


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
queryBatchingoption 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 return200 application/jsonwith one result per operation in request order, including individual GraphQL errors.Form encodings, raw
application/graphqlbodies, and legacy persisted-query aliases remain in legacy mode. Applications supplying pre-parsedOperationParamsstill own parameter validation. Hosting applications remain responsible for authentication, authorization, CORS, CSRF protection, and resource limits.Stack: #2007 → #2008 → #2009 → #2010.
Changelog