Gatsby: Upgrading to Gatsby 2.19.x breaks existing queries

Created on 28 Jan 2020  路  16Comments  路  Source: gatsbyjs/gatsby

Description

I'm trying to test out Gatsby Builds which requires updating to the latest Gatsby and Sharp, and it also seem we need a more current gatsby-source-contentful.

When I do this all our queries have an additional id added to the query, at each level. This breaks the queries, as an example:

Fields "items" conflict because subfields "id" conflict because they return conflicting types ID! and String. Use different aliases on the fields to fetch both if this was intentional.

Screenshot 2020-01-28 at 11 06 35

However, when I look at the source code for we don't set these IDs in our queries so they are being added automatically and then clashing.

Screenshot 2020-01-28 at 11 10 54

Environment

System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
Yarn: 1.19.1 - ~/.yarn/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
Languages:
Python: 2.7.16 - /usr/local/bin/python
Browsers:
Chrome: 79.0.3945.130
Firefox: 69.0.1
Safari: 13.0.4
npmPackages:
gatsby: 2.19.7 => 2.19.7
gatsby-image: ^2.2.7 => 2.2.39
gatsby-link: ^2.2.22 => 2.2.22
gatsby-plugin-eslint: ^2.0.4 => 2.0.5
gatsby-plugin-google-tagmanager: ^2.1.3 => 2.1.4
gatsby-plugin-i18next: ^1.1.7 => 1.1.7
gatsby-plugin-react-helmet: ^3.1.1 => 3.1.2
gatsby-plugin-react-svg: ^2.1.1 => 2.1.1
gatsby-plugin-resolve-src: ^2.0.0 => 2.0.0
gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0
gatsby-plugin-sharp: ^2.4.0 => 2.4.3
gatsby-plugin-styled-components: ^3.1.1 => 3.1.2
gatsby-source-contentful: 2.1.82 => 2.1.82
gatsby-source-filesystem: ^2.1.46 => 2.1.46
gatsby-transformer-remark: ^2.6.3 => 2.6.9
gatsby-transformer-sharp: ^2.3.0 => 2.3.13

needs reproduction bug

Most helpful comment

@afc163 Looks like you have a different issue. Many of your types implement Node interface when they shouldn't (link):

    type SiteSiteMetadataTitle implements Node {
      zh: String
      en: String
    }
    type SiteSiteMetadataDocs implements Node {
      slug: String!
      title: SiteSiteMetadataTitle!
      order: Int
    }
    type SiteSiteMetadataExamples implements Node {
      slug: String!
      title: SiteSiteMetadataTitle!
      icon: String
      order: Int
    }
    type SiteSiteMetadataNavs implements Node {
      slug: String!
      title: SiteSiteMetadataTitle!
      target: String
    }
    type SiteSiteMetadataRedirects implements Node {
      from: String!
      to: String
    }
    type SiteSiteMetadata implements Node {
      title: String!
      description: String!
      githubUrl: String!
      siteUrl: String @defaultString
      logoUrl: String
      navs: [SiteSiteMetadataNavs]
      docs: [SiteSiteMetadataDocs]
      examples: [SiteSiteMetadataExamples]
      redirects: [SiteSiteMetadataRedirects]
      showSearch: Boolean
      showChinaMirror: Boolean
      showGithubCorner: Boolean
      showLanguageSwitcher: Boolean
      showAntVProductsCard: Boolean
      playground: PlayGround
      docsearchOptions: DocsearchOptions
      versions: Json
    }

All of those types are not nodes. If you want them to be nodes you must actually provide all the fields required for nodes (id, internal, etc). See corresponding section in docs.

I bet you can reproduce this error on [email protected] as well if you run the following query in GraphiQL:

{
  site {
    siteMetadata {
      id
    }
  }
}

You see, id is a required field for any node and you do not have it for those types. So the solution for you is just to remove implements Node for all types I posted above.

All 16 comments

I suspect bug ~introduced~ exposed by https://github.com/gatsbyjs/gatsby/pull/20849 which adds ids to selection sets but there is some type mismatch happening somewhere (which I don't quite understand).

Is there way to get access to your repository so it's easier for us to reproduce?

/cc @vladar

Yeah, this is super confusing. We need a repro for this (or at least a full query and a printed schema)

I'll need to create a separate repro for this as I can't share the actual repository.

If I isolate this using GraphiQL I can query with:

query MyQuery {
  contentfulCompAccordionAcc01 {
    id
    heading
    items {
      heading
      id
      copy {
        id
        childMarkdownRemark {
          id
          html
        }
      }
    }
  }
}

And it returns:

