Query for page with slices linking to different custom types

I'm struggling a bit with the query for the model I set up. Essentially, I have a main page a tile and slices. There is only one slice type and that slice has a title, and then a group of fields that are all content relationships to other custom types I have created.

Can I setup a query with Gatsby so that the prismic user can keep adding slices with content relationships to different custom types without having to update the query every time they make a new custom type?

Hello @mitchelsarauer!

You can build such query by retrieving the Content Relationship field from the Custom Type.

If you want, you can share the structure of your Custom Type. I can help you write the query.

That would be amazing!

Here is the json for the custom type:

{
  "Main": {
    "title": {
      "type": "StructuredText",
      "config": {
        "single": "heading1",
        "label": "title"
      }
    },
    "lead": {
      "type": "StructuredText",
      "config": {
        "multi": "paragraph",
        "label": "lead"
      }
    },
    "body": {
      "type": "Slices",
      "fieldset": "Slice zone",
      "config": {
        "labels": null,
        "choices": {
          "test": {
            "type": "Slice",
            "fieldset": "step",
            "description": "step",
            "icon": "ac_unit",
            "display": "list",
            "non-repeat": {
              "title": {
                "type": "StructuredText",
                "config": {
                  "single": "heading2",
                  "label": "Title"
                }
              },
              "text": {
                "type": "StructuredText",
                "config": {
                  "multi": "paragraph",
                  "label": "text"
                }
              }
            },
            "repeat": {
              "form_field": {
                "type": "Link",
                "config": {
                  "select": "document",
                  "label": "Form Field"
                }
              }
            }
          }
        }
      }
    }
  }
}

Here's an example. Say this Custom type is called Article and you have other two types of Custom types Page and BlogPost. This is how you'd cover the two other Custom Types inside the form_field link:

query MyQuery {
  allPrismicArticle {
    nodes {
      data {
        body {
          ... on PrismicArticleDataBodyTest {
            id
            items {
              form_field {
                document {
                  ... on PrismicBlogPost {
                    id
                  }
                  ... on PrismicPage {
                    id
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}