Skip to content

Commit

Permalink
Updated mutations page
Browse files Browse the repository at this point in the history
  • Loading branch information
mcop1 committed Nov 28, 2024
1 parent c2237b5 commit 5ae0449
Showing 1 changed file with 23 additions and 63 deletions.
86 changes: 23 additions & 63 deletions doc/10_GraphQL/07_Mutation/20_DataObject_Mutations.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,29 @@
# DataObject Mutations

>TODO: Align this with the new demo as soon as reasonable content is available.
* Create Objects
* Update Objects
* Delete Objects

In addition, you can turn on mutations to modify assets, create object folders and on on.
Data object mutations are used to create, update and delete data objects, documents, assets and translations.
Keep in mind that for all kinds of mutations you need the `Write` permission and the mutation itself needs to be enabled in the configuration.
Please be aware, that not all operations are supported for all data types.


![Mutation grid](../../img/graphql/mutation_grid.png)

Note that for `Create` and `Update` operate you can query the updated data using the same request.
Keep in mind that for all kinds of mutations you need the `Write` permission.

## Supported Mutation Datatypes

![Mutation grid](../../img/graphql/mutation_grid.png)

Also check out the Pimcore's [data type documentation](https://pimcore.com/docs/6.x/Development_Documentation/Objects/Object_Classes/Data_Types/index.html).

* Boolean Select
* Checkbox
* Country
* Countries (Multiselect)
* Date
* DateTime
* Email
* External Image
* Field Collections
* Firstname
* Gender
* Geopoint
* Image
* ImageGallery
* Input
* Input Quantity Value
* Language
* Lastname
* Link
* Many-to-One Relation
* Many-to-Many Relation
* Many-to-Many Object Relation
* Advanced Many-to-Many Relation
* Advanced Many-to-Many Object Relation
* Multiselect
* Newsletter Active
* Newsletter Confirmed
* Numeric
* Quantity Value
* Select
* Slider
* Table
* Textarea
* Time
* Wysiwyg
Also check out the Pimcore's [data type documentation](https://pimcore.com/docs/6.x/Development_Documentation/Objects/Object_Classes/Data_Types/index.html).
For supported mutation datatypes please check the `DataObjectMutationFieldConfigGenerator` folder in `src/GraphQL/`.

## Supported Mutation Operators

See [operators section](../08_Operators/README.md) for more details.

## Create Object

TBD: do we need an extra workspace permission for that ? (in addition to write which would be only used for updates)

Request:
```
mutation {
createNews(parentId: 66, key: "testcreate27", published: false) {
createNews(parentId: 429, key: "news_created_by_gql", published: false) {
success
message
output(defaultLanguage: "de") {
Expand All @@ -81,16 +37,16 @@ mutation {
```

Response:
```
```json
{
"data": {
"createNews": {
"success": true,
"message": "object created: 98",
"message": "object created: 1196",
"output": {
"id": "98",
"creationDate": 1559642310,
"fullpath": "/tests/testcreate2/testcreate27",
"id": "1196",
"creationDate": 1732785597,
"fullpath": "/Product Data/Accessories/lights/indicator lights/chevrolet-bel air-tail lights/news_created_by_gql",
"title": null
}
}
Expand All @@ -105,23 +61,29 @@ Updates german title and short text and returns the modification date.
Request:
```
mutation {
updateNews(id: 773, defaultLanguage: "de", input: {title: "german TITLE", shortText: "new short text"}) {
updateNews(id: 1196, defaultLanguage: "de", input: {
title: "german TITLE",
shortText: "new short text"
}
) {
success
output {
modificationDate
modificationDate,
title
}
}
}
```

Response:
```
```json
{
"data": {
"updateNews": {
"success": true,
"output": {
"modificationDate": 1559746654
"modificationDate": 1732785648,
"title": "german TITLE"
}
}
}
Expand All @@ -133,7 +95,7 @@ Response:
Request:
```
mutation {
deleteBlogCategory(id: 37) {
deleteNews(id: 1196) {
success
message
}
Expand All @@ -144,7 +106,7 @@ Response:
```
{
"data": {
"deleteBlogCategory": {
"deleteNews": {
"success": true,
"message": ""
}
Expand All @@ -153,8 +115,6 @@ Response:
```




## Extend Data Object Mutations
It is possible to add custom mutation data types and mutation operators. For details see detail documentation
pages:
Expand Down

0 comments on commit 5ae0449

Please sign in to comment.