Conditional dereferencing of elements #372
-
Hi, I have an array of objects and references where I need to deref the references only. I modified the pokemon playground and changed one of Of course dereferencing the whole
Here is the raw GROQ query I would like to build with Groqd:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
With the current API, the best way I can think to do this is to use the
But I'm eager to think of a better way to handle this... |
Beta Was this translation helpful? Give feedback.
-
This is officially supported now! With #378 and #376 . You can do the following: Link to arcade q.star
.filterByType("pokemon")
.project(q => ({
name: z.string(),
types: q.field("types[]").project(q => ({
...q.conditionalByType({
reference: q => q.field("@").deref(),
link: q => q.field("@"),
}),
})),
})) Notice the |
Beta Was this translation helpful? Give feedback.
This is officially supported now! With #378 and #376 .
You can do the following: Link to arcade
Notice the
q.field("@")
syntax, which is strongly-typed!