How can you avoid repeated references? (supporting the ...
spread operator)
#282
-
Hello! I'm new to GROQD, and we're evaluating the possibility of integrating it instead of our manual query builder (which isn't on the same type-safe level as GROQD). While reading through Sanity's "High Performance GROQ", I stumbled upon this recommendation, which recommends you spread ( Instead of this:
Do this:
Right now, whenever I need to grab a specific property in a complex matter, I can just start a new
In the 2nd example, there is more than 1 property that should share some kind of logic to prevent 2 references to "parent". I was wondering if this technique is something that can be implemented with the current version of GROQD? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Great question! Unfortunately, this is not currently supported by GroqD. Below, I'll post some of our proposed suggestions. Let us know what you think , and please propose your own ideas if anything comes to mind! |
Beta Was this translation helpful? Give feedback.
-
Suggestion: Spread Key
However this doesn't allow for "multiple" spreads. We might have to expand this to support an array, which gets inconvenient:
This can also be challenging when we support "fragments", because this key could get overridden instead of merged. |
Beta Was this translation helpful? Give feedback.
-
Suggestion:
|
Beta Was this translation helpful? Give feedback.
-
Suggestion: adding a parameter to
|
Beta Was this translation helpful? Give feedback.
Great question! Unfortunately, this is not currently supported by GroqD.
we've considered ways to add this support, and we're open to suggestions.
Below, I'll post some of our proposed suggestions. Let us know what you think , and please propose your own ideas if anything comes to mind!