Cannot query 2 of 11 pages with new plugin gatsby-source-prismic

Good day!
Could you please help me with migration from old to new Gatsby Prismic integaration plugin? I set up two pages, they work normally with new plugin. Now I am setting up next page. This page is template, it has 11 different pages. The problem is that 9 of 11 pages are available and work. But I can query 2 remaining pages of 11. GraphQL playground does not see them. And I have mistake:

"gatsby-source-prismic" threw an error while running the sourceNodes lifecycle:

Cannot read property 'reduce' of null

TypeError: Cannot read property 'reduce' of null

These page are available with old plugin gatsby-source-prismic-graphql. I check data in Prismic — it is identical both for problem and non-problem pages.

Hey @dmitry.d, I'll be happy to help you debug this. Could you show me an example of the code that is breaking to be able to reproduce it?

Hi, @Paulina, thank you. The query is below. I can get 9 of 11 pages of this custom type by this query. And I can query all pages of other custom type by identical query. The query:

export const query = graphql`
  query($uid: String, $lang: String) {
    allPrismicSolutionpage(filter: { uid: { eq: $uid }, lang: { eq: $lang } }) {
      edges {
        node {
          alternate_languages {
            id
            lang
            uid
            type
          }
          data {
            canonical {
              raw
            }
            metadescription {
              raw
            }
            metatitle {
              raw
            }
            body {
              ... on PrismicSolutionpageBodyHero {
                id
                slice_type
                primary {
                  buttonlink {
                    text
                  }
                  buttontext {
                    text
                  }
                  description {
                    text
                  }
                  modalctabuttonlink {
                    text
                  }
                  modalctabuttontext {
                    text
                  }
                  modalvideo {
                    link_type
                    url
                  }
                  previewimage {
                    url
                    fluid(srcSetBreakpoints: 10) {
                      aspectRatio
                      base64
                      sizes
                      src
                      srcSet
                      srcSetWebp
                      srcWebp
                    }
                    thumbnails
                  }
                  title {
                    text
                  }
                  videobuttontext {
                    text
                  }
                }
                items {
                  partnerslogo {
                    alt
                    url
                  }
                }
              }
              ... on PrismicSolutionpageBodyProjects {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
                items {
                  description {
                    raw
                  }
                  title {
                    raw
                  }
                  link {
                    url
                    link_type
                  }
                  screenshot {
                    alt
                    url
                    fluid(srcSetBreakpoints: 10) {
                      aspectRatio
                      base64
                      sizes
                      src
                      srcSet
                      srcSetWebp
                      srcWebp
                    }
                    thumbnails
                  }
                }
              }
              ... on PrismicSolutionpageBodyQuestions {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
                items {
                  content {
                    raw
                  }
                  link {
                    link_type
                    url
                  }
                  scan
                  linktext {
                    text
                  }
                  title {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyBenefits {
                id
                slice_type
                primary {
                  button {
                    text
                  }
                  buttonlink {
                    text
                  }
                  title {
                    raw
                  }
                }
                items {
                  image {
                    alt
                    url
                  }
                  text {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyFeatures {
                id
                slice_type
                primary {
                  button {
                    text
                  }
                  buttonlink {
                    text
                  }
                  title {
                    raw
                  }
                }
                items {
                  description {
                    raw
                  }
                  image {
                    alt
                    url
                  }
                  title {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyBooking {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyPlans {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
              }
            }
          }
          uid
          type
          id
          lang
        }
      }
    }
    allPrismicLayout {
      edges {
        node {
          data {
            body2 {
              ... on PrismicLayoutBody2Agencies {
                id
                slice_type
                primary {
                  buttontext {
                    text
                  }
                  description {
                    text
                  }
                  image {
                    alt
                    url
                  }
                  link {
                    link_type
                    url
                  }
                  page {
                    text
                  }
                  title {
                    text
                  }
                }
              }
              ... on PrismicLayoutBody2Plans {
                id
                slice_type
                items {
                  benefits {
                    raw
                  }
                  button {
                    raw
                  }
                  buttonlink {
                    link_type
                    url
                  }
                  buttonprice {
                    raw
                  }
                  cardtitle {
                    raw
                  }
                  description {
                    raw
                  }
                  image {
                    alt
                    url
                  }
                  type
                }
              }
            }
          }
        }
      }
    }
  }
`;

By the way, @Paulina. When I add new test pages of that custom type, I can query them by that query code.

