graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

handle nil values for error paths

Open erikdstock opened this issue 6 years ago • 6 comments

This relates to #146, specifically the point raised by a commenter at the end of the thread.

Perhaps there's a cleaner way to do this, but we have a case where the below response causes fails on GraphQL::Client::Errors.normalize_error_paths due to error["path"] being the value nil. I copied an existing test assertion and (rather than a simple error["path"] || [])actually deleted the nil path key from the error object to match the behavior of other examples.

Interested in your thoughts- thanks.

Snippet of the offending graphql response:

{
  "errors": [
    {
      "message": "Response not successful: Received status code 401",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": null,
      "stack": null
    }
  ],

erikdstock avatar Aug 09 '18 23:08 erikdstock

Following the thread in the hidden comment above I've updated this to explicitly set empty/nil error['path']s to [], which changes the tests a little bit but seems safer than continuing to pass a path: nil around the rest of the request cycle. Still open to changes.

erikdstock avatar Aug 10 '18 17:08 erikdstock

Are there any plans for when this PR will be merged? I'm facing a similar issue and was forced to fork this gem locally to add in this fix. It would be great to see it in an official release soon.

dhudec avatar Nov 02 '18 03:11 dhudec

Poke, we'd love to ge this upstream

orta avatar Mar 14 '19 14:03 orta

+1 for this. just had to patch this in to my graphql-client gem to see an "internal server error" that was being obscured by this bug

jmondo avatar Mar 22 '19 19:03 jmondo

:wave: Hello! I don't believe my team is using this fork anymore. If this PR is not going to be merged could we please close it?

erikdstock avatar Jun 06 '19 18:06 erikdstock

This is still an issue with appsync btw. Is there any plans to resolve? Thanks.

jaeming avatar Oct 28 '21 15:10 jaeming