drupal-graphql / drupal-graphql/graphql

logUnsafeErrors() logs way too much data

Open
#1,295 0 comments 0 reactions 0 assignees View on GitHub
4.x enhancement
Dominant language
PHP
Stars
287
Forks
198
PR merge metrics
No merged PRs in 30d

Description

I have had some trouble trying to view GraphQL errors for some queries I'm using. The relevant section of `Executor::logUnsafeErrors()` is here:

```php
\Drupal::logger('graphql')->error(
"There were errors during a GraphQL execution.\nOperation details:\n

\n{details}\n
\nPrevious errors:\n
\n{previous}\n
",
[
'details' => json_encode([
'$operation' => $operation,
// Do not pass $result to json_encode because it implements
// JsonSerializable and strips some data out during the
// serialization.
'$result->data' => $result->data,
'$result->errors' => $result->errors,
'$result->extensions' => $result->extensions,
], JSON_PRETTY_PRINT),
'previous' => implode('\n\n', $previousErrors),
]
```

`$result->data` contains the entire result set of the query. In my case, my queries are returning a couple hundred objects with lots of data and properties. If a single item causes an error, then the log message still will contain hundreds of items.

Is there a way to have my queries still return the data, yet have the error log messages omit or truncate the data? I had to set my PHP memory_limit higher just to view my site's Recent Log Messages for GraphQL.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.