Gatsby, Prismic with GraphQl query aliases error

Gatsby, Prismic with GraphQl query aliases error


0

I tried to update Gatsby and plugins from v4 to v5. I started getting this error in my query:

const query = graphql`
  query Ad {
    prismicHomepage {
      id
      type
      data {
        body {
          ... on PrismicHomepageDataBodyCompareRatesCards {
            id
            slice_type
            items {
              bank {
                html
                text
                richText
              }
              checkingname {
                html
                text
                richText
              }
              savingname {
                html
                text
                richText
              }
              checkingrates {
                html
                text
                richText
              }
              savingrates {
                html
                text
                richText
              }
              fdicinsured
              monthlyfees {
                text
                html
                richText
              }
              maintenancefees {
                text
                html
                richText
              }
              maintenancefeestext {
                text
                html
                richText
              }
              overdraftfees {
                text
                html
                richText
              }
              overdraftfees {
                text
                html
                richText
              }
              feefreecashback
              minimumbalance {
                text
                html
                richText
              }
              havesavingplan
              savingplanname {
                text
                html
                richText
              }
              maximumtransactions {
                text
                html
                richText
              }
              maximumtransactiondescription {
                text
                html
                richText
              }
            }
            primary {
              savingnotes {
                html
                text
                richText
              }
              checkingnotes {
                html
                text
                richText
              }
              hmbrateswithoutcreditcard {
                html
                text
                richText
              }
              hmbrateswithcreditcard {
                html
                text
                richText
              }
              copy {
                html
                text
                richText
              }
              title {
                text
                html
                richText
              }
            }
          }
          ... on PrismicHomepageDataBodyProductCards {
            id
            items {
              product_card {
                document {
                  ... on PrismicProductCard {
                    id
                    data {
                      link_cta
                      product_type
                      title {
                        html
                        text
                        richText
                      }
                      copy {
                        html
                        text
                        richText
                      }
                      legal {
                        html
                        text
                        richText
                      }
                      link
                    }
                    _previewable
                  }
                }
              }
            }
            primary {
              title {
                html
                text
                richText
              }
            }
            slice_type
          }
        }
      }
      _previewable
    }
    prismicAd {
      id
      type
      data {
        body {
          ... on PrismicAdDataBodyHero {
            id
            slice_type
            primary {
              copy {
                html
                text
                richText
              }
              title {
                html
                text
                richText
              }
              fdic_copy {
                html
                text
                richText
              }
            }
          }
          ... on PrismicAdDataBodyPressLogos {
            id
            slice_type
            items {
              logo {
                alt
                url
              }
              external_link {
                url
              }
            }
            primary {
              title {
                text
                html
                richText
              }
            }
          }
          ... on PrismicAdDataBodyRoutinehero {
            id
            slice_type
            primary {
              title {
                text
                html
                richText
              }
              copy {
                text
                html
                richText
              }
              button_copy {
                text
                html
                richText
              }
              title_second {
                text
                html
                richText
              }
              title_secondary_2 {
                text
                html
                richText
              }
            }
          }
          ... on PrismicAdDataBodyProductsIntroduction {
            id
            slice_type
            items {
              copy {
                html
                text
                richText
              }
              product_type
              title {
                html
                text
                richText
              }
            }
            primary {
              copy {
                html
                text
                richText
              }
              title {
                text
                html
                richText
              }
            }
          }
          ... on PrismicAdDataBodyBuild {
            id
            slice_type
            primary {
              title {
                text
                html
                richText
              }
              copy {
                text
                html
                richText
              }
            }
            items {
              link {
                text
              }
              copy {
                html
                text
                richText
              }
              title {
                html
                text
                richText
              }
              button_text {
                html
                text
                richText
              }
            }
          }
          ... on PrismicAdDataBodyFooterLegal {
            id
            slice_type
            items {
              footnote {
                document {
                  ... on PrismicLegalFootnote {
                    id
                    data {
                      copy {
                        html
                        text
                        richText
                      }
                    }
                    _previewable
                  }
                }
              }
            }
          }
          ... on PrismicAdDataBodyQuotesAndReviews {
            id
            items {
              attribution
              color
              quote {
                html
                text
                richText
              }
              link {
                url
              }
            }
            primary {
              title {
                html
                text
                richText
              }
            }
            slice_type
          }
        }
      }
    }
  }
`;

error:

Gatsby, Prismic with GraphQl query aliases error

How do I fix this issue without using aliases, I tried using aliases here:

 ... on PrismicAdDataBodyQuotesAndReviews {
            id
            items {
              attribution
              color
              quote {
                html
                text
                richText
              }
              mainLink: link {
                url
              }
            }
            primary {
              title {
                html
                text
                richText
              }
            }
            slice_type
          }

and faced the issue, that Prismic does not see this value as mainLink but as a link, then I founded that ..aliases are not supported using the previews plugin as it doesn’t have access to the GraphQL query during a preview..


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *