Comments (5)
Relevant specs:
https://graphql.github.io/graphql-spec/June2018/#sec-Errors-and-Non-Nullability
https://graphql.github.io/graphql-spec/June2018/#sec-Response
Thanks for opening this discussion! It's a very interesting problem.
A few questions/remarks:
- Your PR makes all effectful fields that are not
UIO
nullable. Is that the correct default for mutations? I'm afraid this might be unexpected for users. If we apply that new behavior to queries only, the inconsistency might be unexpected too 🤔WDYT? - More generally, some users might want to fail and not have partial failures, I think there should be an easy way to do that if we change the default behavior.
- If we do that, the same logic should be applied to
ZQuery
. - If we want to support this in an explicit manner, is there a type we could use that would determine which way to use? Or maybe an annotation?
- I think this should be released only with a solution to accumulate errors, otherwise you wouldn't be able to distinguish between an error and a simple null field.
from caliban.
Is that the correct default for mutations?
I think yes, mutations should behave the same (it's not very clear from the spec, but I think other GraphQL implementations execute all mutations, even if some of them fail). Also, for mutations, it's not always obvious whether the failure means a failure to mutate, or failure to compute the result.
some users might want to fail and not have partial failures
Maybe, although for me it's hard to imagine the case when we have some data but want to intentionally throw it away. Anyway, I think the partial failure should be the default behavior, and it also follows the spec.
I think this should be released only with a solution to accumulate errors
Absolutely. I guess I should have created my PR as a draft.
from caliban.
I think most other libraries rely on the user-defined schema to decide whether to return null or to bubble up the failure (as defined by the spec), so they don't really have any choice to make. What's a bit different here is that we make the choice for the user based on their schema types.
I tend to agree your proposal is a good default, but I think it would be nicer if we let users fail fast if they want to, for example with a mutation like this:
mutation {
deleteA
deleteB
}
If deleteA
fails and is nullable, deleteB
will be ran. If deleteA
fails and is not nullable, the error will bubble up and the whole mutation will return null
without running deleteB
. I can imagine both cases to be needed.
from caliban.
We had some discussions about it on Discord: https://discordapp.com/channels/629491597070827530/633200096393166868/646147482153254913 (feel free to join 😄)
One idea would be to use the Die
channel for the "fail fast" case. User would simply return UIO
(field would be non-nullable) and add .orDie
to make their error interrupt the whole query.
I'll play with the Executor to see if I can achieve the proposed error handling. Will let you know how it goes.
from caliban.
After discussing with @adamgfraser, it seems that to support this feature we first need ZQuery
to support partial failures as well (with something like foldM
or catchAll
in ZIO). He will have a look at that.
Once this is done, the executor will need to collect the errors, set NullValue
for those fields and return (List[E], ResponseValue)
. I can take care of that part.
from caliban.
Related Issues (20)
- Scala 3 different schema derivation nested enum items missing
- Codegen: Incorrect order of description in server sealed trait generation HOT 1
- Outdated `SchemaReporting` docs
- Allow executing mutations / subscriptions in parallel / batched mode
- Support for IO in the tapir interop adapter HOT 12
- Add an apollo rover template HOT 1
- `SchemaComparison` from `caliban-tools` does not detect changes in base interfaces HOT 2
- Duplicate keys when querying with a fragment compared to inlining HOT 4
- Connection leak with http4s websocket subscriptions HOT 11
- Having a single `FieldWrapper(wrapPureValues=true)` in API causes all FieldWrappers to wrap pure values
- ` print(caliban.InputValue.ObjectValue(Map("name" ->caliban.Value.StringValue("string") )).toString)` HOT 1
- Fine-grained support for `null` values. HOT 4
- Allow overriding Tapir endpoint inputs created by Caliban's HttpInterpreter
- Setup CI to run benchmarks and access results HOT 3
- Broken backward compatibility in CatsInterop since v2.7.0 HOT 1
- Since 2.8.0 compilation take forever HOT 8
- Interpreter hangs when using enums with the same name HOT 4
- Deprecated arguments are missing in introspection query HOT 7
- [Feature request] Support for feature toggle directives HOT 6
- Upgrade or remove zio-config 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 caliban.