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

GraphQL: Access child elements within query #4843

Closed
gregorterrill opened this issue Aug 28, 2019 · 6 comments
Closed

GraphQL: Access child elements within query #4843

gregorterrill opened this issue Aug 28, 2019 · 6 comments
Assignees
Labels
enhancement improvements to existing features graphql ⚙️ features related to the GraphQL API

Comments

@gregorterrill
Copy link

Would be nice if there was a way to access child elements, like the CraftQL plugin's children. For example, this CraftQL query returned a single city and a list of its districts (which are child entries of the city entry in Craft):

query apiQuery ($slug: String) {
  entries(section:[cities], type:[CitiesCity], slug:$slug, limit:1 ) {
    id
    slug
    title,
    districts: children {
      ...on CitiesDistrict {
        id
        slug
        title
      }
    }
  }
}

I would like to be able to do the above in Craft 3.3 but there isn't a way to access the children of an element within a single query as far as I can tell. If it is already possible, can it be added to the documentation with a sample query?

@andris-sevcenko andris-sevcenko self-assigned this Aug 28, 2019
@andris-sevcenko
Copy link
Contributor

Seems like an oversight to me.

@andris-sevcenko andris-sevcenko added the graphql ⚙️ features related to the GraphQL API label Aug 28, 2019
@andris-sevcenko
Copy link
Contributor

By "children", we're talking about children in structures, right?

@gregorterrill
Copy link
Author

Yes, this particular use case is for entries in a Structure, but I believe in CraftQL you can also use children in the context of categories to get child categories.

@andris-sevcenko
Copy link
Contributor

andris-sevcenko commented Aug 28, 2019

Yeah, for sure. I was just making sure you're not wishing to fetch all the related entries in any of the content fields.

@andris-sevcenko
Copy link
Contributor

If it is already possible, can it be added to the documentation with a sample query?

Still have to do this.

@brandonkelly brandonkelly added the enhancement improvements to existing features label Aug 28, 2019
@andris-sevcenko
Copy link
Contributor

Resolved in a0aa539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvements to existing features graphql ⚙️ features related to the GraphQL API
Projects
None yet
Development

No branches or pull requests

3 participants