Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pavel Remizov 4 posts 74 karma points
    Aug 18, 2022 @ 13:25
    Pavel Remizov
    0

    Retrieve children content with graphql with a single query

    Hello, Umbraco comunity. I use Umbraco Heartcore as a headless cms, and I have content node and it's children. And it seems like I'm able to retrieve all children's content with single request like: https://cdn.umbraco.io/content/{id}/children

    But I don't know how to repeat the same request with graphql, seems in graphql children are all under the ContentConnection type, so how to perform some data aggregation on this type during to a single request? in graphql I have something like this

    query {
        MyEntity(url: "entityurl") {
            id
            children {
                // how to retrieve children content here?
            }
        }
    }
    
  • Lindow 154 posts 1301 karma points
    Aug 18, 2022 @ 14:43
    Lindow
    100

    Hi there

    Like so:

    query {
      MyEntity(url: "entityurl") {
        id
        children {
          items {
            name
          }
        }
      }
    }
    
  • Pavel Remizov 4 posts 74 karma points
    Aug 19, 2022 @ 08:43
    Pavel Remizov
    0

    Hi, I used to try query like you wrote but I was unable to retrieve content from the children, like if MyEntity has some ChildEntity content node, how can I retrieve it, for example way like this didn't work for me:

    query {
      MyEntity(url: "entityurl") {
        id
        children {
          items {
            name,
            ... on ChildEntity {
                title,
                description
           }
          }
        }
      }
    }
    
  • Lindow 154 posts 1301 karma points
    Aug 19, 2022 @ 13:40
    Lindow
    0

    This looks correct but you need to get rid of the commas :D

Please Sign in or register to post replies

Write your reply to:

Draft