Skip to content

Commit 2ffd2e3

Browse files
committed
Documentation: Add debug flags to example GraphQL server
Should not be used in production environments, but great for debugging while developing.
1 parent dd5ce0a commit 2ffd2e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/getting_started.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ For a quick start, here’s an example of a **GraphQL server in Symfony**.
5757
*This example omits error handling for simplicity.*
5858

5959
```php
60+
use GraphQL\Error\DebugFlag;
6061
use GraphQL\Server\StandardServer;
6162
use GraphQL\Server\ServerConfig;
6263
use Jerowork\GraphqlAttributeSchema\ParserFactory;
@@ -100,11 +101,11 @@ final readonly class GraphQLServerController
100101

101102
// 4. Handle batch requests
102103
if (is_array($result)) {
103-
return new JsonResponse(array_map(fn($res) => $res->toArray(), $result));
104+
return new JsonResponse(array_map(fn($res) => $res->toArray(DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE), $result));
104105
}
105106

106107
// 5. Return response
107-
return new JsonResponse($result->toArray());
108+
return new JsonResponse($result->toArray(DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE));
108109
}
109110
}
110111
```

0 commit comments

Comments
 (0)