{ "data": { "contentfulCompAccordionAcc01": { "id": "18e913da-6aa2-5b13-a66e-82d16c9aa5e0", "heading": "Chauffeur Service", "items": [ { "heading": "How can I make a Chauffeur booking?", "id": "1bd1fa4e-224f-54f8-be85-dd11e8f3a4e4", "copy": { "id": "df885e98-7841-5ff3-a969-39ff2093f9e7", "childMarkdownRemark": { "id": "0c6e9589-efb6-56d6-ad8d-ad3caeaa28b7", "html": "<p>HTML</p>" } } }, { "heading": "How can I cancel my booking?", "id": "8a9edf55-16fa-5875-b5c5-babd7f056033", "copy": { "id": "4d0b72a8-0962-5a4f-acc7-df736dd99945", "childMarkdownRemark": { "id": "53f03761-4c8c-5cf8-a265-c200811a2c51", "html": "<p>HTML</p>" } } }, { "heading": "How can I amend my booking?", "id": "74363f4c-9003-5f16-aa16-fbe3e4c37be9", "copy": { "id": "1f6c99aa-7713-5899-a65f-112d27b6bbeb", "childMarkdownRemark": { "id": "63e1b017-2ad1-5667-9cf7-603d7c089962", "html": "<p>HTML</p>" } } }, { "heading": "Will I receive confirmation once I have made a booking online?", "id": "e0b6b6b7-a9ab-5a30-86e5-9d3ffaec1a59", "copy": { "id": "08cc6ff9-9967-524c-9a96-b20955850746", "childMarkdownRemark": { "id": "c69a8c35-11bb-5174-a285-25d0bc397b0b", "html": "<p>HTML</p>" } } }, { "heading": "What will happen on the day of my journey?", "id": "7619fe70-bcd3-5047-93d0-6cf522a64c63", "copy": { "id": "de808f28-59ba-5eeb-b7de-e48a5957875b", "childMarkdownRemark": { "id": "8c55cd89-117a-5da4-b9a7-94f6deb13cfb", "html": "<p>HTML</p>" } } }, { "heading": "What if my driver is late?", "id": "1b1250f4-c806-5a2e-b535-737e9caf09a7", "copy": { "id": "f85babab-029b-57da-8f2e-8ab32c2baeea", "childMarkdownRemark": { "id": "c299b2ec-2f7b-56af-824e-e9f67b6e8a76", "html": "<p>HTML</p>" } } }, { "heading": "Can I book a one way journey only?", "id": "8967c632-5ce4-56ac-a123-a50d1d5977eb", "copy": { "id": "6def2319-bd22-5123-90ea-58625abba2c8", "childMarkdownRemark": { "id": "546dd588-638a-5f51-93e1-b98f3badaaf6", "html": "<p>HTML</p>" } } }, { "heading": "Can I book extra waiting time in the Village on the day of my journey?", "id": "b2b17610-a0ef-5b0c-825f-c743f7604e04", "copy": { "id": "cd3624fe-be48-57f1-acd6-818f6c9e6b62", "childMarkdownRemark": { "id": "66e0e980-0850-575b-8dc2-2dded1707d8c", "html": "<p>HTML</p>" } } }, { "heading": "Are there any other costs?", "id": "665f1774-b2a5-5b22-b64f-26c2c9e5a760", "copy": { "id": "8b9efcff-c0c1-5424-a1e4-7db7f4d1590e", "childMarkdownRemark": { "id": "0d595cca-5a9e-59d3-bad4-5fed1daa553a", "html": "<p>HTML</p>" } } }, { "heading": "Contact Us", "id": "7809c284-9512-5d20-903e-e09491e11a63", "copy": { "id": "002256cc-8220-53ef-aeab-18ab7e5855bf", "childMarkdownRemark": { "id": "bb05ff77-60b3-5b50-824a-22f206f6a9ba", "html": "<p>HTML</p>" } } } ] } } }

This is happening to me as well. My problem seems to be that on queries where I've aliased the contentful_id with id (as shown below) I'm now getting the conflict error.

{
  guides: allContentfulBuildGuides(filter: { type: { eq: "DIY" } }) {
    all: nodes {
      id: contentful_id
        name
        description {
          description
        }
        image {
          fluid {
            ...GatsbyContentfulFluid
          }
        }
        guide {
          file {
            url
          }
        }
      }
    }
  }

I'm also getting a "The result of this StaticQuery could not be fetched." error on a previously working query, but I can't quite seem to identify why. Before upgrading to the latest Gatsby (for Builds functionality) the query worked fine, and it's returning everything as expected within graphiql as well.

Gatsby Builds built the site this morning when I updated a production env variable on the dashboard, then when I upgraded my dependencies, with no other changes to the code, the queries broke.

Here's my repo

I can confirm this is happening too, though its unrelated to contentful:

`ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

vipspng: libpng read error
vipspng: libpng read error
vips2png: unable to write to buffer
vips2png: unable to write to buffer

129 | thank_you_page_download_file_url
130 | thank_you_page_youtube_video_id
131 | resource_button_label
132 | landing_asset_image {
133 | id
134 | alt_text
135 | localFile {
136 | id
137 | childImageSharp {
138 | id

139 | fixed(height: 248) {
| ^
140 | ...GatsbyImageSharpFixed_withWebp_noBase64
141 | }
142 | }
143 | publicURL
144 | }
145 | }
146 | mobileAsset: landing_asset_image {
147 | id
148 | alt_text
149 | localFile {`

