Skip to content

Commit

Permalink
fix psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Meyer authored and Dominik Meyer committed Mar 19, 2023
1 parent 310c17b commit 69bbc27
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
"psr/http-message": "^1",
"react/http": "^1.6",
"react/promise": "^2.9",
"amphp/http-server": "^2.1",
"rector/rector": "^0.15.18",
"symfony/polyfill-php81": "^1.23",
"symfony/var-exporter": "^5 || ^6",
"thecodingmachine/safe": "^1.3 || ^2"
},
"suggest": {
"psr/http-message": "To use standard GraphQL server",
"react/promise": "To leverage async resolving on React PHP platform"
"react/promise": "To leverage async resolving on React PHP platform",
"amphp/http-server": "To leverage async resolving with webserver on AMPHP platform"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 7 additions & 1 deletion examples/04-async-php/amphp/event-loop/graphql.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
$schema = require_once __DIR__ . '/../schema.php';

Loop::run(function () use ($schema): void {
$input = json_decode(file_get_contents('php://input'), true);
$content = file_get_contents('php://input');
$input = '';

if ($content !== false) {
$input = json_decode($content, true);
}

$promise = GraphQL::promiseToExecute(
new AmpPromiseAdapter(),
$schema,
Expand Down
12 changes: 6 additions & 6 deletions examples/04-async-php/amphp/http-server/graphql.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
$query = $input['query'];
$variableValues = $input['variables'] ?? null;
$promise = GraphQL::promiseToExecute(new AmpPromiseAdapter(), $schema, $query, [], null, $variableValues);
$promise = $promise->then(fn(ExecutionResult $result): Response =>
new Response(
$promise = $promise->then(function(ExecutionResult $result): Response {
$data = json_encode($result->toArray());
return new Response(
200,
['Content-Type' => 'application/json'],
json_encode($result->toArray())
)
);

$data !== false ? $data : null
);
});
return $promise->adoptedPromise;
}), new Psr\Log\NullLogger);

Expand Down

0 comments on commit 69bbc27

Please sign in to comment.