GraphQuery not fetching data of content-relationship in repeatable zone

Hi,

I have a homepage type with a slice (named: links). The repeatable zone of the slice has a content relationship which accepts 1 type (named: link). The link type has just a basic title, image and rich text.
I retrieve the data using following graphquery:

{
    homepage {
      body {
        ...on links { //SLICE
          non-repeat {
            ...non-repeatFields
          }
          repeat {
            ...repeatFields
          }
        }
    }
}

I’m fetching data with:

  const result1 = await client.getSingle('homepage', { graphQuery: myGraphQuery }).then(function (document) {
    return document;
  });

In my response i’m receiving the basic information of the link type, but not the necessary data. The response looks something like this:

data {
    body {
        links {
            items [
                 {
                     id: xxx
                     lang: xxx
                     ....
                     ....
                     ! MISSING DATA ATTRIBUTE
                 },
                 ...
            ]
        }
    }
}

How can I get all this missing information on my relation-item without having to perform extra api calls (waterfall style)?

Hi @kevin.vannimmen, the Content Relationship field won’t provide any content from the linked document unless you specify in your GraphQuery what you are looking for. Here is the documentation for this.

I believe that your GraphQuery needs to look something like this:

{
  homepage {
    body {
      ...on links { //SLICE
        non-repeat {
          ...non-repeatFields
        }
        repeat {
          ...repeatFields
          name_of_content_relationship_field {
            ... on linked_doc_type {
              ...linked_doc_type_Fields
            }
          }
        }
      }
  }
}

Give that a try (updating the names that need to be updated of course) and let me know if it works for you.

Thank you for the help!

I adapted my query like you said above and it works, but I think there is a bug here as-well. I cannot get the data if the linked_doc_type is named “link”. Which here is the case. If I created a new custom type and named it “link-item” instead of “link” it works.

Thanks for letting us know about this. I will inform the dev team about this so hopefully they can address it soon.