Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ra-data-graphql: error thrown by GraphQL client not caught so data provider does not return rejected promise #5906

Closed
bayareacoder opened this issue Feb 12, 2021 · 0 comments

Comments

@bayareacoder
Copy link

bayareacoder commented Feb 12, 2021

What you were expecting:

  • when GQL client throws , the function const raDataProvider = (raFetchType, resource, params) => { ...} in index.js should return a rejected promise, per data provider requirements in react-admin.

What happened instead:
While a

catch (e) {
      return Promise.reject(e);
    }

was added, this code is never reached since the promise chain already returned earlier, so the error is not caught, eg:

          return client
            .query(apolloQuery)
            .then((response) => parseResponse(response))

Solution is to add to each promise chain individually:

.catch((e) => Promise.reject(new HttpError(e.message, 200))

to ensure a rejected promise is returned with an error object with the required syntax.

This was seen together with #5907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants