Dave
Dave

Reputation: 11

Contentful graphQL: filtering content by publishDate

Hi my team is developing functionality to allow content editors to preview pages with content that will is schedule to be published at a future date. See screenshot.

I have not seen much documentation on how to do this. All the documentation I have found relies on gatsby. Also note that some of the content might be added through content templates in contentful into the page, so the user will be clicking into the content template to change content and then set the publish date for that particlular content.

These are the only article is all I found:

https://monkishtypist.com/blog/filter-contentful-content-by-date

contentful getEntries published data only

Does anyone have any details on how to filter by publishDate?

Thanks

Just investigating

Upvotes: 0

Views: 204

Answers (1)

iweir
iweir

Reputation: 21

Difficult to say for sure. I'm not familiar with contentful but skimming their api docs this part feels like it would be helpful:

Each GraphQL type is derived from a content type and the Asset type will also have a system-defined sys field. This field exposes meta-information about the content.

type Sys {
  id: String!
  spaceId: String!
  environmentId: String!
  publishedAt: DateTime
  firstPublishedAt: DateTime
  publishedVersion: Int
}

filtering based on the publishedAt field in the Sys type appears to be a path to the solution you're looking for. Like I said without being able to see the schema for Contentful I'm not sure if they have a way to do that within the request or alternatively you can do it on the request response.

Upvotes: 0

Related Questions