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

Related categories from a category query #177

Closed
membla opened this issue Oct 22, 2018 · 2 comments
Closed

Related categories from a category query #177

membla opened this issue Oct 22, 2018 · 2 comments

Comments

@membla
Copy link

membla commented Oct 22, 2018

I have a main category that itself contains a field for sub categories. The two categories belong to different category groups. Can I use craftql to create a query that exposes all main categories, within them their sub categories, and within these the entries that are related to the respective sub category?

@markhuot
Copy link
Owner

This is now possible. All category fields applied to entries expose two fields, the name of the field as well as the name of the field + Connection. E.g.,

{
  entriesConnection(limit:10) { # pull 10 entries
    edges {
      node {
        title # get the title of the 10 entries
        categoryFieldHandleConnection { # get the categories of on each of the 10 entries
          edges {
            node {
              title # get the title of the related category
            }
            relatedEntries { # get related entries to each category applied to the 10 entries
              entries {
                title
              }
            }
          }
        }
      }
    }
  }
}

@markhuot
Copy link
Owner

Closing this issue. The fix is included in version 1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants