🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Beginner seeks help with GROQ query for getting title of availability in Sanity schema.

1 replies
Last updated: Jun 6, 2023
Hey, I'm a beginner with Sanity and I feel like this should be simple but can't figure it out.
What GROQ query should I use to get the title of availability (i.e 'Available at')?

I tried this query but I get null:

*[_type == "brand"][0]{
      "availability":availability.title,
    }
Schema:

const brand = {
  name: 'brand',
  title: 'Brands',
  type: 'document',
  fields: [
{
      name: 'availability',
      title: 'Available at',
      type: 'array',
      of: [
        {
          name: 'link',
          title: 'Source',
          type: 'object',
          fields: [
            {
              name: 'anchor',
              title: 'Anchor text',
              type: 'string',
            },
            {
              name: 'url',
              title: 'URL',
              type: 'url',
            },
          ],
        },
      ],
    },
],
};
Jun 6, 2023, 2:39 PM
Afaik this is not possible. You can only query the data that stored, not the schema itself.
Jun 6, 2023, 2:54 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?