I would like to use the Enonic API not only to read data, but also to write data to the content studio (update or insert). I searched for a way to do that with Graphql and found a type of query called “mutation”. I tried this in the Enonic API but I was not able to update or insert any data. The queries that are for reading the Enonic data are enclosed in the “guillotine” tag, which is for accessing read-only data. So I tried to remove the “guillotine” tag but got the error:
“OperationNotSupported: Schema is not configured for mutations.”
Here is an example of a query for retrieving the data:
{
guillotine {
query(
contentTypes: "com.gksoftware.es.esintranet:how-to-item"
query: "pathMatch('_path', '/content/intranet/how-to-do/how-to-items', 4)"
first: 100
) {
... on com_gksoftware_es_esintranet_HowToItem {
data {
title
content
}
}
}
}
}
And here is an example of the mutation that’s trying to create new data of the same type:
in our project we do not configure any schema, but we use a tool/layer called Apollo (https://www.apollographql.com/) and we send the query to the Enonic API via this layer. The Apollo layer has a query function which accepts queries to retrieve data and it has also a mutate function which is for inserting/updating data. We would like to send a mutation to the Enonic API directly via the Apollo layer. Is this possible or do we have to configure the Enonic XP to accept mutations in the first place?
could you please provide an example of extending the schema with a custom mutation?
I tried to extend the schema but I get the error OperationNotSupported: Schema is not configured for mutations in the Graphql Playground.
The content type has two fields of type string (title and content). With this mutation, I would like to modify the content.