Cms: GraphQL returns an error with site "*"

Created on 16 Sep 2020  路  12Comments  路  Source: craftcms/cms

Description

With a long query with (site: "*"), GraphQL returns this error:
"Invalid site param: [*, *, *, *, *, *, *, *, *, *, *, *]"

For some reason, CraftCMS do some eager loading for multiSiteContent but results in a site array with multiple * instead of one.

You already have my composer.json/lock and database from this issue: https://github.com/craftcms/cms/issues/6844

Here is the query:

query FetchPage($uri: [String]) {
  pageEntry: entry(site: "*", uri: $uri) {
    ...PageFragment
    __typename
  }
}

fragment PageFragment on EntryInterface {
  id
  title
  level
  uri
  url
  postDate
  expiryDate
  dateUpdated
  ... on blogPost_blogPost_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    ...BlogPostFragment
    __typename
  }
  ... on blogPostList_blogPostList_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    __typename
  }
  ... on job_job_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    ...JobFragment
    __typename
  }
  ... on jobsList_jobsList_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    ...JobsListFragment
    __typename
  }
  ... on pressRelease_pressRelease_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    ...PressReleaseFragment
    __typename
  }
  ... on pressReleasesList_pressReleasesList_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    ...PressReleasesListFragment
    __typename
  }
  ... on home_home_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  ... on hotel_hotel_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  ... on page_page_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  ... on discovery_discovery_Entry {
    disablePage
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  ... on offer_offer_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  ... on room_room_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  ... on space_space_Entry {
    alternateUri
    siteId: currentSiteId
    seoDescription
    seoTitle
    seoRobotFollow
    seoRobotIndex
    seoAlternateUrl
    seoOpenGraphImage {
      ...ImageFragment
      __typename
    }
    blocks {
      ...BlocksFragment
      __typename
    }
    __typename
  }
  __typename
}

fragment BlocksFragment on NeoBlockInterface {
  ...MultiSiteContentFragment
  ...SingleSiteContentFragment
  ...BaseBlockFragment
  __typename
}

fragment BaseBlockFragment on NeoBlockInterface {
  ...BannerFragment
  ...BannerCarouselFragment
  ...BrandsFragment
  ...CitiesFragment
  ...BookingMaskFragment
  ...InstagramFeedFragment
  ...RoomCarouselFragment
  ...LocationContactFragment
  ...RatingsFragment
  ...IconsWithTextFragment
  ...ListingFragment
  ...EntriesLineUpFragment
  ...PhotoFragment
  ...PhotoCarouselFragment
  ...TableFragment
  ...ListTableFragment
  ...ListTablesFragment
  ...MapFragment
  ...EntriesShowCaseFragment
  ...FreeTextFragment
  ...DisplayTopicsFragment
  ...TextWithMenuFragment
  ...StatisticFragment
  ...ImageWithQuoteFragment
  ...RouteFragment
  ...ImageWithTextFragment
  ...ImageWithTextListFragment
  ...TimelineFragment
  ...PresentationFragment
  __typename
}

