Skip to content

fieldPath is always empty string on relay_field_payload.error #4970

Open

Description

@tobias-tengler

I was playing around with the relayFieldLogger to customize the errors being thrown for certain events when I noticed that the fieldPath on the relay_field_payload.error event seems to always be an empty string.

This is the query I executed:

const data = useLazyLoadQuery<AppQuery>(
  graphql`
    query AppQuery @throwOnFieldError {
      company {
        name
      }
    }
  `,
  {}
);

This is the response returned by the network:

{
  "errors": [
    {
      "message": "Something happened",
      "path": ["company", "name"],
      "extensions": { "code": "E1" }
    }
  ],
  "data": { "company": { "name": null } }
}

This is the event passed to the relayFieldLogger:

{
  "kind": "relay_field_payload.error",
  "owner": "AppQuery",
  "fieldPath": "",
  "error": {
    "message": "Something happened",
    "extensions": {
      "code": "E1"
    }
  },
  "shouldThrow": true,
  "handled": false
}

My expectation would've been for the fieldPath to be 'company.name'. Is the current behavior expected or a bug?

Activity

  1. itamark commented on Apr 24, 2025

    @itamark
    Contributor

    Hey @tobias-tengler, thanks for the feedback! This is a known problem. However, I believe it's been like this the whole time. So it's not a regression, but also it's not correct. I would also expect the path to be populated here.

    This is something I intend to fix - unless it gets fixed by a contributor before I get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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