1

I am trying to list a set of articles by their categories, by uid, and I'm assuming that I would have to use the where query, but I'm not able to get that to worked on linked documents.

The issue seems to be that where only accepts a string on a field, but in the case of a linked document you would need to dig down to the uid field.

I'm not sure if I'm using the wrong query, but struggling to find anything in the documentation to help me out.

I tried digging into the category object:

{
  allDirectoryServices(
    where: { category: { _meta: { uid: "developers" } } }
  ) {
    edges {
      node {
        name
        city
        region
        country
        category {
          ...on DirectoryTaxonomy {
            _meta {
              uid
            }
            name
          }
        }
      }
    }
  }
}

But that returns an error that it's expecting a string:

"message": "Expected type String, found {_meta: {uid: \"developers\"}}.",
{
  allDirectoryServices(
    where: { category: "developers"}
  ) {
    edges {
      node {
        name
        city
        region
        country
        category {
          ...on DirectoryTaxonomy {
            _meta {
              uid
            }
            name
          }
        }
      }
    }
  }
}

This returns no results, obviously.

TraaidMark
  • 63
  • 8

1 Answers1

1

I asked this question on the Prismic Slack group too, and got the answer from them:

In order to query by a Content Relationship / Link field like this, you need to use the document ID.

where: { category: "WBsLfioAABNUo9Kk" }

Unfortunately it isn’t possible to query by the UID (or any other field).

I imagine they will be updating their documentation soonish, as this isn't covered by it.

Thanks to the Prismic guys!

TraaidMark
  • 63
  • 8