Modified and deleted content items
How to get content items based on last modified changes.
With Optimizely Graph, you can query for updates to content items. This can be useful to get snapshots of content items based on a datetime delta using the cursor. It can also be used as a signal to know when a static site should be re-generated. The hit count with total
can be used to know whether a site has fully synchronized.
You can get the first five modified documents updated since 2023-05-24T11:00
with this Optimizely Graph query:
{
Content(
limit: 5,
where: { _modified: { gte: "2023-05-24T11:00" } }
orderBy: {_ranking: DOC}
) {
total
items {
_modified
ContentLink {
GuidValue
}
}
}
}
You can get all the modified documents updated since 2023-05-24T11:00
with this Optimizely Graph query using cursor:
{
Content(
limit: 5,
where: { _modified: { gte: "2023-05-24T11:00" } }
orderBy: {_ranking: DOC}
cursor: ""
) {
total
items {
_modified
ContentLink {
GuidValue
}
}
cursor
}
}
You can get the next batches of the modified content by adding the cursor
value to the cursor argument.
Deleted documents
You can query in Optimizely Graph for content items that were deleted. This is only possible by using HMAC authentication and adding the header cg-include-deleted
with the value true
. Each content item that is deleted will have the value of _modified
updated and marked as deleted with _deleted: true.
With the single key, Optimizely only lets you retrieve published content items, so the _deleted
values are null
.
You can use the following Optimizely Graph query to get all modified content items, including deleted items, since 2023-05-20T11:00
:
{
Content(
limit: 5,
where: { _modified: { gte: "2023-05-20T11:00" } }
orderBy: {_ranking: DOC}
cursor: ""
) {
total
items {
_deleted
ContentLink {
GuidValue
}
}
cursor
}
}
You know that an item was deleted by looking at the _deleted
value. When the value is true
, the content was deleted. A response could look like the following and note that there are three deleted items in this batch.
{
"data": {
"Content": {
"total": 13,
"items": [
{
"_deleted": null,
"ContentLink": {
"GuidValue": "64ea99b4-fe38-43b7-a993-20ceb333861a"
}
},
{
"_deleted": true,
"ContentLink": {
"GuidValue": "c8ab68cf-7231-43ca-a376-ca4cac2e06d8"
}
},
{
"_deleted": null,
"ContentLink": {
"GuidValue": "582ecd34-e0bc-4d14-b467-8255b04d2b53"
}
},
{
"_deleted": true,
"ContentLink": {
"GuidValue": "c64c5afb-a538-4245-92d8-55625527cfd3"
}
},
{
"_deleted": true,
"ContentLink": {
"GuidValue": "4eaece75-3e53-440b-8dec-eb8d6d6895e0"
}
}
],
"cursor": "FGluY2x1ZGVfY29udGV4dF91dWlkDnF1ZXJ5VGhlbkZldGNoAhZua3ZXUUFvMFRuU2plVUJmX1pfTlNnAAAAAAAADwQWTG5QWjFjRXFURnVpZktRd0d0MkZGQRZua3ZXUUFvMFRuU2plVUJmX1pfTlNnAAAAAAAADwUWTG5QWjFjRXFURnVpZktRd0d0MkZGQQ=="
}
},
"extensions": {
"correlationId": "92151285-aae3-4d7f-93e7-a009d390f18e",
"cost": 9,
"costSummary": [
"Content(9) = limit(5) + fields(2) + basicFilter(1)*2"
]
}
}
Updated 8 months ago