-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
questionFurther information is requestedFurther information is requested
Description
I'm trying to order a GROQ query dynamically by passing an $order variable.
Hardcoding does work
const query = groq`{"BlogPosts": *[_type=='blog_post'] | order(publishedAt desc)}`;
const { data, status } = await useSanityQuery(query)Passing a variable does not work. The ordering is just ignored and the results are returned without ordering
const query = groq`{"BlogPosts": *[_type=='blog_post'] | order($order desc)}`;
const { data, status } = await useSanityQuery(query, {
'order': 'publishedAt',
});The same when passing the order field as a string. This does not work:
const query = groq`{"BlogPosts": *[_type=='blog_post'] | order('publishedAt' desc)}`;
const { data, status } = await useSanityQuery(query)Am I passing the order variable in a wrong format or is this not possible with this module?
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested