react-admin: [ra-data-graphql-simple] Http 401 error is not redirecting to login page
What you were expecting:
I expected to be redirected to the login page when the graphql endpoint returns http 401 or 403
What happened instead:
It displays the error message, but continues and tries to parse the null data returned
Steps to reproduce:
- Have the graphql endpoint return 401 for a query, with an error message and null data
Related code:
Other information:
Environment
- React-admin version: “^2.7.3” “ra-data-graphql-simple”: “^2.7.1”,
- React version: “^16.8.4”
- Browser: Google Chrome
- Stack trace (in case of a JS error): Below is what gets printed to console.log
index.js:83 POST http://localhost:3001/graphql 401 (Unauthorized)
index.js:1446 Warning: Missing translation for key: "GraphQL error: LOGIN_USER
GraphQL error: LOGIN_USER
GraphQL error: Non-nullable field was null."
index.js:1446 Warning: Missing translation for key: "GraphQL error: LOGIN_USER
GraphQL error: LOGIN_USER
GraphQL error: Non-nullable field was null."
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (8 by maintainers)
Commits related to this issue
- Fix misleading documentation about auth failure redirection Closes #2983 — committed to marmelab/react-admin by fzaninotto 5 years ago
- Fix misleading documentation about auth failure redirection Closes #2983 — committed to ghodsizadeh/react-admin by fzaninotto 5 years ago
- Fix misleading documentation about auth failure redirection Closes #2983 — committed to ghodsizadeh/react-admin by fzaninotto 5 years ago
I see that however, I have a
nullcheck inrender()checkingthis.state.dataProviderwhich doesn’t get set if Apollo returns an error. My workaround was to return a function that throws an error with the status code since react-admin expects a function for dataProvider.If I remove the null check the app fails since dataProvider is null.