Skip to content

GraphQL publicationState doesn’t appear to pass down to components? #9463

@gaz-99

Description

@gaz-99

I posted this on the strapi forum and was asked to create a bug report:

I’m not sure if this is expected behaviour or i’m setting up my queries wrong but I have the following collections:

Static Pages (has a dynamic zone called PageContent)

Sites (a site has a relation to many offers)

Offers (an offer belongs to only one site)

I then have a custom component which has two string properties and then a repeatable component of site relations.

all data for all collections is in DRAFT state.

when i use the following query in the graphql playground:

query($pageID: String!, $publicationState: PublicationState!) {
  staticPages(publicationState:$publicationState, where: { PageID: $pageID }) {
    Title,
    Heading,
    HeadingImage{
      url,
      alternativeText
    },
    PageContent {
      ... on ComponentStaticComponentsSitesList {
        __typename,
        Heading,
        Description,
        Sites {
          site {
            Name,
            Slug,
            Logo {
              url,
              alternativeText
            },
            Rating,
            offers{
              Title,
              OfferLink
            }
          }
        }
      }
    }
  }
}

with these query parameters

{
  "publicationState": "PREVIEW",
  "pageID": "Home"
}

everything populates except the offers array, it just returns empty, however if i PUBLISH the items in Offers and Sites (Static Pages can be left in DRAFT), everything populates as i would expect.

Is this the normal behaviour? Is there a way to get the offers relation to populate when in DRAFT state?

I feel like the publicationState must not be passing into the sub selections hence why it returns empty.

System

  • Node.js version: 14.15.1
  • NPM version:
  • Strapi version: v3.4.4
  • Database: MongoDB
  • Operating system: Windows

Metadata

Metadata

Assignees

Labels

issue: feature requestIssue suggesting a new featureseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: core:databaseSource is core/database packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

Type

No type

Projects

Status

Archived

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions