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

Add generic ability to add extension key-value for Errors #299

Closed
phillip-kruger opened this issue Jun 19, 2020 · 2 comments
Closed

Add generic ability to add extension key-value for Errors #299

phillip-kruger opened this issue Jun 19, 2020 · 2 comments
Labels
Server This issue applies to the Server side

Comments

@phillip-kruger
Copy link
Member

Relate to #282. We have code as a key supported with #295 but still need a generic key value.

Some more features:

  • Move the knowledge to the model, so that we do not need to check annotations in runtime.
  • Allow adding of Annotation on method that throw the exception, to get per instance usage (currently it's global)
  • Add way to do all that is done for code for any other key-value
@phillip-kruger phillip-kruger added the Server This issue applies to the Server side label Sep 1, 2020
@t1
Copy link
Collaborator

t1 commented Feb 26, 2021

I think we should add an instance extension, too; probably an UUID. This would be logged on the server, so when the client reports an error, it's easy to find the exact request without relying on the timestamp or so. In rfc-7807, it's an URI, so it could be an URN like urn:uuid:1234-1232534-... or an URL directly into the logging system.

@piotrblasiak
Copy link

I think graphql-java has the most flexible, if not the most developer friendly approach. There you register a DataFetcherExceptionHandler and override getExtensions in the thrown GraphQLError. This makes it possible to add 3 important use cases for exception extensions:

  1. (Static) per class - like the @errorcode already does
  2. Instance - additional details that do not fit into the message field of an error but that are still relevant and specific to an exception instance.
  3. Handled throw - like @t1 suggests an UUID or other kind of reference, whatever the developer wants to call it. This probably needs to be added to the exception after it has been thrown.

t1 added a commit to t1/smallrye-graphql that referenced this issue May 14, 2022
jmartisk pushed a commit to jmartisk/smallrye-graphql that referenced this issue May 16, 2022
…ow custom GraphQL error `extension` fields; use it for `code` and `exception` (class name)
jmartisk pushed a commit to jmartisk/smallrye-graphql that referenced this issue May 16, 2022
jmartisk added a commit that referenced this issue May 16, 2022
fix #299: custom GraphQL error `extension` fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Server This issue applies to the Server side
Projects
None yet
Development

No branches or pull requests

3 participants