Back to Content Management API
siteSettingsPatch
Applies JSON Patch-style operations to the site settings and seo, or replaces the favicon, without resending the whole object. Read the current revisionId from siteSettings and pass it as expectedRevisionId. If the settings changed since then, the mutation fails with a conflict error instead of overwriting the newer edit.
Supply at least one of settingsPatch, seoPatch, or favicon. Paths are JSON Pointers relative to the field being patched, such as /header/announcementBar/text in settingsPatch or /title in seoPatch. Use a TEST operation to assert a value before changing it. After patching, seo must be a valid SEO object or null.
Arguments
- Name
input- Type
- SiteSettingsPatchInput!
- Description
An object.
id:ID!The ID of the site settings.expectedRevisionId:ID!The currentrevisionId.settingsPatch:[SiteSettingsPatchOperationInput!]Operations onsettings, applied in order. Each hasop: SiteSettingsPatchOperationType!(ADD,REMOVE,REPLACE, orTEST),path: String!, andvalue: JSON.seoPatch:[SiteSettingsPatchOperationInput!]Operations onseo, in the same format.favicon:StringThe favicon URL. Passnullto remove it.
Returns
- Name
SiteSettings.*- Type
- SiteSettings!
- Description
Any requested field from the SiteSettings object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN',
})
const query = `
mutation SiteSettingsPatch($input: SiteSettingsPatchInput!) {
siteSettingsPatch(input: $input) {
id
revisionId
settings
}
}
`
const variables = {
input: {
id: 'site-settings-id',
expectedRevisionId: 'current-revision-id',
settingsPatch: [
{
op: 'REPLACE',
path: '/header/announcementBar/text',
value: 'Free shipping over $50',
},
],
},
}
const response = await packClient.fetch(query, { variables })
console.log(response.data)
Response
{
"data": {
"siteSettingsPatch": {
"id": "site-settings-id",
"revisionId": "new-revision-id",
"settings": {
"header": {
"announcementBar": {
"text": "Free shipping over $50"
}
}
}
}
}
}