#GraphQL where with relationship

1 messages · Page 1 of 1 (latest)

upbeat ocean
#

Hey guys,

I'm having troubles using a relationship in a GraphQL query with where , for example something like this:

query Organizations($slug: [String]) {
  Organizations(where: { "categories.slug": { all: $slug } }) {
    docs {
      title
      slug
    }
  }
}

I'd like to provide different slugs for categories and get the organizations that have the categories. However, I get this - Error: Syntax Error: Expected Name, found String "categories.slug".

While in the docs it says it should work: https://payloadcms.com/docs/queries/overview#nested-properties

It only works if on the left side I have only categories and provide an arrays of IDs for the category. I'd like to use the slug instead though.

Payload

Payload is a headless CMS and application framework built with TypeScript, Node.js, React and MongoDB