You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature is just syntax sugar on top of existing features of GraphQL API. The dot-notation projection proposal is something like:
x.y.z
Which is expanded to:
x {
y {
z
}
}
The separator for the projection could be another token, such as :: (for instance, x::y::z), but the goal here is to avoid too much typing and spare efforts.
Rationale/why:
On large projects made of diverse relations, our queries & mutation payloads become quite complex. Indentation levels become deep, which hinders the source code reading. This syntax also favours and simplifies auto-complete toolings.
Additional comments:
This feature is only useful for many-to-one relationships. On either one-to-many or many-to-many, we'll often resort to some kind of pagination (on most times, Relay/cursor-based). Nevertheless, the syntax can be extended to accept parameters on the last field of the chain of projections, for instance:
A new syntax is always a burden for compiler/parser writers. Despite that, because the syntax sugar expansion property, this syntax could be expanded before the parsing phase, and therefore, reuse the existing parsing/grammar rules already implemented.
I would like to hear opinions from you guys. Thanks in advance. 🐈
The text was updated successfully, but these errors were encountered:
I'm concerned that this adds complexity and weight without adding much value. Generally I prefer there be only one way to express something. This proposal doesn't unlock any new use cases. Also, accepting this proposal would make #174 not possible, so the complexity cost here is real.
this syntax could be expanded before the parsing phase, and therefore, reuse the existing parsing/grammar rules already implemented.
Unfortunately that means this syntax would be only transient. Printing an AST would not be able to create this syntax.
Brief Description:
This feature is just syntax sugar on top of existing features of GraphQL API. The dot-notation projection proposal is something like:
Which is expanded to:
The separator for the projection could be another token, such as
::
(for instance,x::y::z
), but the goal here is to avoid too much typing and spare efforts.Rationale/why:
On large projects made of diverse relations, our queries & mutation payloads become quite complex. Indentation levels become deep, which hinders the source code reading. This syntax also favours and simplifies auto-complete toolings.
Additional comments:
This feature is only useful for many-to-one relationships. On either one-to-many or many-to-many, we'll often resort to some kind of pagination (on most times, Relay/cursor-based). Nevertheless, the syntax can be extended to accept parameters on the last field of the chain of projections, for instance:
Being expanded to:
Bad use cases:
The following code below is a counter-argument for this proposal:
Where a better and clean approach would just be:
Or, who knows:
The non-last parametrized fields are only "sound" on single-field projections, otherwise, a client could do that and thus break expansion:
Resulting in the following unsound/incorrect expansion:
Compatibility breaking:
As far I'm concerned, there's no one.
Cost analysis:
A new syntax is always a burden for compiler/parser writers. Despite that, because the syntax sugar expansion property, this syntax could be expanded before the parsing phase, and therefore, reuse the existing parsing/grammar rules already implemented.
I would like to hear opinions from you guys. Thanks in advance. 🐈
The text was updated successfully, but these errors were encountered: