Skip to content

logUnsafeErrors() logs way too much data #1295

Open
@mbomb007

Description

@mbomb007

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

      \Drupal::logger('graphql')->error(
        "There were errors during a GraphQL execution.\nOperation details:\n<pre>\n{details}\n</pre>\nPrevious errors:\n<pre>\n{previous}\n</pre>",
        [
          '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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions