GraphQuery question

Hi! I've been trying to use a GraphQuery in with the JS API and I'm stuck on one part.

I have a slice on my homepage which has links to three items of a custom type called "video".
With the Query I'm trying to get the content of the linked video document with the GraphQuery.

This is my query:

const graphQuery = `{
  home {
    body {
      ...on top_videos {
          non-repeat {
            ...non-repeatFields
          }
          repeat {
            ...repeatFields
          }
        }
      }
    }
  }`

In that repeat zone I have links to documents of part video. When I use the ...repeatFields I only get link data. But I actually want to get the title and image, etc.

In the docs there is this example:

{
  blog {
    author_link {
      ...on author {
        name_of_the_author
      }
    }
  }
}

But I can't get that to work in my case.

What do I do?

Thanks!

I have managed to resolve my issue. I had to add a content relationship field rather than a link field. This is the query that works:

{
        home {
          body {
            ...on top_videos {
              repeat {
                ...repeatFields
                video {
                  ...on video {
                    ...videoFields
                  }
                }
              }
            }
          }
        }
      }
2 Likes

Hi Tim,

Thanks for sharing the solution,
Please let us know if you need any help.

Fares