fragment BannerFragment on blocks_banner_BlockType {
  id
  background {
    ... on background_image_BlockType {
      id
      image {
        ...ImageFragment
        __typename
      }
      __typename
    }
    ... on background_video_BlockType {
      id
      video {
        ...VideoFragment
        __typename
      }
      __typename
    }
    __typename
  }
  overlay {
    ... on overlay_overlay_BlockType {
      id
      backgroundColor
      htmlContent
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ImageFragment on AssetInterface {
  id
  url
  width
  height
  ... on amazonS3_Asset {
    title: altText
    animated
    animatedIconFallback {
      id
      url
      width
      height
      ... on amazonS3_Asset {
        title: altText
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}

fragment VideoFragment on videoField_Video {
  title
  url
  embed
  __typename
}

fragment BannerCarouselFragment on blocks_bannerCarousel_BlockType {
  id
  callToAction {
    ...LinkFragment
    __typename
  }
  banners: children {
    ... on blocks_banner_BlockType {
      ...BannerFragment
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment LinkFragment on linkitField_Linkit {
  url
  text
  openNewWindow
  ... on Entry_Linkit {
    entry {
      id
      uri
      title
      __typename
    }
    __typename
  }
  ... on Category_Linkit {
    category {
      id
      uri
      __typename
    }
    __typename
  }
  ... on Asset_Linkit {
    asset {
      id
      url
      filename
      __typename
    }
    __typename
  }
  __typename
}

fragment BrandsFragment on blocks_brands_BlockType {
  id
  blockPostDate
  blockExpiryDate
  __typename
}

fragment BookingMaskFragment on blocks_bookingMask_BlockType {
  id
  travelClickLanguage
  travelClickCurrentId
  blockPostDate
  blockExpiryDate
  __typename
}

fragment CitiesFragment on blocks_cities_BlockType {
  id
  title: blockTitle
  cities {
    id
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment InstagramFeedFragment on blocks_instagramFeed_BlockType {
  id
  blockTitle
  hashtag
  blockPostDate
  blockExpiryDate
  __typename
}

fragment RoomCarouselFragment on blocks_roomCarousel_BlockType {
  id
  rooms {
    ... on room_room_Entry {
      id
      title
      uri
      shortDescription
      pictures {
        ...ImageFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment LocationContactFragment on blocks_locationContact_BlockType {
  id
  blockTitle
  shortDescription
  mapPin {
    ...ImageFragment
    __typename
  }
  mapZoom
  location {
    ... on hotel_hotel_Entry {
      id
      title
      prefix: titlePrefix
      fullTitle
      geolocation {
        ...GeolocationFragment
        __typename
      }
      address {
        ... on address_BlockType {
          street
          city
          province
          zip
          country
          __typename
        }
        __typename
      }
      phones {
        ... on phones_BlockType {
          phoneLabel
          phoneLink {
            ...LinkFragment
            __typename
          }
          __typename
        }
        __typename
      }
      __typename
    }
    ... on discovery_discovery_Entry {
      id
      title
      geolocation {
        ...GeolocationFragment
        __typename
      }
      address {
        ... on address_BlockType {
          street
          city
          province
          zip
          country
          __typename
        }
        __typename
      }
      phones {
        ... on phones_BlockType {
          phoneLabel
          phoneLink {
            ...LinkFragment
            __typename
          }
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
  callToAction {
    ...LinkFragment
    __typename
  }
  contactLink {
    ... on contactLink_link_BlockType {
      id
      sectionTitle
      label
      entryLink {
        ...LinkFragment
        __typename
      }
      __typename
    }
    __typename
  }
  emails {
    ... on emails_email_BlockType {
      id
      address {
        ...LinkFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment GeolocationFragment on addressField_Address {
  lat
  lng
  __typename
}

fragment RatingsFragment on blocks_ratings_BlockType {
  id
  blockTitle
  providerRatings {
    ... on providerRatings_BlockType {
      id
      rating
      provider
      __typename
    }
    __typename
  }
  userReviews {
    ... on userReviews_BlockType {
      id
      reviewTitle
      reviewerName
      reviewMessage
      stars
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment IconsWithTextFragment on blocks_iconsWithText_BlockType {
  id
  blockTitle
  brandColorThemed
  limitOneRowOnMobile
  descriptionWithLink
  callToAction {
    ...LinkFragment
    __typename
  }
  brand {
    ... on brand_Category {
      id
      background: iconBrandBackground {
        ...ImageFragment
        __typename
      }
      __typename
    }
    __typename
  }
  icons: children {
    ... on blocks_iconWithText_BlockType {
      id
      icon {
        ...ImageFragment
        __typename
      }
      iconTitle: iconTitleChoice {
        ... on iconTitleChoice_text_BlockType {
          id
          text
          __typename
        }
        ... on iconTitleChoice_link_BlockType {
          id
          callToAction {
            ...LinkFragment
            __typename
          }
          __typename
        }
        __typename
      }
      descriptionWithLink
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ListingFragment on blocks_listing_BlockType {
  id
  blockTitle
  listing {
    ... on listing_BlockType {
      id
      text: item
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment EntriesLineUpFragment on blocks_entriesLineUp_BlockType {
  id
  blockTitle
  descriptionWithLink
  lineUpEntries {
    ...TileEntryFragment
    __typename
  }
  limitOneRowOnMobile
  anchorId
  blockPostDate
  blockExpiryDate
  __typename
}

fragment TileEntryFragment on EntryInterface {
  id
  title
  uri
  ... on discovery_discovery_Entry {
    ...DiscoveryTileEntryFragment
    __typename
  }
  ... on room_room_Entry {
    ...RoomTileEntryFragment
    __typename
  }
  ... on offer_offer_Entry {
    ...OfferTileEntryFragment
    __typename
  }
  ... on space_space_Entry {
    ...SpaceTileEntryFragment
    __typename
  }
  ... on blogPost_blogPost_Entry {
    ...BlogPostEntryFragment
    __typename
  }
  __typename
}

fragment DiscoveryTileEntryFragment on discovery_discovery_Entry {
  disablePage
  pictures {
    ...ImageFragment
    __typename
  }
  shortDescription
  distance
  isFavorite: isfavorite
  discoveryLinks {
    ... on discoveryLinks_link_BlockType {
      id
      callToAction {
        ...LinkFragment
        __typename
      }
      __typename
    }
    __typename
  }
  overrideLink {
    ...LinkFragment
    __typename
  }
  __typename
}

fragment RoomTileEntryFragment on room_room_Entry {
  pictures {
    ...ImageFragment
    __typename
  }
  shortDescription
  __typename
}

fragment OfferTileEntryFragment on offer_offer_Entry {
  pictures: offerImage {
    ...ImageFragment
    __typename
  }
  descriptionWithLink
  offersLinks {
    ... on offersLinks_link_BlockType {
      callToAction {
        ...LinkFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockTitle
  imageOverlayMessage: offerImageOverlayMessage
  bulletPoint {
    ... on bulletPoint_BlockType {
      id
      text
      __typename
    }
    __typename
  }
  bannerBigText
  bannerSmallText
  __typename
}

fragment SpaceTileEntryFragment on space_space_Entry {
  pictures {
    ...ImageFragment
    __typename
  }
  shortDescription
  capacity
  __typename
}

fragment BlogPostEntryFragment on blogPost_blogPost_Entry {
  id
  title
  uri
  description
  image: blogBannerImage {
    ...ImageFragment
    __typename
  }
  cities {
    ... on city_Category {
      id
      title
      __typename
    }
    __typename
  }
  blogTags {
    id
    title
    __typename
  }
  author: blogAuthor {
    ... on author_author_Entry {
      id
      title
      image: authorPicture {
        ...ImageFragment
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}

fragment PhotoFragment on blocks_photo_BlockType {
  id
  picture {
    ...ImageFragment
    __typename
  }
  description: descriptionWithLink
  __typename
}

fragment PhotoCarouselFragment on blocks_photoCarousel_BlockType {
  id
  title: blockTitle
  photos: children {
    ... on blocks_photo_BlockType {
      ...PhotoFragment
      __typename
    }
    __typename
  }
  themed
  blockPostDate
  blockExpiryDate
  __typename
}

fragment TableFragment on blocks_table_BlockType {
  id
  blockTitle
  tableHeaders {
    ... on tableHeaders_BlockType {
      id
      header
      __typename
    }
    __typename
  }
  tableRows {
    ... on tableRows_BlockType {
      id
      linkedEntry {
        id
        uri
        __typename
      }
      row {
        ... on row_textValue_BlockType {
          id
          text
          __typename
        }
        ... on row_booleanValue_BlockType {
          id
          boolean
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ListTableFragment on blocks_listTable_BlockType {
  id
  title: blockTitle
  description: freeText
  rows: listTableRows {
    ... on listTableRows_BlockType {
      id
      title: rowTitle
      value: rowValue {
        ... on rowValue_rowText_BlockType {
          __typename
          id
          text
        }
        ... on rowValue_rowLink_BlockType {
          __typename
          id
          callToAction {
            ...LinkFragment
            __typename
          }
        }
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ListTablesFragment on blocks_listTables_BlockType {
  id
  tables: children {
    ... on blocks_listTable_BlockType {
      ...ListTableFragment
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment MapFragment on blocks_map_BlockType {
  id
  title: blockTitle
  cities {
    id
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment EntriesShowCaseFragment on blocks_entriesShowCase_BlockType {
  id
  blockTitle
  showCaseEntries {
    ...TileEntryFragment
    __typename
  }
  callToAction {
    ...LinkFragment
    __typename
  }
  city {
    ... on city_Category {
      id
      cityNameIcon {
        ...ImageFragment
        __typename
      }
      icon {
        ...ImageFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment FreeTextFragment on blocks_freeText_BlockType {
  id
  brandColorThemed
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment FreeTextMatrix on freeTextMatrix_MatrixField {
  ... on freeTextMatrix_text_BlockType {
    id
    freeText
    __typename
  }
  ... on freeTextMatrix_divider_BlockType {
    id
    align
    __typename
  }
  ... on freeTextMatrix_link_BlockType {
    id
    link: entrylink {
      ...LinkFragment
      __typename
    }
    style
    appendCharacter
    __typename
  }
  ... on freeTextMatrix_links_BlockType {
    id
    firstLink {
      ...LinkFragment
      __typename
    }
    secondLink {
      ...LinkFragment
      __typename
    }
    linksStyle
    appendCharacter
    __typename
  }
  ... on freeTextMatrix_html_BlockType {
    id
    embedded
    __typename
  }
  __typename
}

fragment DisplayTopicsFragment on blocks_displayTopics_BlockType {
  id
  title: blockTitle
  descriptionWithLink
  topics: children {
    ... on blocks_topic_BlockType {
      id
      title: blockTitle
      picture {
        ...ImageFragment
        __typename
      }
      descriptionWithLink
      callToAction {
        ...LinkFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment TextWithMenuFragment on blocks_textWithMenu_BlockType {
  id
  title: blockTitle
  image: backgroundImage {
    ...ImageFragment
    __typename
  }
  sections: faqSections {
    ... on faqSections_BlockType {
      id
      label
      freeTextMatrix {
        ...FreeTextMatrix
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment StatisticFragment on blocks_statistic_BlockType {
  id
  blockTitle
  statistics: statisticEntries {
    ... on statisticEntries_statistic_BlockType {
      id
      value: displayValue
      description
      details
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ImageWithQuoteFragment on blocks_imageWithQuote_BlockType {
  id
  image {
    ...ImageFragment
    __typename
  }
  video {
    ...VideoFragment
    __typename
  }
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  imagePosition
  blockPostDate
  blockExpiryDate
  __typename
}

fragment RouteFragment on blocks_route_BlockType {
  id
  title: blockTitle
  sections: menuSections {
    ... on menuSections_BlockType {
      id
      label
      icon {
        ...ImageFragment
        __typename
      }
      freeTextMatrix {
        ...FreeTextMatrix
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ImageWithTextFragment on blocks_imageWithText_BlockType {
  id
  verticalTextAlignment
  imagePosition
  image {
    ...ImageFragment
    __typename
  }
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  brand {
    ... on brand_Category {
      id
      title
      icon: iconBrand {
        ...ImageFragment
        __typename
      }
      background: iconBrandBackground {
        ...ImageFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment ImageWithTextListFragment on blocks_imageWithTextList_BlockType {
  id
  title: blockTitle
  children {
    ... on blocks_imageWithText_BlockType {
      ...ImageWithTextFragment
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment TimelineFragment on blocks_timeline_BlockType {
  id
  blockPostDate
  blockExpiryDate
  picture {
    ...ImageFragment
    __typename
  }
  timeline {
    ... on timeline_item_BlockType {
      id
      date
      title: blockTitle
      description
      __typename
    }
    __typename
  }
  __typename
}

fragment PresentationFragment on blocks_presentation_BlockType {
  id
  backgroundImage {
    ...ImageFragment
    __typename
  }
  icon {
    ...ImageFragment
    __typename
  }
  title: blockTitle
  subtitle: blockSubtitle
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment MultiSiteContentFragment on blocks_multiSiteContent_BlockType {
  id
  multiSiteContent(site: "*") {
    id
    ... on multiSiteContent_multiSiteContent_Entry {
      id
      title
      blocks {
        ...BaseBlockFragment
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}

fragment SingleSiteContentFragment on blocks_singleSiteContent_BlockType {
  id
  singleSiteContent {
    id
    ... on singleSiteContent_singleSiteContent_Entry {
      id
      title
      blocks {
        ...BaseBlockFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blockPostDate
  blockExpiryDate
  __typename
}

fragment BlogPostFragment on blogPost_blogPost_Entry {
  description
  image: blogBannerImage {
    ...ImageFragment
    __typename
  }
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  cities {
    ... on city_Category {
      id
      title
      __typename
    }
    __typename
  }
  blogTags {
    id
    title
    __typename
  }
  author: blogAuthor {
    ... on author_author_Entry {
      id
      title
      image: authorPicture {
        ...ImageFragment
        __typename
      }
      __typename
    }
    __typename
  }
  blogPromotions {
    ... on blogPromotions_BlockType {
      title: sectionTitle
      promotions {
        ... on promotions_promotionEntry_BlockType {
          id
          title: promotionTitle
          description
          image {
            ...ImageFragment
            __typename
          }
          callToAction {
            id
            uri
            __typename
          }
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}

fragment JobFragment on job_job_Entry {
  active
  postExpiryDate
  employer
  image: careerBannerImage {
    ...ImageFragment
    __typename
  }
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  city {
    ... on city_Category {
      id
      title
      uri
      __typename
    }
    __typename
  }
  place {
    ... on hotel_hotel_Entry {
      id
      title
      fullTitle
      uri
      __typename
    }
    ... on discovery_discovery_Entry {
      id
      title
      uri
      __typename
    }
    __typename
  }
  applyBox {
    ... on applyBox_BlockType {
      id
      paragraph
      email {
        ...LinkFragment
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}

fragment JobsListFragment on jobsList_jobsList_Entry {
  image: careerBannerImage {
    ...ImageFragment
    __typename
  }
  __typename
}

fragment PressReleaseFragment on pressRelease_pressRelease_Entry {
  image: pressReleaseBanner {
    ...ImageFragment
    __typename
  }
  freeTextMatrix {
    ...FreeTextMatrix
    __typename
  }
  city {
    ... on city_Category {
      id
      title
      province
      __typename
    }
    __typename
  }
  __typename
}

fragment PressReleasesListFragment on pressReleasesList_pressReleasesList_Entry {
  minimumYear
  image: pressReleaseBanner {
    ...ImageFragment
    __typename
  }
  __typename
}

Additional info

  • Craft version: 3.5.9 and 3.5.10.1
  • PHP version: 7.3.18
  • Database driver & version: PostgreSQL 12.4
  • Plugins & versions:
    Amazon S3 | 1.2.11
    Neo | 2.8.8
    Super Table | 2.6.2
bug

All 12 comments

If I disable eager loading directly in the GraphQL code, it works fine. Would it be possible to include the option to disable eager loading for GraphQL?
Thanks!

@andris-sevcenko Not able to reproduce this with a much simpler multi-site query, FWIW.

@brandonkelly @andris-sevcenko I was able to reproduce the error with a much simpler query:

{
  entries {
    id
    ... on home_home_Entry {
      blocks {
        ...BlockFragment
      }
    }
    ... on pages_pages_Entry {
      blocks {
        ...BlockFragment
      }
    }
  }
}

fragment BlockFragment on MatrixBlockInterface {
  ... on blocks_entryBlock_BlockType {
    entries(site: "*") {
      id
      title
    }
  }
}

There is only a matrix field with 1 block with an Entries field and the matrix field is on two entry types. Then you call the entries with (site: "*") on the two entry types and it gives this error:

{
  "errors": [
    {
      "debugMessage": "Invalid site param: [*, *]",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "entries"
      ]
    }
  ],
  "data": {
    "entries": null
  }
}

I thinks it's perhaps the array_merge_recursive on the _traverseAndExtractRules method (ElementQueryConditionBuilder.php) which will merge the values and if it encounters the same value multiple times, it will merge it in an array instead of just keeping one value.

OK yeah I鈥檓 able to reproduce now. @andris-sevcenko if you go with Happy Lager, and create a new entry type within the News section called newArticle, and include the Article Body field in its field layout, you can reproduce with this query:

{
  entries {
    id
    ... on news_article_Entry {
      articleBody {
        ...BlockFragment
      }
    }
    ... on news_newArticle_Entry {
       articleBody {
        ...BlockFragment
      }
    }
  }
}

fragment BlockFragment on MatrixBlockInterface {
  ... on articleBody_image_BlockType {
    image(site: "*") {
      id
      title
    }
  }
}

(You don鈥檛 even need to create a second site.)

@andris-sevcenko There is still an error with your cleanup method:

{
  "errors": [
    {
      "debugMessage": "Invalid site param: [*]",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "pageEntry"
      ]
    }
  ],
  "data": {
    "pageEntry": null
  }
}

It's because of the method site with this if ($value === '*')

Ah, true. I feel like this should be handled outside of the GraphQL layer, though, as it doesn't need to know about specific special cases for element queries.

@andris-sevcenko I updated to the latest Craft develop (commit e3e68e048be323186238a94b12f81398a1c56baf) with the new eager-loading plans and tried to run the same query above and I get this error:

yii\base\ErrorException Object
(
    [message:protected] => Undefined offset: 0
    [string:Exception:private] => 
    [code:protected] => 8
    [file:protected] => C:\Projects\test\api\vendor\craftcms\cms\src\fields\BaseRelationField.php
    [line:protected] => 655
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [function] => handleError
                    [type] => ->
                    [class] => craft\web\ErrorHandler
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\web\ErrorHandler.php
                    [line] => 76
                    [params] => Array
                        (
                            [code] => ???
                            [message] => ???
                            [file] => ???
                            [line] => ???
                        )

                    [args] => Array
                        (
                            [code] => ???
                            [message] => ???
                            [file] => ???
                            [line] => ???
                        )

                )

            [1] => Array
                (
                    [function] => handleError
                    [type] => ->
                    [class] => craft\web\ErrorHandler
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\fields\BaseRelationField.php
                    [line] => 655
                    [params] => Array
                        (
                            [code] => ???
                            [message] => ???
                            [file] => ???
                            [line] => ???
                            [3] => ???
                        )

                    [args] => Array
                        (
                            [code] => ???
                            [message] => ???
                            [file] => ???
                            [line] => ???
                            [3] => ???
                        )

                )

            [2] => Array
                (
                    [function] => getEagerLoadingMap
                    [type] => ->
                    [class] => craft\fields\Assets
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\base\Element.php
                    [line] => 1134
                    [params] => Array
                        (
                            [sourceElements] => ???
                        )

                    [args] => Array
                        (
                            [sourceElements] => ???
                        )

                )

            [3] => Array
                (
                    [function] => eagerLoadingMap
                    [type] => ::
                    [class] => craft\base\Element
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\elements\Entry.php
                    [line] => 584
                    [params] => Array
                        (
                            [sourceElements] => ???
                            [handle] => ???
                        )

                    [args] => Array
                        (
                            [sourceElements] => ???
                            [handle] => ???
                        )

                )

            [4] => Array
                (
                    [function] => eagerLoadingMap
                    [type] => ::
                    [class] => craft\elements\Entry
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\services\Elements.php
                    [line] => 1982
                    [params] => Array
                        (
                            [sourceElements] => ???
                            [handle] => ???
                        )

                    [args] => Array
                        (
                            [sourceElements] => ???
                            [handle] => ???
                        )

                )

            [5] => Array
                (
                    [function] => _eagerLoadElementsInternal
                    [type] => ->
                    [class] => craft\services\Elements
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\services\Elements.php
                    [line] => 1952
                    [params] => Array
                        (
                            [elementType] => ???
                            [elementsBySite] => ???
                            [with] => ???
                        )

                    [args] => Array
                        (
                            [elementType] => ???
                            [elementsBySite] => ???
                            [with] => ???
                        )

                )

            [6] => Array
                (
                    [function] => eagerLoadElements
                    [type] => ->
                    [class] => craft\services\Elements
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\elements\db\ElementQuery.php
                    [line] => 2882
                    [params] => Array
                        (
                            [elementType] => ???
                            [elements] => ???
                            [with] => ???
                        )

                    [args] => Array
                        (
                            [elementType] => ???
                            [elements] => ???
                            [with] => ???
                        )

                )

            [7] => Array
                (
                    [function] => _createElements
                    [type] => ->
                    [class] => craft\elements\db\EntryQuery
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\elements\db\ElementQuery.php
                    [line] => 1455
                    [params] => Array
                        (
                            [rows] => ???
                        )

                    [args] => Array
                        (
                            [rows] => ???
                        )

                )

            [8] => Array
                (
                    [function] => populate
                    [type] => ->
                    [class] => craft\elements\db\EntryQuery
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\elements\db\ElementQuery.php
                    [line] => 1500
                    [params] => Array
                        (
                            [rows] => ???
                        )

                    [args] => Array
                        (
                            [rows] => ???
                        )

                )

            [9] => Array
                (
                    [function] => one
                    [type] => ->
                    [class] => craft\elements\db\EntryQuery
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\gql\base\ElementResolver.php
                    [line] => 49
                    [params] => Array
                        (
                            [db] => ???
                        )

                    [args] => Array
                        (
                            [db] => ???
                        )

                )

            [10] => Array
                (
                    [function] => resolveOne
                    [type] => ::
                    [class] => craft\gql\base\ElementResolver
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 781
                    [params] => Array
                        (
                            [source] => ???
                            [arguments] => ???
                            [context] => ???
                            [resolveInfo] => ???
                        )

                    [args] => Array
                        (
                            [source] => ???
                            [arguments] => ???
                            [context] => ???
                            [resolveInfo] => ???
                        )

                )

            [11] => Array
                (
                    [function] => resolveOrError
                    [type] => ->
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 739
                    [params] => Array
                        (
                            [fieldDef] => ???
                            [fieldNode] => ???
                            [resolveFn] => ???
                            [source] => ???
                            [context] => ???
                            [info] => ???
                        )

                    [args] => Array
                        (
                            [fieldDef] => ???
                            [fieldNode] => ???
                            [resolveFn] => ???
                            [source] => ???
                            [context] => ???
                            [info] => ???
                        )

                )

            [12] => Array
                (
                    [function] => resolveField
                    [type] => ->
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 473
                    [params] => Array
                        (
                            [parentType] => ???
                            [source] => ???
                            [fieldNodes] => ???
                            [path] => ???
                        )

                    [args] => Array
                        (
                            [parentType] => ???
                            [source] => ???
                            [fieldNodes] => ???
                            [path] => ???
                        )

                )

            [13] => Array
                (
                    [function] => executeFields
                    [type] => ->
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 349
                    [params] => Array
                        (
                            [parentType] => ???
                            [source] => ???
                            [path] => ???
                            [fields] => ???
                        )

                    [args] => Array
                        (
                            [parentType] => ???
                            [source] => ???
                            [path] => ???
                            [fields] => ???
                        )

                )

            [14] => Array
                (
                    [function] => executeOperation
                    [type] => ->
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 309
                    [params] => Array
                        (
                            [operation] => ???
                            [rootValue] => ???
                        )

                    [args] => Array
                        (
                            [operation] => ???
                            [rootValue] => ???
                        )

                )

            [15] => Array
                (
                    [function] => GraphQL\Executor\{closure:C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php:308-310}
                    [type] => ->
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Promise\Adapter\SyncPromiseAdapter.php
                    [line] => 59
                    [params] => Array
                        (
                            [resolve] => ???
                            [0] => ???
                        )

                    [args] => Array
                        (
                            [resolve] => ???
                            [0] => ???
                        )

                )

            [16] => Array
                (
                    [function] => create
                    [type] => ->
                    [class] => GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 310
                    [params] => Array
                        (
                            [resolver] => ???
                        )

                    [args] => Array
                        (
                            [resolver] => ???
                        )

                )

            [17] => Array
                (
                    [function] => doExecute
                    [type] => ->
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\Executor\Executor.php
                    [line] => 166
                    [params] => Array
                        (
                        )

                    [args] => Array
                        (
                        )

                )

            [18] => Array
                (
                    [function] => promiseToExecute
                    [type] => ::
                    [class] => GraphQL\Executor\Executor
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\GraphQL.php
                    [line] => 148
                    [params] => Array
                        (
                            [promiseAdapter] => ???
                            [schema] => ???
                            [ast] => ???
                            [rootValue] => ???
                            [contextValue] => ???
                            [variableValues] => ???
                            [operationName] => ???
                            [fieldResolver] => ???
                        )

                    [args] => Array
                        (
                            [promiseAdapter] => ???
                            [schema] => ???
                            [ast] => ???
                            [rootValue] => ???
                            [contextValue] => ???
                            [variableValues] => ???
                            [operationName] => ???
                            [fieldResolver] => ???
                        )

                )

            [19] => Array
                (
                    [function] => promiseToExecute
                    [type] => ::
                    [class] => GraphQL\GraphQL
                    [file] => C:\Projects\test\api\vendor\webonyx\graphql-php\src\GraphQL.php
                    [line] => 85
                    [params] => Array
                        (
                            [promiseAdapter] => ???
                            [schema] => ???
                            [source] => ???
                            [rootValue] => ???
                            [context] => ???
                            [variableValues] => ???
                            [operationName] => ???
                            [fieldResolver] => ???
                            [validationRules] => ???
                        )

                    [args] => Array
                        (
                            [promiseAdapter] => ???
                            [schema] => ???
                            [source] => ???
                            [rootValue] => ???
                            [context] => ???
                            [variableValues] => ???
                            [operationName] => ???
                            [fieldResolver] => ???
                            [validationRules] => ???
                        )

                )

            [20] => Array
                (
                    [function] => executeQuery
                    [type] => ::
                    [class] => GraphQL\GraphQL
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\services\Gql.php
                    [line] => 480
                    [params] => Array
                        (
                            [schema] => ???
                            [source] => ???
                            [rootValue] => ???
                            [context] => ???
                            [variableValues] => ???
                            [operationName] => ???
                            [fieldResolver] => ???
                            [validationRules] => ???
                        )

                    [args] => Array
                        (
                            [schema] => ???
                            [source] => ???
                            [rootValue] => ???
                            [context] => ???
                            [variableValues] => ???
                            [operationName] => ???
                            [fieldResolver] => ???
                            [validationRules] => ???
                        )

                )

            [21] => Array
                (
                    [function] => executeQuery
                    [type] => ->
                    [class] => craft\services\Gql
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\controllers\GraphqlController.php
                    [line] => 165
                    [params] => Array
                        (
                            [schema] => ???
                            [query] => ???
                            [variables] => ???
                            [operationName] => ???
                            [debugMode] => ???
                        )

                    [args] => Array
                        (
                            [schema] => ???
                            [query] => ???
                            [variables] => ???
                            [operationName] => ???
                            [debugMode] => ???
                        )

                )

            [22] => Array
                (
                    [function] => actionApi
                    [type] => ->
                    [class] => craft\controllers\GraphqlController
                    [file] => C:\Projects\test\api\vendor\yiisoft\yii2\base\InlineAction.php
                    [line] => 57
                    [params] => Array
                        (
                        )

                    [args] => Array
                        (
                        )

                )

            [23] => Array
                (
                    [function] => call_user_func_array:{C:\Projects\test\api\vendor\yiisoft\yii2\base\InlineAction.php:57}
                    [file] => C:\Projects\test\api\vendor\yiisoft\yii2\base\InlineAction.php
                    [line] => 57
                    [params] => Array
                        (
                            [4294967295] => ???
                            [0] => ???
                        )

                    [type] => ::
                    [args] => Array
                        (
                            [4294967295] => ???
                            [0] => ???
                        )

                )

            [24] => Array
                (
                    [function] => runWithParams
                    [type] => ->
                    [class] => yii\base\InlineAction
                    [file] => C:\Projects\test\api\vendor\yiisoft\yii2\base\Controller.php
                    [line] => 180
                    [params] => Array
                        (
                            [params] => ???
                        )

                    [args] => Array
                        (
                            [params] => ???
                        )

                )

            [25] => Array
                (
                    [function] => runAction
                    [type] => ->
                    [class] => craft\controllers\GraphqlController
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\web\Controller.php
                    [line] => 189
                    [params] => Array
                        (
                            [id] => ???
                            [params] => ???
                        )

                    [args] => Array
                        (
                            [id] => ???
                            [params] => ???
                        )

                )

            [26] => Array
                (
                    [function] => runAction
                    [type] => ->
                    [class] => craft\controllers\GraphqlController
                    [file] => C:\Projects\test\api\vendor\yiisoft\yii2\base\Module.php
                    [line] => 528
                    [params] => Array
                        (
                            [id] => ???
                            [params] => ???
                        )

                    [args] => Array
                        (
                            [id] => ???
                            [params] => ???
                        )

                )

            [27] => Array
                (
                    [function] => runAction
                    [type] => ->
                    [class] => craft\web\Application
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\web\Application.php
                    [line] => 285
                    [params] => Array
                        (
                            [route] => ???
                            [params] => ???
                        )

                    [args] => Array
                        (
                            [route] => ???
                            [params] => ???
                        )

                )

            [28] => Array
                (
                    [function] => runAction
                    [type] => ->
                    [class] => craft\web\Application
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\web\Application.php
                    [line] => 588
                    [params] => Array
                        (
                            [route] => ???
                            [params] => ???
                        )

                    [args] => Array
                        (
                            [route] => ???
                            [params] => ???
                        )

                )

            [29] => Array
                (
                    [function] => _processActionRequest
                    [type] => ->
                    [class] => craft\web\Application
                    [file] => C:\Projects\test\api\vendor\craftcms\cms\src\web\Application.php
                    [line] => 264
                    [params] => Array
                        (
                            [request] => ???
                        )

                    [args] => Array
                        (
                            [request] => ???
                        )

                )

            [30] => Array
                (
                    [function] => handleRequest
                    [type] => ->
                    [class] => craft\web\Application
                    [file] => C:\Projects\test\api\vendor\yiisoft\yii2\base\Application.php
                    [line] => 386
                    [params] => Array
                        (
                            [request] => ???
                            [skipSpecialHandling] => ???
                        )

                    [args] => Array
                        (
                            [request] => ???
                            [skipSpecialHandling] => ???
                        )

                )

            [31] => Array
                (
                    [function] => run
                    [type] => ->
                    [class] => craft\web\Application
                    [file] => C:\Projects\test\api\web\index.php
                    [line] => 42
                    [params] => Array
                        (
                        )

                    [args] => Array
                        (
                        )
                )
        )
)

I simplified to query to replicate the error:

query FetchPage($uri: [String]) {
  pageEntry: entry(site: "*", uri: $uri) {
    ... on home_home_Entry {
      seoOpenGraphImage {
        id
        __typename
      }
    }
    ... on blogPost_blogPost_Entry {
      seoOpenGraphImage {
        id
        __typename
      }
    }
    __typename
  }
}

seoOpenGraphImage is an asset field and the problem seems to arise when you query the same field two times on different entry types.
In Services/Elements.php line 1982, the $filteredElements is an empty array because of array_filter($elements, $plan->when). The $elements variable contains the Home entry, but the $plan->when wants a blog post entry.

If I replace with this line:

                $map = count($filteredElements) > 0
                    ? $elementType::eagerLoadingMap($filteredElements, $plan->handle)
                    : null;

The query works fine

@smcyr Should be good now. Thanks for helping look into this.

Craft 3.5.12 is out now with that fix.

Was this page helpful?
0 / 5 - 0 ratings