Hasura doesn't show RAISE EXCEPTION message from postgres function
See original GitHub issueIt’s common to make some checks in triggers and RAISE NOTICE
or EXCEPTION
and provided message went to postgres log. Can we somehow provide this message to the client, instead poor Uncaught (in promise) Error: GraphQL error: postgres query error
Issue Analytics
- State:
- Created 4 years ago
- Reactions:37
- Comments:25 (7 by maintainers)
Top Results From Across the Web
Handling GraphQL Errors with Hasura & React
A guide to common GraphQL API & Hasura specific errors and how to handle them with React pages.
Read more >Top GraphQL Errors and How to fix them
Identifying error types will help quickly fix them. Clients can encounter these types of errors while communicating with the GraphQL server.
Read more >Postgres: Data validations | Hasura GraphQL Docs
We can now create a Postgres function that checks if an article's content exceeds a certain ... RAISE EXCEPTION 'Content can not have...
Read more >Postgres: Filter query results / search queries - Hasura
Filter query results and search queries on Postgres in Hasura. ... By design, the _eq or _neq operators will not return rows with...
Read more >Optimizing your GraphQL API with Postgres - Hasura
This post shows how to optimize your GraphQL API using some of Postgres' most popular features. These will help with data validations, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I guess you can use Class 22 — Data Exception error codes
raise exception like this RAISE EXCEPTION USING ERRCODE= ‘22000’, MESSAGE= ‘business logic error message’;
and the client will always receive { “errors”: [ { “extensions”: { “path”: “$”, “code”: “data-exception” }, “message”: “business logic error message” } ] }
https://www.postgresql.org/docs/current/errcodes-appendix.html
@0x777 that would be great. It would also be helpful if that check support a prefix or a pattern/mask to be configured, this could be in accordance to what is specified in the documentation.
In our use case today, we have a helper function (example below) that raises all exceptions that we want to propagate to the client. We use a prefix (eg:
C0
) to the code in order to indicate such application errors.It would really helpful if such a usage pattern (including the propagation of
HINT
) could be supported in the solution for this issue.