Ok so it's only two pages that you aren't able to get, are these pages published or in draft?

They are published. And I can query them with old plugin. All 11 pages are available. But with new plugin I get only 9 from 11 pages. When I add new pages of that custom type, they are abailable.

That's very odd. Could you send me the following details so I can take a closer look?

  • The response of the query you're making
  • The URL of your repository
  • The uid of the two missing documents
1 Like

Hi, @Paulina. Thank you for helping me. The query is published here already, but I will do it again in this message. The URL of repository and uid of problem pages I will send you in direct message.

the query:

export const query = graphql`
  query($uid: String, $lang: String) {
    allPrismicSolutionpage(filter: { uid: { eq: $uid }, lang: { eq: $lang } }) {
      edges {
        node {
          alternate_languages {
            id
            lang
            uid
            type
          }
          data {
            canonical {
              raw
            }
            metadescription {
              raw
            }
            metatitle {
              raw
            }
            body {
              ... on PrismicSolutionpageBodyHero {
                id
                slice_type
                primary {
                  buttonlink {
                    text
                  }
                  buttontext {
                    text
                  }
                  description {
                    text
                  }
                  modalctabuttonlink {
                    text
                  }
                  modalctabuttontext {
                    text
                  }
                  modalvideo {
                    link_type
                    url
                  }
                  previewimage {
                    url
                    fluid(srcSetBreakpoints: 10) {
                      aspectRatio
                      base64
                      sizes
                      src
                      srcSet
                      srcSetWebp
                      srcWebp
                    }
                    thumbnails
                  }
                  title {
                    text
                  }
                  videobuttontext {
                    text
                  }
                }
                items {
                  partnerslogo {
                    alt
                    url
                  }
                }
              }
              ... on PrismicSolutionpageBodyProjects {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
                items {
                  description {
                    raw
                  }
                  title {
                    raw
                  }
                  link {
                    url
                    link_type
                  }
                  screenshot {
                    alt
                    url
                    fluid(srcSetBreakpoints: 10) {
                      aspectRatio
                      base64
                      sizes
                      src
                      srcSet
                      srcSetWebp
                      srcWebp
                    }
                    thumbnails
                  }
                }
              }
              ... on PrismicSolutionpageBodyQuestions {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
                items {
                  content {
                    raw
                  }
                  link {
                    link_type
                    url
                  }
                  scan
                  linktext {
                    text
                  }
                  title {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyBenefits {
                id
                slice_type
                primary {
                  button {
                    text
                  }
                  buttonlink {
                    text
                  }
                  title {
                    raw
                  }
                }
                items {
                  image {
                    alt
                    url
                  }
                  text {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyFeatures {
                id
                slice_type
                primary {
                  button {
                    text
                  }
                  buttonlink {
                    text
                  }
                  title {
                    raw
                  }
                }
                items {
                  description {
                    raw
                  }
                  image {
                    alt
                    url
                  }
                  title {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyBooking {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
              }
              ... on PrismicSolutionpageBodyPlans {
                id
                slice_type
                primary {
                  title {
                    raw
                  }
                }
              }
            }
          }
          uid
          type
          id
          lang
        }
      }
    }
    allPrismicLayout {
      edges {
        node {
          data {
            body2 {
              ... on PrismicLayoutBody2Agencies {
                id
                slice_type
                primary {
                  buttontext {
                    text
                  }
                  description {
                    text
                  }
                  image {
                    alt
                    url
                  }
                  link {
                    link_type
                    url
                  }
                  page {
                    text
                  }
                  title {
                    text
                  }
                }
              }
              ... on PrismicLayoutBody2Plans {
                id
                slice_type
                items {
                  benefits {
                    raw
                  }
                  button {
                    raw
                  }
                  buttonlink {
                    link_type
                    url
                  }
                  buttonprice {
                    raw
                  }
                  cardtitle {
                    raw
                  }
                  description {
                    raw
                  }
                  image {
                    alt
                    url
                  }
                  type
                }
              }
            }
          }
        }
      }
    }
  }
`;

Ok thanks for the details. We'll try it out and let you know what we find,

1 Like

@Paulina, good day. I solved the problem with two pages. There was empty content field on each problem page. Old plugin worked with this problem, and new plugin force me to find this problem. Thank you for help!

I'm glad to hear that!
Let us know if we can help you with anything else :metal: :metal:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.