Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added taxanomy to Graphql EntriesQuery #4779

Closed
wants to merge 3 commits into from

Conversation

SteJW
Copy link
Contributor

@SteJW SteJW commented Nov 19, 2021

This allows you to filter in GraphQL on the taxanomy. The basic filter function is pretty simple and doesn't allow to filter on multiple values.

How the query looks when using taxanomy.

query Entry {
  entries(collection: "products", filter: {
    taxonomy: ["target::moederfiets","target::fiets"],
  }) {
    data {
      ... on Entry_Products_Products {
        id
        title
        slug
        product_type {
          slug
          id
        }
        target {
          slug
          id
        }
      }
    }
  }
}

I tried using queries like this, but no luck. Added a quick fix at #4739 but that doesn't work correctly either.

query Entry {
  entries(collection: "products", filter: {
    target: {in: {slug : [ "fiets"]}},
  }) {
    data {
      ... on Entry_Products_Products {
        id
        title
        slug
        product_type {
          slug
          id
        }
        target {
          slug
          id
        }
      }
    }
  }
}

I copied this function from https://github.com/statamic/cms/blob/3.2/src/Tags/Collection/Entries.php:300

@jasonvarga
Copy link
Member

With taxonomies potentially being reworked soon, I'd like to avoid adding more taxonomy features until then.

You may currently filter by taxonomy using a regular filter.

query MyQuery {
  entries(collection: "articles", filter: {
    tags: { contains: "sneakers" }
  }) {
    data {
      title
      id
    }
  }
}

@jasonvarga jasonvarga closed this Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants