Comments (4)
in an ideal world, would Relay have GraphQL inline the error rather than returning it in a separate errors list?
I see that you answered your own question regarding that particular encoding scheme, but to answer your question more broadly, I think you're spot on. With explicit error handling, Relay is going to start thinking of the response as a single tree that just happens to encode errors in a look-aside array for the purposes of unambiguous JSON encoding. Relay's runtime is sufficiently sophisticated to be able to, in essence, perform that transformation on the client.
So, for us, the only advantage of a server response that actually was a single tree, would just be some slight performance advantages when interpreting the server response.
from nullability-wg.
It would be wise for Relay to not only add ? to every non-null field, but to nullable fields to in case the schema evolves (since changing a nullable output field to non-nullable is generally seen as non-breaking). Perhaps a shortcut could be to place a ? after the operation name: query Foo? {…}
from nullability-wg.
Good point about schema changes! Ultimately what a client like Relay wants, both for the purpose outlined in this post as well as the True Nullability Schema goal outlined in #19, is an option to opt out of null bubbling globally, exactly as you propose.
A global flag like this more elegantly describes what Relay, and other sufficiently-smart normalizing clients, wants. In addition a global flag would be approachable for simpler clients that don't transform a user-defined query. Although, for those middle-tier smart-clients that don't transform, maybe they would prefer that the flag be supplied as a header or http query variable. That way the client could select the execution mode without needing the user's participation (adding the query-level annotation)...
I'm was a bit hesitant to propose a change where a top-level annotation forks execution behavior for the full query. Having two separate execution modes sounds undesirable from the perspective of the spec and also the mental overhead of the whole ecosystem. That said, I think the value that could be unlocked by a true nullability schema is considerable and would likely be worth the added complexity.
I think the big question here is:
For smart clients that can handle errors client-side, a single top-level annotation like you propose would obviate the need for the rest of CCN. Should we consider skipping CCN, with its complexity, limitations, and tradeoffs, all together and try to make the jump straight to True Schema Nullability?
Some outstanding questions are:
- How do simple clients stay resilient in the face of a true nullability schema? (Does it matter?)
- How practical is it to migrate to a true nullability schema? Legacy clients (apps that have been deployed) will be retroactively opted into a less resilient execution mode.
from nullability-wg.
Question: in an ideal world, would Relay have GraphQL inline the error rather than returning it in a separate errors list? I'm thinking:
{ // Response B (without null bubbling)
"data": {
"me": {
"id": "10",
"age": {
$$isError: true, // <-- note that this key is not possible through aliases, but could happen in custom scalars... Risky.
"message": "Age errored",
// no need for "path"
} // <-- Errored, but did not bubble!
}
}
}
Answer: we can't do this, because of custom scalars. If your JSON
field errored, there's no way for the client to differentiate this between an actual error and data that happens to contain $$isError: true
.
from nullability-wg.
Related Issues (10)
- Sync the video to YouTube HOT 1
- Spec/Proposal revision HOT 3
- Add 'CCN Update' to the next WG meeting agenda HOT 1
- CCN: A path to True Nullability Schema HOT 3
- Write up concerns regarding the try/catch method proposed for CCN HOT 2
- Find a date for the next meeting HOT 5
- [2023-09-26] Update Interrobang RFC... to remove the interrobang 😉 HOT 1
- Rename Working Group to "Nullability Working Group"
- Update README with links to other nullability discussions and RFCs
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 nullability-wg.