question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] @pankod/refine-nhost is not handling graphQL error responses

See original GitHub issue

Describe the bug The @nhost/nhost-js does not throw errors for graphQL errors, instead it returns error field in the return value. Callers are expected to check for the error field in the return values and act appropriately.

https://github.com/nhost/nhost/blob/19ccc5ab0d69ba516305548678e09807809845c3/packages/nhost-js/src/clients/graphql.ts#L55-L60

However, The refine-nhost is not considering this situation and is not handling the error return values. https://github.com/pankod/refine/blob/38278e6b61af8c4cbf90d61e790bd619825fead5/packages/nhost/src/index.ts#L203-L204

This is leading to situation where the error message is eaten away by the refine-nhost and no way for the app or caller to know about the graphQL error responses. App gets a “success” notification, but the backend does not have the data and no way to know about it (since console log also does not show any errors).

To Reproduce Use refine-nhost to make a graphQL query that returns errors (such as permission error) etc.

Expected behavior Error message should be thrown or notification should be displayed

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
KrishnaPGcommented, May 12, 2022

Thank you @omeraplak

The problem is retryer is retrying even when status code is 200 (because the handleError is rejecting the promise).

Is there anyway this { retry: false } can be set specifically for all these graphQL requests in the data provider?

https://github.com/pankod/refine/blob/daa900ddf7272d4a7c6bd515b9179a0b8c747d67/packages/nhost/src/index.ts#L137-L140

Is there any additional parameter or something that can be passed here that will tell the retryer not to retry this?

Doing it here will fix all the cases instead of doing one by one for each of useList, useCreate, useTable, useForm etc.,

Also, I do not want to turn off the retries globally. Only when the status code is 200, do not retry.

1reaction
KrishnaPGcommented, May 12, 2022

Thank you @omeraplak

Not sure about the example or checkError.

I tested the "@pankod/refine-nhost": "^3.18.1" (the latest release you indicated above) and the handleError is the one I am seeing in the code as the new fix that has the promise.reject (which is causing the screenshot shown earlier above)

https://github.com/pankod/refine/blob/daa900ddf7272d4a7c6bd515b9179a0b8c747d67/packages/nhost/src/index.ts#L110-L120

My test repo https://github.com/KrishnaPG/refine-nhost-test illustrates this problem with this new fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling - Apollo GraphQL Docs
When Apollo Server formats an error in a response, it sets the code extension to this value if no other code is set....
Read more >
Top GraphQL Errors and How to fix them
Error handling in GraphQL is different on both server and client side tooling. You no longer are looking at HTTP status codes to...
Read more >
Handling GraphQL errors like a champ with unions and ...
Error handling can be frustrating in GraphQL. This post shows you how to use unions and interfaces to handle errors in a more...
Read more >
Wrong error code thrown for GraphQL validation failures in ...
If an argument passed as a non-null query variable fails to validate, the server response has the code INTERNAL_SERVER_ERROR .
Read more >
Error Handling - GraphQL .NET
Note that by default, messages from unhandled processing errors are masked and ... These types of errors are most likely to be bugs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found