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

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (9 by maintainers)

Most upvoted comments

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.

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.

Hey @KrishnaPG 👋, Thank you for contacting us! Great point! It seems our graphql providers are missing error handling. We’ll deal with that this week! 🚀