Comments (5)
I've noticed a similar issue with errors when passing nil
as the value for a types.GraphQLNonNull(...)
which should throw an error.
from graphql.
Hi guys,
Currently user functions (such as ParseLiteral
, ResolveFn
etc) that are passed into configs and executed by the executor
. Any panics are caught/recovered by the executor
and then be returned as Errors
in GraphQLResult
struct.
type GraphQLResult struct {
Data interface{} `json:"data"`
Errors []graphqlerrors.GraphQLFormattedError `json:"errors,omitempty"`
}
As to why the current executor
implementation uses panic
instead of returning a more idiomatic error
value, I chose to defer from making that decision, instead made a straight port from graphql-js
which throws error everywhere and anywhere, and wait to hear from the community :)
Personally I would love to see a move to a more go-idiomatic library as the project shapes itself, so I would vote for (interface{}, error)
return signature for user functions as well.
@bbuck That's interesting. Could you share the JSON response from the query? (If this is off-topic, maybe in a separate issue)
Thanks guys!
from graphql.
I definitely think a move to a more idiomatic approach would be better. As far as I understood the graphql-js implementation was that it was only created to server as an example of how you could implement it. I'm pretty sure making the necessary alterations to bring a GraphQL server library to Go would make sense to apply Go processes to it.
There is some merit in keeping similarities, I'm not necessarily encouraging rebuilding everything, but where it makes sense I definitely think that's the best. And this is one place I think it does make sense. When I work in Go, I've very accustomed to , err
assignments as well as returning an error from my own functions so it wouldn't be something I wouldn't already expect to do. However, writing a panic
line in production (so to speak) code would be something I'd be uncomfortable doing.
Also, @sogko, in regards to my last comment. Disregard. After running again to get your requested information I see the problem is with my previously posted issue on GraphQLInt
ignoring other integer types. If I return a value, everything gives me 0, which is definitely wrong. I feel like it should have been throwing nil to begin with. But if I return nil
directly the proper errors are reported.
from graphql.
There seems to be another issue also if I panic in the ParseValue function it causes the process to crash. I think you are recovering only in the ParseLiteral function I will inspect more on this
types.NewGraphQLScalarType(types.GraphQLScalarTypeConfig{
Name: name,
Serialize: func(value interface{}) interface{} {
return value
},
ParseValue: func(value interface{}) interface{} {
panic("Not String Type")
return value
},
ParseLiteral: func(valueAst ast.Value) interface{} {
return valueAst
},
from graphql.
Cleaning up the issues tracker. Closing this issue since the original issue brought up by @pyros2097 regarding return signature (i.e. (interface{}, error)
has been bought up in #44. Consider continuing the discussion there.
Regarding the panic in ParseValue()
, please consider creating another issue. If I have the time, I'll try to verify it and will open the issue for you.
Thanks and cheers guys!
from graphql.
Related Issues (20)
- Is this project still mantained? HOT 2
- New release?
- Potential goroutine leak in TestContextDeadline HOT 1
- Enums with trailing white space cause error.
- Playground
- make union input type ? it just have output union type
- With fiber HOT 1
- Printing GraphQL documents is slow HOT 1
- Bug with underscore and same name in keys from json response
- MongoDB _id field
- Printer returns invalid SDL if Block String comment contains double-quote
- When using custom scalar types, it's crucial to provide error feedback to users when issues arise with their submitted data. However, triggering exceptions within the ParseValue and ParseLiteral methods can lead to program crashes when using the graphql.Do method. This prevents the necessary error messages from being delivered to users.
- String type no longer recongised HOT 1
- Is it possible to go from `*graphql.Schema` to an ast node? HOT 1
- Error handling HOT 1
- Disabling Field Suggestions
- Is possible to typing typeConfig of graphql.Object after Object done.
- RootObjectFn request body always empty
- Unable to pass {{....}} as part of query or mutation string
- Redefining scalar ID
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 graphql.