# Query for content relationship documents within group fields

**URL:** <https://community.prismic.io/t/query-for-content-relationship-documents-within-group-fields/12164>\
**Category:** Developing with Prismic\
**Tags:** nextjs, graphquery, custom-types-api\
**Created:** [January 11, 2023, 4:49am UTC](https://community.prismic.io/t/query-for-content-relationship-documents-within-group-fields/12164 "2023-01-11T04:49:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgunderson](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jgunderson](https://community.prismic.io/u/jgunderson)\
**Post date:** [January 11, 2023, 4:49am UTC](https://community.prismic.io/t/query-for-content-relationship-documents-within-group-fields/12164/1 "2023-01-11T04:49:17Z")

</div>

Similar to [this topic](https://community.prismic.io/t/query-linked-content-in-nested-page-slice/11458/7), can anyone offer some insight into how to query for content relationship documents within group fields?

I have a custom type with repeatable groups which contain a content relationship field. I am able to query these fields using fetchLinks, but like the linked topic above, fetchLinks only returns the first object in a Rich Text field's array.

JSON for the about\_page custom type:

```auto
{
  "id": "about_page",
  "label": "About Page",
  "repeatable": false,
  "status": true,
  "json": {
    "Main": {
      "uid": {
        "type": "UID",
        "config": {
          "label": "Slug",
          "placeholder": ""
        }
      },
      "page_title": {
        "type": "StructuredText",
        "config": {
          "label": "Page Title",
          "placeholder": "",
          "allowTargetBlank": true,
          "single": "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl"
        }
      },
      "page_content": {
        "type": "StructuredText",
        "config": {
          "label": "Page Content",
          "placeholder": "",
          "allowTargetBlank": true,
          "multi": "paragraph,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl"
        }
      },
      "section": {
        "type": "Group",
        "config": {
          "label": "Section",
          "fields": {
            "section_id": {
              "type": "Text",
              "config": {
                "label": "Section ID",
                "placeholder": ""
              }
            },
            "section_title": {
              "type": "Text",
              "config": {
                "label": "Section Title",
                "placeholder": ""
              }
            },
            "section_content": {
              "type": "StructuredText",
              "config": {
                "label": "Section Content",
                "placeholder": "",
                "allowTargetBlank": true,
                "multi": "paragraph,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item"
              }
            },
            "content_relationship": {
              "type": "Link",
              "config": {
                "label": "Content Relationship",
                "select": "document"
              }
            }
          }
        }
      },
      "slices": {
        "type": "Slices",
        "fieldset": "Slice Zone",
        "config": {
          "choices": {
            "call_to_action": {
              "type": "SharedSlice"
            },
            "content_relationship": {
              "type": "SharedSlice"
            },
            "rich_text_slice": {
              "type": "SharedSlice"
            },
            "three_card_block": {
              "type": "SharedSlice"
            },
            "multiple_button_call_to_action": {
              "type": "SharedSlice"
            }
          }
        }
      }
    }
  }
}

```

JSON for meeting\_tabs custom type:

```auto
{
  "id": "meeting_tabs",
  "label": "Meeting Tabs",
  "repeatable": false,
  "status": true,
  "json": {
    "Main": {
      "uid": {
        "type": "UID",
        "config": {
          "label": "meeting-tabs",
          "placeholder": ""
        }
      },
      "upcoming_meeting_date": {
        "type": "Date",
        "config": {
          "label": "Upcoming Meeting Date",
          "placeholder": ""
        }
      },
      "upcoming_meeting_agenda_packet": {
        "type": "Link",
        "config": {
          "label": "Upcoming Meeting Agenda Packet",
          "placeholder": "",
          "select": null
        }
      },
      "upcoming_meeting_agenda_content": {
        "type": "StructuredText",
        "config": {
          "label": "Upcoming Meeting Agenda Content",
          "placeholder": "",
          "allowTargetBlank": true,
          "multi": "paragraph,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item"
        }
      },
      "previous_meeting_date": {
        "type": "Date",
        "config": {
          "label": "Previous Meeting Date",
          "placeholder": ""
        }
      },
      "previous_meeting_documents": {
        "type": "Group",
        "config": {
          "label": "Previous Meeting Documents",
          "fields": {
            "document_title": {
              "type": "Text",
              "config": {
                "label": "Document Title",
                "placeholder": ""
              }
            },
            "document_link": {
              "type": "Link",
              "config": {
                "label": "Document Link",
                "placeholder": "",
                "select": "media"
              }
            }
          }
        }
      }
    }
  }
}

```

This query is not returning any of the subfields for the meeting\_tabs custom type:

```auto
async function init() {
  const page = await client.getByUID('about_page', 'about-meetings',
  {
    graphQuery: `{
      section {
        meeting_tabs {
          ...on meeting_tabs {
            ...meeting_tabsFields
          }
        }
      }
    }`
  }
  )
  return page
}

init()

```

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 11, 2023, 1:41pm UTC](https://community.prismic.io/t/query-for-content-relationship-documents-within-group-fields/12164/3 "2023-01-11T13:41:13Z")

</div>

Hello @jgunderson

Thanks for reaching out to us.

I think your graphQuery should like this:

```auto
{
  meeting_tabs {
    ...your_custom_typeFields
    previous_meeting_documents {
      document_link {
        ...on media {
          ...mediaFields
        }
      }
    }
  }
}

```

Please follow our technical reference for graphQuery: [GraphQuery API Option Technical Reference - Documentation - Prismic](https://prismic.io/docs/graphquery-rest-api)

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![jgunderson](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jgunderson](https://community.prismic.io/u/jgunderson)\
**Post date:** [January 11, 2023, 1:49pm UTC](https://community.prismic.io/t/query-for-content-relationship-documents-within-group-fields/12164/4 "2023-01-11T13:49:08Z")

</div>

Thank you @Priyanka.

I just solved this by adding the Custom Type (about\_page) and then the group API ID (section):

```auto
      about_page {
      section {
        ...sectionFields
          content_relationship {
            ...on meeting_tabs {
              ...meeting_tabsFields
            }
          }
}
}

```

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 11, 2023, 9:34pm UTC](https://community.prismic.io/t/query-for-content-relationship-documents-within-group-fields/12164/5 "2023-01-11T21:34:20Z")

</div>

Great @jgunderson. Let us know if you need any assistance.
