FormidableLabs / groqd

A schema-unaware, runtime and type-safe query builder for GROQ.
https://commerce.nearform.com/open-source/groqd
MIT License
222 stars 17 forks source link

Groqd schema guide for deref #222

Closed emt-mocha closed 10 months ago

emt-mocha commented 10 months ago

Hi I am having problem to query for below:

*[_type == 'home' && !(_id in path("draft.**"))]{
  services{
    scopes[0...4]->{
      title,
      subTitle,
    }
  }
}

I tried using the below method but failed to get the result:

runQuery(
  q("*")
    .filter("_type == 'home' && !(_id in path('draft.**'))")
    .slice(0)
    .grab$({
      services: q.object({
          scopes: q('scopes').filter().deref().grab({
          title: q.string(),
          subTitle: q.string(),
        }).slice(0 , 3)
      }),
   }),

Can some one help me to resolve this please. Thank you in advance.