I also started receiving errors regarding the ID a couple of hours ago:

ERROR #85925 GRAPHQL

There was an error in your GraphQL query:

Cannot return null for non-nullable field ContentfulAssetFile.id

The field "ContentfulAssetFile.id." was explicitly defined as non-nullable via the schema customization API (by yourself or a plugin/theme). This means that this field is not optional and you have to define a value. If this is not your desired behavior and you defined the schema yourself, go to "createTypes" in gatsby-node.js. If you're using a plugin/theme, you can learn more here on how to fix field types:
https://www.gatsbyjs.org/docs/schema-customization/#fixing-field-types

My gatsby-node.js has the following:

exports.createSchemaCustomization = ({ actions, schema }) => {
  const { createTypes } = actions
  createTypes([
    schema.buildObjectType({
      name: "ContentfulAssetFile",
      fields: {
        id: "String",
        url: "String",
        fileName: "String",
        contentType: "String",
      },
      interfaces: ["Node"],
    }),
  ])
...

But it doesn't seem to help.

the same thing happens to me, when I use id as an alias id:wordpress_id on my site that is in production https://recetas.eluniverso.com

You know what the solution is?

Anyone having this issue because of the id alias, please upgrade to [email protected]. The subject issue of @galvogalvo seems to be different so keeping this open (and waiting for repro to fix).

I'm able to recreate via GraphiQL with the full query, here's what happens as I add an ID (which is what happens to our queries):

conflict

This is the full query, as you can see items appears multiple times.


This is the full query

query MyQuery(
    $id: String!
    $openingHoursId: String!
    $brandOpeningHoursId: String!
    $dateStart: Date!
    $dateEnd: Date!
    $nodeLocale: String!
    $villageSlug: String
    $pageTypeSlug: String
  ) {
  page: contentfulPageTemplateBrandDetailT06(id: { eq: $id }) {
      id
      brandLink
      brandCopy
      brandReadMoreCopy {
        childMarkdownRemark {
          html
        }
      }
      phoneNumber
      emailAddress
      leaseNumber
      openStatus: flags
      closingDownCopy
      categories {
        name
        label
      }
      brandLogo: logoImage {
        code {
          code
        }
      }
      hero {
        isCondensed
        ...heroMediaQuery
      }
      village {
        name
        villageSlug: slug
        home: page_template_home_t01 {
          ...headerFooterVillage
          locale: node_locale
        }
        openingHours {
          ...villageOpeningHours
        }
        labels: label_brand_details_lab01 {
          readMoreLabel
          readLessLabel
          contactDetailsHeader
          phoneNumberLabel
          emailAddressLabel
          onlineLabel
          viewOnMapLabel
        }
      }
      content {
        __typename
        ... on Node {
          ...multipleComponents
        }
      }
      openingHours {
        ...brandOpeningHours
      }
      hideFromSearchEngine
      pageTitle
      pageDescription
      stacklaCarousel {
        code {
          code
        }
        eyebrow
        headline
        ctaLabel
        ctaUrl
      }
    }
    brandOpeningHoursExceptions: allContentfulCompOpeningHoursExceptionOph04(
      filter: {
        date: { lte: $dateEnd, gte: $dateStart }
        comp_opening_hours_boutique_oph02: {
          elemMatch: { id: { eq: $brandOpeningHoursId } }
        }
      }
    ) {
      exceptions: edges {
        node {
          date(formatString: "DD-MM-YYYY")
          openingTime
          closingTime
          closedFlag
          label
        }
      }
    }
    openingHoursExceptions: allContentfulCompOpeningHoursExceptionOph04(
      filter: {
        date: { lte: $dateEnd, gte: $dateStart }
        comp_opening_hours_village_oph01: {
          elemMatch: { id: { eq: $openingHoursId } }
        }
      }
    ) {
      exceptions: edges {
        node {
          ...contentfulOpeningHoursExceptions
        }
      }
    }
    openingHoursLabels: allContentfulLabelOpeningHoursLab04(
      filter: { node_locale: { eq: $nodeLocale } }
    ) {
      edges {
        node {
          ...contentfulOpeningHoursLabels
        }
      }
    }
    mapTranslations: allContentfulEntityPageTypeEnt06(
      filter: { instanceName: { eq: "map" }, node_locale: { eq: $nodeLocale } }
    ) {
      edges {
        node {
          nodeLocale: node_locale
          slug
        }
      }
    }
    memDaysOnboarding: contentfulCompMemDayOnb01(
      node_locale: { eq: $nodeLocale }
      village: { slug: { eq: $villageSlug } }
      pageTypes: { elemMatch: { slug: { eq: $pageTypeSlug } } }
    ) {
      ...memDaysOnboarding
    }
    allMemorableDays: allContentfulPageTemplateMemorableDaysT14(
      filter: {
        node_locale: { eq: $nodeLocale }
        village: { slug: { eq: $villageSlug } }
      }
    ) {
      edges {
        node {
          ...memDaysSlugs
        }
      }
    }
  }

  fragment heroMediaQuery on Node {
    ... on ContentfulCompHeroHer01 {
      media {
        __typename
        ... on Node {
          ... on ContentfulCompVideoVid01 {
            ...responsiveVideoQuery
          }
          ... on ContentfulEntityImageEnt02 {
            ...responsiveImageQuery
          }
        }
      }
    }
  }

  fragment headerFooterVillage on ContentfulPageTemplateHomeT01 {
    header {
      ...header
    }
    footer {
      ...footer
    }
    locale: node_locale
  }

fragment villageOpeningHours on ContentfulCompOpeningHoursVillageOph01 {
    hero {
      eyebrow
      headline
    }
    pageType {
      slug
    }
    mondayOpeningTime
    mondayClosingTime
    mondayClosedFlag
    mondayFootnoteFlag
    tuesdayOpeningTime
    tuesdayClosingTime
    tuesdayClosedFlag
    tuesdayFootnoteFlag
    wednesdayOpeningTime
    wednesdayClosingTime
    wednesdayClosedFlag
    wednesdayFootnoteFlag
    thursdayOpeningTime
    thursdayClosingTime
    thursdayClosedFlag
    thursdayFootnoteFlag
    fridayOpeningTime
    fridayClosingTime
    fridayClosedFlag
    fridayFootnoteFlag
    saturdayOpeningTime
    saturdayClosingTime
    saturdayClosedFlag
    saturdayFootnoteFlag
    sundayOpeningTime
    sundayClosingTime
    sundayClosedFlag
    sundayFootnoteFlag
    footNoteCopy {
      footNoteCopy
    }
    exceptions {
      date(formatString: "DD-MM-YYYY")
      openingTime
      closingTime
      closedFlag
      label
    }
  }

  fragment multipleComponents on Node {
    ... on ContentfulCompHeroHer01 {
      ctaLabel
      ctaUrl
      eyebrow
      headline
      ...heroMediaQuery
    }
    ... on ContentfulCompMapMap01 {
      mappedinId
    }
    ... on ContentfulCompSectionHeaderSch01 {
      eyebrow
      headline
      headerBodyCopy: bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      headerCtaLabel: ctaLabel
      headerCtaUrl: ctaUrl
      audiences: childrenContentfulCompSectionHeaderSch01AudiencesJsonNode {
        content
      }
    }
    ... on ContentfulCompAccordionAcc01 {
      heading
      items {
        heading
        copy {
          childMarkdownRemark {
            html
          }
        }
      }
    }
    ... on ContentfulCompButtonPromoInPageBpr02 {
      headline
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      ctaCopy
      ctaUrl
      external
      inPage
      roundTopEdge
      italicHeadline
      background
    }
    ... on ContentfulCompBlockFreeTextBlk02 {
      textType
      textContent {
        childMarkdownRemark {
          html
        }
      }
    }
    ... on ContentfulCompListicleLis01 {
      headline
    }
    ... on ContentfulCompImageImg01 {
      type: imageType
      image {
        ...responsiveImageQuery
      }
    }
    ... on ContentfulCompQuoteQuo01 {
      copy
      authorName
      authorTitle
    }
    ... on ContentfulCompCarouselImagesCar04 {
      eyebrow
      heading
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      background
      items {
        __typename
        ... on Node {
          ... on ContentfulCompVideoVid01 {
            ...responsiveVideoQuery
          }
          ... on ContentfulEntityImageEnt02 {
            ...responsiveImageQuery
          }
        }
      }
    }
    ... on ContentfulCompPromoCopyCtaPro01 {
      image {
        altText
        landscape {
          fixed(width: 960, height: 650, quality: 100) {
            src
            srcSet
            srcSetWebp
            srcWebp
            aspectRatio
            base64
          }
        }
      }
      headline
      bodyCopy {
        bodyCopy
      }
      ctaCopy
      ctaUrl
    }
    ... on ContentfulCompCarouselProductsCar06 {
      background
      eyebrow
      heading
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      filterProductsBy
      carouselId: contentful_id
      carouselBrand {
        brandId: contentful_id
        brandName: name
        products: comp_product_prd01 {
          ...productQuery
        }
      }
      items {
        ...productQuery
      }
      tags {
        tagId: contentful_id
        tag
        products: comp_product_prd01 {
          ...productQuery
        }
      }
    }
    ... on ContentfulCompCarouselInfoCardsCar07 {
      background
      eyebrow
      heading
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      items {
        heading
        bodyCopy {
          bodyCopy
        }
      }
    }
    ... on ContentfulCompCarouselServicesCar08 {
      background
      eyebrow
      heading
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      items {
        image {
          ...responsiveImageQuery
        }
        eyebrow
        heading
        benefit
        bodyCopy {
          bodyCopy
        }
        url
        external
      }
    }
    ... on ContentfulCompCarouselArticleCar01 {
      background
      eyebrow
      heading
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      items {
        hero {
          title
          headline
          eyebrow
          ...heroMediaQuery
        }
        heading
        published(formatString: "DD-MM-YYYY")
        slug
        pageType {
          slug
        }
        village {
          villageSlug: slug
        }
      }
    }
    ... on ContentfulCompCarouselFullBleedCar03 {
      ...car03Query
    }
    ... on ContentfulCompBlockTextCtaBlk01 {
      bodyCopyTextCta: bodyCopy
      cta1Label
      cta1Url
      cta2Label
      cta2Url
      eyebrow
      headline
    }
    ... on ContentfulCompGridHomepageGrd01 {
      eyebrow
      headline
      cards {
        image {
          altText
          portrait {
            standard: fixed(
              cropFocus: CENTER
              height: 640
              width: 480
              quality: 90
            ) {
              src
            }
            retina: fixed(
              cropFocus: CENTER
              height: 1280
              width: 960
              quality: 80
            ) {
              src
            }
          }
          landscape {
            retina: fixed(
              cropFocus: CENTER
              width: 670
              height: 670
              quality: 80
            ) {
              src
            }
          }
        }
        headline
        copy
        ctaLabel
        ctaUrl
      }
    }
    ... on ContentfulCompBulletListBul01 {
      headline
      introCopy {
        childMarkdownRemark {
          html
        }
      }
      list {
        list
      }
      secondaryCopy
      ctaLabel
      ctaUrl
    }
    ... on ContentfulCompStepsStp01 {
      locale: node_locale
      headline
      qr {
        description
        sizes(maxHeight: 309, maxWidth: 309, quality: 90) {
          src
        }
      }
      items {
        headline
        description {
          description
        }
      }
    }
    ... on ContentfulEntityEventEnt04 {
      eventPage: page_template_section_detail_t03 {
        pageType {
          slug
        }
        slug
      }
      headline
      eyebrow
      eventRunFinishDate(formatString: "D MMMM YYYY")
      eventRunStartDate(formatString: "D MMMM YYYY")
      description {
        description
      }
      dateAndTime
      location
      eventRegistrationCTA {
        headline
        bodyCopy {
          childMarkdownRemark {
            html
          }
        }
        ctaCopy
        ctaUrl
      }
      phoneNumber
      emailAddress
      leaseNumber
      title
      eventImages {
        imageType
        image {
          ...responsiveImageQuery
        }
      }
    }
    ... on ContentfulCompTabsTab01 {
      items {
        label
        url
      }
    }
    ... on ContentfulPageTemplateEditorialT08 {
      ...articleQuery
    }
    ... on ContentfulCompGridVillagesGrd04 {
      headline
    }
    ... on ContentfulCompGridPartnerCardsGrd06 {
      eyebrow
      headline
      intro {
        intro
      }
      cards {
        image {
          ...responsiveImageQuery
        }
        eyebrow
        body {
          body
        }
        url
      }
    }
    ... on ContentfulCompMenuMn01 {
      title
      eyebrow
      headline
      items {
        itemName
        media {
          file {
            url
          }
        }
      }
    }
    ... on ContentfulCompVideoVid01 {
      ...responsiveVideoQuery
    }

    ... on ContentfulCompContactDetailsCnt01 {
      headline
      phoneNumber
      phoneNumberLabel
      emailAddress
      emailAddressLabel
      viewOnMapUrl
      viewOnMapLabel
      brandLink
      brandLinkLabel
    }
    ... on ContentfulLabelBrandListLab03 {
      allCategoriesCopy
      bodyText: bodyCopy
      header
      loadMoreCTACopy
      searchNoResults
      searchPlaceholder
      searchTitle
    }
    ... on ContentfulCompLockupProductCardLku02 {
      cards {
        image {
          ...responsiveImageQuery
        }
        brand: productBrand {
          name
        }
        productDescription
        currency
        locale: node_locale
        rrpPrice
        salePrice
        villagePrice
      }
    }
    ... on ContentfulCompGridOffersGrd03 {
      eyebrow
      headline
      cards {
        eyebrow
        headline
        description {
          description
        }
        offerDetailUrl
        offerExpirationLabel
        offerRunStartDate(formatString: "D MMMM")
        offerRunFinishDate(formatString: "D MMMM YYYY")
        offerImage {
          ...heroMediaQuery
        }
      }
      loadMoreOffersCta
    }
    ... on ContentfulCompCarouselOfferCar05 {
      eyebrow
      headline
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      items {
        id: contentful_id
        eyebrow
        headline
        description {
          description
        }
        offerDetailUrl
        offerExpirationLabel
        offerRunStartDate(formatString: "D MMMM")
        offerRunFinishDate(formatString: "D MMMM YYYY")
        offerImage {
          ...heroMediaQuery
        }
      }
      ctaCopy
      ctaUrl
    }
    ... on ContentfulCompBrandTickerBrd03 {
      tickerText1 {
        tickerText1
      }
      tickerText2 {
        tickerText2
      }
      tickerText3 {
        tickerText3
      }
    }
    ... on ContentfulCompGridComboGrd05 {
      brandLabel
      articleLabel
      dineLabel
      loadMoreLabel
      eyebrow
      headline
      items {
        __typename
        ... on Node {
          ... on ContentfulPageTemplateEditorialT08 {
            hero {
              headline
              eyebrow
              ...heroMediaQuery
            }
            published(formatString: "D MMMM YYYY")
            slug
            pageType {
              slug
            }
            village {
              slug
            }
          }
          ... on ContentfulPageTemplateBrandDetailT06 {
            hero {
              headline
              eyebrow
              ...heroMediaQuery
            }
            name
            slug
            pageType {
              slug
            }
            village {
              slug
            }
          }
          ... on ContentfulPageTemplateSectionDetailT03 {
            hero {
              headline
              eyebrow
              ...heroMediaQuery
            }
            slug
            pageType {
              slug
            }
            village {
              slug
            }
            content {
              __typename
              ... on Node {
                ... on ContentfulEntityEventEnt04 {
                  eventRunStartDate(formatString: "D MMMM YYYY")
                }
              }
            }
          }
          ... on ContentfulPageTemplateRestaurantDetailT07 {
            hero {
              headline
              eyebrow
              ...heroMediaQuery
            }
            name
            slug
            pageType {
              slug
            }
            village {
              slug
            }
          }
        }
      }
    }
    ... on ContentfulCompPortraitGridGrd08 {
      eyebrow
      headline
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      promos {
        headline
        bodyCopy {
          childMarkdownRemark {
            html
          }
        }
        ctaCopy
        ctaUrl
        image {
          altText
          desktop: portrait {
            fixed(width: 507, height: 652, cropFocus: CENTER, quality: 90) {
              src
            }
          }
          mobile: landscape {
            fixed(width: 700, height: 700, cropFocus: CENTER, quality: 90) {
              src
            }
          }
        }
      }
    }
    ... on ContentfulCompMultiPromoGridGrd08 {
      eyebrow
      headline
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      offers {
        eyebrow
        headline
        description {
          description
        }
        url: offerDetailUrl
        offerExpirationLabel
        offerRunStartDate(formatString: "D MMMM")
        offerRunFinishDate(formatString: "D MMMM YYYY")
        offerImage {
          media {
            ... on ContentfulEntityImageEnt02 {
              altText
              landscape {
                fixed(width: 760, height: 460, cropFocus: CENTER, quality: 90) {
                  aspectRatio
                  height
                  src
                }
              }
            }
            ... on ContentfulCompVideoVid01 {
              videoPlaceholder: image {
                altText
                landscape {
                  fixed(
                    width: 760
                    height: 460
                    cropFocus: CENTER
                    quality: 90
                  ) {
                    aspectRatio
                    height
                    src
                  }
                }
              }
            }
          }
        }
      }
    }
    ... on ContentfulCompPromoCardCrd01 {
      superHeadline
      image {
        ...responsiveImageQuery
      }
      eyebrow
      headline
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      ctaCopy
      ctaUrl
      background
    }
    ... on ContentfulCompCarouselBrandsCar09 {
      eyebrow
      heading
      introductoryCopy {
        childMarkdownRemark {
          html
        }
      }
      backgroundImage {
        ...responsiveImageQuery
      }
      items {
        brand {
          logoImage {
            code {
              code
            }
          }
        }
        image {
          ...responsiveImageQuery
        }
        eyebrow
        summary
      }
    }
    ... on ContentfulCompMemDayDineOptionTab02 {
      headline
      tab1bodyCopy
      tab1ctaCopy
      tab1ctaUrl
      tab1eyebrow
      tab1image {
        altText
        landscape {
          fluid(maxWidth: 2500, quality: 100) {
            src
          }
        }
        portrait {
          fluid(maxWidth: 2500, quality: 100) {
            src
          }
        }
      }
      tab1tabTitle
      tab2bodyCopy
      tab2ctaCopy
      tab2ctaUrl
      tab2eyebrow
      tab2image {
        altText
        landscape {
          fluid(maxWidth: 2500, quality: 100) {
            src
          }
        }
        portrait {
          fluid(maxWidth: 1800, quality: 100) {
            src
          }
        }
      }
      tab2tabTitle
    }
  }

  fragment brandOpeningHours on ContentfulCompOpeningHoursBoutiqueOph02 {
    mondayOpeningTime
    mondayClosingTime
    mondayClosedFlag
    mondayFootnoteFlag
    tuesdayOpeningTime
    tuesdayClosingTime
    tuesdayClosedFlag
    tuesdayFootnoteFlag
    wednesdayOpeningTime
    wednesdayClosingTime
    wednesdayClosedFlag
    wednesdayFootnoteFlag
    thursdayOpeningTime
    thursdayClosingTime
    thursdayClosedFlag
    thursdayFootnoteFlag
    fridayOpeningTime
    fridayClosingTime
    fridayClosedFlag
    fridayFootnoteFlag
    saturdayOpeningTime
    saturdayClosingTime
    saturdayClosedFlag
    saturdayFootnoteFlag
    sundayOpeningTime
    sundayClosingTime
    sundayClosedFlag
    sundayFootnoteFlag
    footNoteCopy {
      footNoteCopy
    }
  }

  fragment contentfulOpeningHoursExceptions on ContentfulCompOpeningHoursExceptionOph04 {
    date(formatString: "DD-MM-YYYY")
    openingTime
    closingTime
    closedFlag
    label
  }

  fragment contentfulOpeningHoursLabels on ContentfulLabelOpeningHoursLab04 {
    brandHeading
    villageHeading
    dineHeading
    thisWeekHeading
    nextWeekHeading
    followingWeekHeading
    mondayLabel
    tuesdayLabel
    wednesdayLabel
    thursdayLabel
    fridayLabel
    saturdayLabel
    sundayLabel
    closedLabel
    brandRibbonLabel
    villageRibbonLabel
    dineRibbonLabel
    moreOpeningHoursCtaCopy
    januaryLabel
    februaryLabel
    marchLabel
    mayLabel
    juneLabel
    julyLabel
    augustLabel
    septemberLabel
    octoberLabel
    novemberLabel
    decemberLabel
  }

  fragment memDaysOnboarding on ContentfulCompMemDayOnb01 {
    background {
      desktop: landscape {
        file {
          url
        }
      }
      mobile: portrait {
        file {
          url
        }
      }
    }
    confirmation {
      cta1Label
      eyebrow
      headline
    }
    forwarding {
      eyebrow
      headline
    }
    intro {
      bodyCopy
      cta1Label
      eyebrow
      headline
    }
    questions {
      answers {
        answer
        bgColor
        cirColor
        image {
          portrait {
            file {
              url
              details {
                image {
                  height
                  width
                }
              }
            }
          }
        }
        sentence
        slug
        thumbnail {
          portrait {
            fixed(height: 432, width: 432, quality: 100, cropFocus: CENTER) {
              src
            }
          }
        }
      }
      eyebrow
      format
      headline
      overviewEyebrow
      overviewHeadline
    }
    triggerIcon {
      code {
        code
      }
    }
    village {
      villageSlug: slug
      home: page_template_home_t01 {
        header {
          logoIcon {
            code {
              code
            }
          }
        }
      }
    }
  }

  fragment memDaysSlugs on ContentfulPageTemplateMemorableDaysT14 {
    answers {
      slug
    }
    pageType {
      slug
    }
    village {
      villageSlug: slug
    }
  }

  fragment responsiveVideoQuery on ContentfulCompVideoVid01 {
    name
    videoPortrait: portrait
    videoLandscape: landscape
    videoPlaceholder: image {
      ...responsiveImageQuery
    }
  }

  fragment responsiveImageQuery on ContentfulEntityImageEnt02 {
    altText
    portrait {
      fluid(maxWidth: 1500, quality: 100) {
        ...fluidImage
      }
    }
    landscape {
      fluid(maxWidth: 2500, quality: 100) {
        ...fluidImage
      }
    }
  }

  fragment header on ContentfulCompHeaderHdr01 {
    navigation {
      navItems: links {
        label
        link: url
        external
      }
    }
    languageGroup {
      languages {
        label
        locale
      }
    }
    signinGroup {
      headline
      signinLabel
      signinUrl
      signupLabel
      signupUrl
      accountLabel
      accountUrl
      logoutLabel
      logoutUrl
    }
    logos {
      code {
        code
      }
    }
    notification {
      bodyCopy {
        childMarkdownRemark {
          html
        }
      }
      cookieHash: updatedAt(formatString: "YYMMDDHHmmss")
      cookieTimeout
      ctaLabel
      ctaUrl
      dismiss
      headline
    }
  }

  fragment footer on ContentfulCompFooterFtr01 {
    navItems: navigations {
      category: label
      links {
        label
        link: url
        external
      }
    }
    copy {
      copy
    }
    logos {
      code {
        code
      }
    }
    copyright: copyRight
    instagramLink
    facebookLink
    twitterLink
    youTubeLink
    pinterestLink
    tripAdvisorLink
    buttonPromo {
      headline
      bodyCopy {
        bodyCopy
      }
      ctaCopy
      ctaUrl
    }
  }

  fragment productQuery on ContentfulCompProductPrd01 {
    productId: contentful_id
    date(formatString: "x")
    salePrice
    rrpPrice
    productDescription
    villagePrice
    currency
    image {
      ...responsiveImageQuery
    }
    tags {
      tagId: contentful_id
      tag
    }
    brand: productBrand {
      brandId: contentful_id
      brandName: name
      village {
        villageId: contentful_id
        villageLocale: node_locale
      }
      contentful_id
    }
  }

fragment car03Query on ContentfulCompCarouselFullBleedCar03 {
    eyebrow
    heading
    bodyCopy {
      childMarkdownRemark {
        html
      }
    }
    items {
      ... on ContentfulPageTemplateEditorialT08 {
        hero {
          title
          headline
          eyebrow
          ...heroMediaQuery
        }
        slug
        pageType {
          slug
        }
        village {
          storyVillageSlug: slug
        }
      }
      ... on ContentfulPageTemplateSectionDetailT03 {
        hero {
          title
          headline
          eyebrow
          ...heroMediaQuery
        }
        slug
        pageType {
          slug
        }
        village {
          storyVillageSlug: slug
        }
      }
    }
  }

  fragment articleQuery on ContentfulPageTemplateEditorialT08 {
    id
    locale: node_locale
    slug
    heading
    village {
      villageSlug: slug
    }
    pageType {
      slug
      name: instanceName
    }
    publishDate: published(formatString: "D MMMM YYYY")
    hero {
      headline
      ...heroMediaQuery
    }
  }

  fragment fluidImage on ContentfulFluid {
    src
    srcSet
    srcWebp
    srcSetWebp
    sizes
    aspectRatio
    base64
  }

@galvogalvo Your query contains this:

items {
        id: contentful_id

That's where you get a conflict when adding the id field. Have you tried [email protected]? It prevents auto-adding id when there is an alias, so in theory, it should be working for you.

@vladar It looks like the id conflict is clashing on the auto added ones, as well, not just the id: contentful_id. I've tried with 2.19.9 and the same problem happens.

This is unlikely because it clashes only when types of id field are different (you see: String vs ID). I need to reproduce it to fix. Can you prepare a repro? It doesn't have to use your contentful schema, this fails before actual network requests

Reproduce:

$ git clone [email protected]:antvis/gatsby-theme-antv.git -b Gatsby-2.19-bug
$ cd gatsby-theme-antv
$ yarn
$ yarn start
 ERROR #85925  GRAPHQL

There was an error in your GraphQL query:

Cannot return null for non-nullable field SiteSiteMetadata.id.

The field "SiteSiteMetadata.id." was explicitly defined as non-nullable via the schema customization API (by yourself or a plugin/theme). This means that this field is not optional and you have to define a value. If this is not your desired behavior and you defined the schema yourself, go to "createTypes" in gatsby-node.js. If you're using a plugin/theme, you can learn more here on how to fix field types:
https://www.gatsbyjs.org/docs/schema-customization/#fixing-field-types

   1 | query usersafc163ProjectsgatsbyThemeAntvAntvgatsbyThemeAntvsitetemplatesexampleTsx1557978011 {
   2 |   site {
   3 |     id
   4 |     siteMetadata {
>  5 |       id
     |       ^
   6 |       title
   7 |       githubUrl
   8 |       examples {
   9 |         id
  10 |         slug
  11 |         icon
  12 |         title {
  13 |           id
  14 |           zh
  15 |           en

Confirmed that https://github.com/gatsbyjs/gatsby/issues/20849 breaks GraphQL query, [email protected] is broken and [email protected] works fine.

@afc163 Looks like you have a different issue. Many of your types implement Node interface when they shouldn't (link):

    type SiteSiteMetadataTitle implements Node {
      zh: String
      en: String
    }
    type SiteSiteMetadataDocs implements Node {
      slug: String!
      title: SiteSiteMetadataTitle!
      order: Int
    }
    type SiteSiteMetadataExamples implements Node {
      slug: String!
      title: SiteSiteMetadataTitle!
      icon: String
      order: Int
    }
    type SiteSiteMetadataNavs implements Node {
      slug: String!
      title: SiteSiteMetadataTitle!
      target: String
    }
    type SiteSiteMetadataRedirects implements Node {
      from: String!
      to: String
    }
    type SiteSiteMetadata implements Node {
      title: String!
      description: String!
      githubUrl: String!
      siteUrl: String @defaultString
      logoUrl: String
      navs: [SiteSiteMetadataNavs]
      docs: [SiteSiteMetadataDocs]
      examples: [SiteSiteMetadataExamples]
      redirects: [SiteSiteMetadataRedirects]
      showSearch: Boolean
      showChinaMirror: Boolean
      showGithubCorner: Boolean
      showLanguageSwitcher: Boolean
      showAntVProductsCard: Boolean
      playground: PlayGround
      docsearchOptions: DocsearchOptions
      versions: Json
    }

All of those types are not nodes. If you want them to be nodes you must actually provide all the fields required for nodes (id, internal, etc). See corresponding section in docs.

I bet you can reproduce this error on [email protected] as well if you run the following query in GraphiQL:

{
  site {
    siteMetadata {
      id
    }
  }
}

You see, id is a required field for any node and you do not have it for those types. So the solution for you is just to remove implements Node for all types I posted above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hobochild picture hobochild  路  3Comments

signalwerk picture signalwerk  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

benstr picture benstr  路  3Comments

totsteps picture totsteps  路  3Comments