Content relationship fields inside a group

I'm trying to get all the fields of a content relationship "promo_blocks" nested inside a group "promo_blocks_group". My understanding is that I need to use GraphQuery, but I'm not sure about the structure.
Any help with this?

Here is the content type

  "Main" : {
    "promo_blocks_group" : {
      "type" : "Group",
      "config" : {
        "fields" : {
          "promo_blocks" : {
            "type" : "Link",
            "config" : {
              "select" : "document",
              "customtypes" : [ "promo_block" ],
              "label" : "Blocks"
            }
          }
        },
        "label" : "Promo Blocks Group"
      }
    }
  }

Have you seen the GraphQL help pages? You can create GraphQL queries in https://your-repository.prismic.io/graphql.

Your query will be something like this:

query {
  allPromo_blocks {
    edges {
      node {
        body
        _linkType
      }
    }
  }
}

Pro tip, use ctrl+space/cmd+space in the GraphiQL viewer to access auto-fill suggestions.

Hi @filippo.bovo. I think that your GraphQuery will look something like this:

{
  your_custom_type {
    ...your_custom_typeFields
    promo_blocks_group {
      promo_blocks {
        ...on promo_block {
          ...promo_blockFields
        }
      }
    }
  }
}

Give that a try and let me know if it works for you. Keep in mind that you’ll need to update your_custom_type and your_custom_typeFields with the API ID of the Custom Type that you are querying.

Also as a general note for anyone reading this, GraphQuery is different than GraphQL. GraphQuery is an updated version of fetchLinks which allows you to retrieve content from a Content Relationship field when using the REST API. Here is the documentation for GraphQuery:
https://prismic.io/docs/rest-api/query-the-api/graphquery

Thanks @Levi, works like a charm

1 Like