# Retrieve content relationship document in one query

**URL:** <https://community.prismic.io/t/retrieve-content-relationship-document-in-one-query/3872>\
**Category:** Developing with Prismic\
**Tags:** javascript\
**Created:** [February 4, 2021, 1:03am UTC](https://community.prismic.io/t/retrieve-content-relationship-document-in-one-query/3872 "2021-02-04T01:03:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![e\_account](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@e\_account](https://community.prismic.io/u/e_account)\
**Post date:** [February 4, 2021, 1:03am UTC](https://community.prismic.io/t/retrieve-content-relationship-document-in-one-query/3872/1 "2021-02-04T01:03:27Z")

</div>

Hi I currently have using the js sdk to retrieve a document using its uid. I'd like to get the contents of a linked document ( content relationship field ) in that same query as the uid document call.

Example:  
` const doc = await api.getByUID("profile", "myuid");`

The above brings me back all the fields in this document but I also want to get to all the document fields inside any linked fields in doc.

I'l like to do something like.  
` const doc = await api.getByUID("profile", "myuid", { fetchLinkedDocuments });`

I have seen examples of fetching linked fields based on their name but I want to return all the fields without having to list them.

> **[Fetch Data in React](https://prismic.io/docs/technologies/react-fetch-data)**
>
> In this article, you'll learn how to perform different queries to the Prismic API to get content into your React application.

In the link above can I use the helper getByUID in combination with the options object example:  
` const doc = await api.getByUID("profile", "myuid", {fetchLinks: ['article.title', 'article.description']});`  
But instead of having to know all the fields upfront is there a way to fetch all the fields ?

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [February 4, 2021, 3:33am UTC](https://community.prismic.io/t/retrieve-content-relationship-document-in-one-query/3872/2 "2021-02-04T03:33:53Z")

</div>

Hello, welcome to the community!

An alternative to the `fetchLinks` parameter is [GraphQuery](https://prismic.io/docs/technologies/graphquery-rest-api), a query option you can add to your Prismic queries to specify which fields to retrieve and what content to retrieve from Linked Documents / Content Relationships.

GraphQuery uses a GraphQL-like syntax and allows you to do selective fetching (i.e., fetch only the fields you need) and deep fetching (i.e., fetch the document + author in one request).

With this option, you will still need to specify each of the fields inside the linked documents but without the limitations of `fetchLinks`, which are not being able to query certain fields and any field in a Group or Slice. Plus, the GraphQL-like syntax makes the query more readable.

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [February 10, 2021, 4:56pm UTC](https://community.prismic.io/t/retrieve-content-relationship-document-in-one-query/3872/4 "2021-02-10T16:56:54Z")

</div>

This issue has been closed due to inactivity. [Flag to reopen](https://community.prismic.io/t/re-open-a-thread/2175).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 4:43pm UTC](https://community.prismic.io/t/retrieve-content-relationship-document-in-one-query/3872/5 "2021-12-09T16:43:26Z")

</div>


