Comments (5)
I see, yes, we can very well do that.
from dgs-framework.
Hi - actually you need to wrap the throwing of the exception in a DataFetcher and return that. This will allow the default exception handler to trigger and do the needful. You can also add your own custom exception handler if you want more control over the result.
public @NotNull DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state) {
if (true) {
return DataFetcher -> {
throw new NullPointerException("I made an oopsie");
};
}
return super.instrumentDataFetcher(dataFetcher, parameters, state);
}
Will result in the following:
"errors": [
{
"message": "java.lang.NullPointerException: I made an oopsie",
"locations": [
{
"line": 3,
"column": 1
}
],
"path": [
"hello"
],
"extensions": {
"errorType": "INTERNAL"
}
}
],
"data": {
"hello": null
}
}
from dgs-framework.
That's a good tip, thanks. Still, I would argue the framework shouldn't swallow exceptions like that.
from dgs-framework.
That's a good tip, thanks. Still, I would argue the framework shouldn't swallow exceptions like that.
I see your point. However, we are leveraging graphql-java's execution here, so in order to get all of the properly formatted response with errors as part of the result, we need to go through the exception handling mechanism. You could argue that we can format the same where we catch the exception, but we do not have all information at that point, we just have the message, which I suppose we can add to the error that we construct.
from dgs-framework.
I'm not suggesting changing how exceptions are handled, only asking that it is properly logged in this case (ie to add logger.error()
) - that would make debugging easier :)
from dgs-framework.
Related Issues (20)
- feature: Allow specifying custom scalars when generating queries using Kotlin query projections HOT 11
- bug: webRequest.getResponse() is null HOT 5
- bug: CORS errors in frontend app only after updating to v6 (with SpringBoot 3) HOT 1
- Scalar backed by value class inside input type fail to deserialize HOT 3
- bug: No qualifying bean of type 'com.fasterxml.jackson.databind.ObjectMapper' available HOT 6
- bug: unmapped fields after version upgrade when using dgs.graphql.schema-locations HOT 5
- bug: Deadlock after upgrading to DGS 7.6.0 version HOT 7
- bug: dgsMicrometerContextRegistry's Slf4jThreadLocalAccessor conflicts with ObservationThreadLocalAccessor HOT 5
- bug: Switching to `graphql-dgs-spring-graphql-starter` breaks `Upload` GraphQL scalar HOT 3
- documentation: Incorrect Information in DGS Framework Documentation Regarding WebSocket Sub-Protocols HOT 2
- bug: unmapped fields after switching to Spring GraphQL integration HOT 5
- bug: "path" is not mapped from DataFetchingException to TypedGraphQLError HOT 1
- bug: scalar coercing exceptions don't use typed graphql error HOT 8
- bug: XML Injection (AKA Blind Xpath Injection) in ORG.XMLUNIT:XMLUNIT-CORE [CVE-2024-31573] HOT 1
- bug: Java Optional<> - Failed to convert from type LinkedHasMap<?, ?> to type HOT 4
- bug: OpenTelemetry Context is not getting propagated in the data loader HOT 5
- bug: dgs.graphql.path is not working in 8.7.1 & 9.0.0 versions with spring integration HOT 3
- bug: GraphQLJavaErrorInstrumentation changes error type of DataFetchingException HOT 3
- bug: Optional null fields are not returned HOT 5
- bug: DgsSpringGraphQLAutoConfiguration not compatible with WebFluxHateoasConfiguration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dgs-framework.