# Get related content via graphQuery doesn't work

**URL:** <https://community.prismic.io/t/get-related-content-via-graphquery-doesnt-work/14589>\
**Category:** Developing with Prismic\
**Tags:** graphquery, rest-api\
**Created:** [November 27, 2023, 11:13am UTC](https://community.prismic.io/t/get-related-content-via-graphquery-doesnt-work/14589 "2023-11-27T11:13:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianbreitmeyer](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@marianbreitmeyer](https://community.prismic.io/u/marianbreitmeyer)\
**Post date:** [November 27, 2023, 11:13am UTC](https://community.prismic.io/t/get-related-content-via-graphquery-doesnt-work/14589/1 "2023-11-27T11:13:23Z")

</div>

Hi, i just try to develop my first prismic project – a simple portfolio.

So i have Pages for every Project/Case, but also a Custom Type for ProjectTeaser with content realtions fields for image/stageimage, projecttitle and projecttagline.

No i want to query these data from the homepage to show a slider of Projectteasers there. But i can't get it to work.

my query looks like this atm:

```auto
const teasers = await client.getAllByType("projectteaser", {
    graphQuery: `{
      projectteaser {
        projecttitle {
          ...on Project {
            title
          }
        }
      }
    }`
  })

```

the definition of my project and projectteaser looks like this:  
projectteaser

```auto
{
  "id": "projectteaser",
  "label": "ProjectTeaser",
  "format": "custom",
  "repeatable": true,
  "status": true,
  "json": {
    "Main": {
      "uid": {
        "config": {
          "label": "UID"
        },
        "type": "UID"
      },
      "linked_stageimage": {
        "type": "Link",
        "config": {
          "label": "LinkedStageImage",
          "select": "document"
        }
      },
      "linked_projecttitle": {
        "type": "Link",
        "config": {
          "label": "LinkedProjectTitle",
          "select": "document"
        }
      },
      "linked_projecttagline": {
        "type": "Link",
        "config": {
          "label": "LinkedProjectTagline",
          "select": "document"
        }
      }
    }
  }
}

```

project

```auto
{
  "id": "project",
  "label": "Project",
  "format": "page",
  "repeatable": true,
  "status": true,
  "json": {
    "Main": {
      "uid": {
        "config": {
          "label": "UID"
        },
        "type": "UID"
      },
      "slices": {
        "type": "Slices",
        "fieldset": "Slice Zone",
        "config": {
          "choices": {
            "stage": {
              "type": "SharedSlice"
            },
            "background": {
              "type": "SharedSlice"
            },
            "project_intro": {
              "type": "SharedSlice"
            }
          }
        }
      }
    },
    "SEO & Metadata": {
      "meta_description": {
        "config": {
          "label": "Meta Description",
          "placeholder": "A brief summary of the page"
        },
        "type": "Text"
      },
      "meta_image": {
        "config": {
          "constraint": {
            "height": 1260,
            "width": 2400
          },
          "label": "Meta Image",
          "thumbnails": []
        },
        "type": "Image"
      },
      "meta_title": {
        "config": {
          "label": "Meta Title",
          "placeholder": "A title of the page used for social media and search engines"
        },
        "type": "Text"
      }
    }
  }
}

```

second question is, if this is the way to go for my usecase, even if it works. Thanks for any help or nudge in the right dorection in advance 🙂

---

<div class="post-metadata">

**Author:** ![nf\_mastroianni](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/nf_mastroianni/32/7071_2.png) [@nf\_mastroianni](https://community.prismic.io/u/nf_mastroianni)\
**Post date:** [November 28, 2023, 12:50am UTC](https://community.prismic.io/t/get-related-content-via-graphquery-doesnt-work/14589/2 "2023-11-28T00:50:27Z")

</div>

Have you tried using fetchLinks instead of graphQuery?

Here's mine as an example:

```auto
const page = await client
    .getByUID('product', params.product, {
      fetchLinks: [
        'brand.description',
        'brand.logo',
        'brand.title',
        'product_type.title',
        'product_type.description',
        'product_type.featured_image',
        'service.title',
        'service.excerpt',
      ],
    })
    .catch(() => notFound())

```

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [November 28, 2023, 3:30pm UTC](https://community.prismic.io/t/get-related-content-via-graphquery-doesnt-work/14589/3 "2023-11-28T15:30:39Z")

</div>

Hi @marianbreitmeyer ,

For GraphQueries, you always have to put the entire content of the parent document and then be sure to reference correctly the link field API ID, then the content you need from the linked document.

It's not what I would recommend to do here. On your index file in your project, I would do 2 queries, one for your homepage and one for your projects and build it out from there.

---

<div class="post-metadata">

**Author:** ![marianbreitmeyer](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@marianbreitmeyer](https://community.prismic.io/u/marianbreitmeyer)\
**Post date:** [November 28, 2023, 9:33pm UTC](https://community.prismic.io/t/get-related-content-via-graphquery-doesnt-work/14589/4 "2023-11-28T21:33:59Z")

</div>

Yep, thanks for the advice. That's what i ended up doing. Works fine so far :)
