Defining custom fields under errors.extensions field and use dgs codegen to retrieve the custom fields #1937
shivagithub1
started this conversation in
General
Replies: 2 comments 1 reply
-
Could share minimal code sample to replicate this behaviour? Also, please further clarify the behaviour expected? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Not the prettiest but made it work using Configuration configuration = Configuration.builder()
.mappingProvider(new JacksonMappingProvider())
.build();
TypeRef<List<TypedGraphQLError>> typeRef = new TypeRef<>() {};
List<TypedGraphQLError> errors = JsonPath.using(configuration).parse(result.getJson()).read("$.errors", typeRef); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
We are using DGS framework for our new service and we are using dgs generated client to generate the JavaClient for our clients to integrate with our api. In case of errors, As mentioned in https://netflix.github.io/dgs/error-handling/, the dgs client is returning GraphQLError object from dgs library and extensions field is of TypedError type. However we wanted to have our own errorType values and also wanted to include additional fields within extensions map. Since the errorType is of enum type, we are not able add our own values to errorType enum.
So we are following the graphql-java spec and returning below error response using an Instrumentation class.
Now we are trying to see how we can read the fields within extensions field including errorType, errorDetail, isRetryable. The dgs graphQLResponse.getErrors() method is returning GraphQLError object from dgs library and is providing above custom fields as expected. Below is Java object toString() on GraphQLError object.
[GraphQLError(message=error message, path=[field1], locations=[], extensions=GraphQLErrorExtensions(errorType=UNKNOWN, errorDetail=ValidationException, origin=, debugInfo=GraphQLErrorDebugInfo(subquery=, variables={}), classification=DataFetchingException))]
I am looking for guidance here. Below is one option that i am thinking.
Beta Was this translation helpful? Give feedback.
All reactions