Parse OperationParams into strongly typed data structures - #1019
Draft
spawnia wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors GraphQL server request/operation handling with the goal of parsing OperationParams into more strongly typed structures and adjusting persisted-query-related behavior, while updating the server test suite accordingly.
Changes:
- Refactors
GraphQL\Server\Helper::promiseToExecuteOperation()to perform parameter validation and persisted query resolution inline. - Introduces new DTO-style classes
GraphQL\Server\ValidOperationandGraphQL\Server\PersistedOperation. - Updates server tests to reflect the new parsing/loader expectations.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Server/RequestValidationTest.php | Switches validation calls to a new parseOperationParams API (currently missing in implementation). |
| tests/Server/QueryExecutionTest.php | Updates one persisted query loader callback to use PersistedOperation. |
| src/Server/ValidOperation.php | Adds a new DTO for “validated” operations. |
| src/Server/PersistedOperation.php | Adds a new DTO for persisted operations. |
| src/Server/Helper.php | Refactors execution-time validation, persisted query loading, and error handling flow. |
Comments suppressed due to low confidence (1)
tests/Server/RequestValidationTest.php:67
- Same issue as above:
Helper::parseOperationParams()does not exist in the current changeset, so this assertion helper will fatal at runtime until the method is implemented or the test is updated to use the correct API.
private function assertInputError($parsedRequest, $expectedMessage): void
{
$helper = new Helper();
$errors = $helper->parseOperationParams($parsedRequest);
if (isset($errors[0])) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| return $promiseAdapter->createFulfilled( | ||
| new ExecutionResult(null, $locatedErrors) | ||
| if ($extensions !== null && (! is_array($extensions) || isset($variables[0]))) { |
Comment on lines
+243
to
+247
| if ($queryId !== null) { | ||
| if (! is_string($queryId)) { | ||
| $errors[] = new RequestError( | ||
| 'GraphQL Request parameter "queryId" must be string, but got ' . | ||
| Utils::printSafeJson($params->queryId) |
Comment on lines
+289
to
+293
| if ($operationAST === null) { | ||
| $errors[] = new RequestError('Failed to determine operation type'); | ||
| } | ||
|
|
||
| $operationType = $operationAST->operation; |
Comment on lines
+302
to
309
| if (count($errors) > 0) { | ||
| return $promiseAdapter->createFulfilled( | ||
| new ExecutionResult( | ||
| null, | ||
| array_map([Error::class, 'createLocatedError'], $errors) | ||
| ) | ||
| ); | ||
| } |
Comment on lines
+208
to
+210
| return $promiseAdapter->createFulfilled( | ||
| new ExecutionResult(null, [Error::createLocatedError($batchedQueriesAreNotSupported)]) | ||
| ); |
Comment on lines
+407
to
+408
| ->setPersistedQueryLoader(static function (PersistedOperation $persistedOperation): string { | ||
| if ($persistedOperation->queryId === 'some-id') { |
Comment on lines
28
to
32
| private static function assertValid($parsedRequest): void | ||
| { | ||
| $helper = new Helper(); | ||
| $errors = $helper->validateOperationParams($parsedRequest); | ||
| $errors = $helper->parseOperationParams($parsedRequest); | ||
| self::assertEmpty($errors, isset($errors[0]) ? $errors[0]->getMessage() : ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.