hygraph-examples icon indicating copy to clipboard operation
hygraph-examples copied to clipboard

Content stage only showing `Draft` & not `Published`

Open SanyamPunia opened this issue 2 years ago • 2 comments

I've published two documents on the CMS and I'm fetching + rendering them inside my Next.js application.

I want to render only those documents which are in the published stage, and not in draft.

When I fetch the content using GraphQL in the API playground, the stage attribute is always in the draft stage, even after I published it.


GraphQL query

query getBlogStage{
  portfolioBlogs {
    id
    title
    stage
  }
}

Output

image

In the specific content, it's also showing the published stage

image

I would appreciate if anyone could find possible fix for this.

SanyamPunia avatar Apr 18 '23 04:04 SanyamPunia

Yeah, I am also stuck with the same issue. Please share a possible fix

TontofourK avatar Apr 18 '23 04:04 TontofourK

Hey @SanyamPunia @TontofourK

Have you tried updating the query to include a stage argument? Something like this should work for you...

query getBlogStage {
  portfolioBlogs(stage: PUBLISHED) {
    id
    title
    stage
  }
}

This is because the "default stage" is DRAFT. You can alternatively update the Playground to use the Published stage. This essentially does the above for playground purposes but you should always set the stage in the query.

CleanShot 2023-05-15 at 12 34 03@2x

You can also set your access tokens to have a specific stage scoped which is what I do in 99.9% of the time.

notrab avatar May 15 '23 11:05 notrab