Back to Content Management API
templateUpdate
Updates a template.
Arguments
- Name
input
- Type
- TemplateCreateInput!
- Description
An object.
title
:String
disjunctive
:Boolean
rules
:[TemplateRuleInput]
sectionIds
:[ID!]
Returns
- Name
Template.*
- Type
- Template
- Description
Any requested field from the Template object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
fragment TemplateResourceFields on TemplateResource {
title
disjunctive
rules {
field
operator
value
}
}
mutation TemplateUpdate($input: TemplateUpdateInput!) {
templateUpdate(input: $input) {
...TemplateResourceFields
}
}
`;
const variables = {
"input": {
"id": "YOUR-TEMPLATE-ID",
"title": "YOUR-TEMPLATE-TITLE",
"disjunctive": false,
"rules": [
{
"field": "YOUR-FIELD",
"operator": "YOUR-OPERATOR",
"value": "YOUR-VALUE"
}
],
"sectionIds": ["YOUR-SECTION-ID"]
}
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"templateUpdate": {
"title": "YOUR-TEMPLATE-TITLE",
"disjunctive": false,
"rules": [
{
"field": "YOUR-FIELD",
"operator": "YOUR-OPERATOR",
"value": "YOUR-VALUE"
}
]
}
}
}