-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use sanityImage('string') in q.object? #216
Comments
Ahh – the Zod/TS errors are not at all comprehensible. The core issue, I believe, is that the fields inside I believe the rationale for returning a groqd query from Not sure if it's feasible, but you could probably achieve this by refactoring to using nested |
@multiplehats any solution? |
I think I got it working after a little trial and error, using nested So instead of this (which is how I expected groqd to work): q("*")
.filter("_type == 'page'")
.grab$({
hero: q.object({
heading: q.string(),
image: sanityImage("image", { withAsset: ["base", "blurHash"] }),
content: q.contentBlocks(),
}),
sections: q.array(
q.object({
heading: q.string(),
image: sanityImage("image", { withAsset: ["base", "blurHash"] }),
content: q.contentBlocks(),
})
),
}) I used this: q("*")
.filter("_type == 'page'")
.grab$({
hero: q("hero").grab$({
heading: q.string(),
image: sanityImage("image", { withAsset: ["base", "blurHash"] }),
content: q.contentBlocks(),
}),
sections: q("sections")
.filter() // turns it into an array query
.grab$({
heading: q.string(),
image: sanityImage("image", { withAsset: ["base", "blurHash"] }),
content: q.contentBlocks(),
}),
}) It seems to give me both the right data and types. Happy to hear suggestions if there are better approaches. |
I'm having the same issue, I had like to find a better solution for this aswell |
Hey guys! Thanks for the awesome library.
One thing I can't figure out for the life of me is how to use
sanityImage
insideq.object()
.Am I missing something?
The text was updated successfully, but these errors were encountered: