Skip to content

Latest commit

 

History

History
171 lines (140 loc) · 3.17 KB

20_DataObject_Mutations.md

File metadata and controls

171 lines (140 loc) · 3.17 KB

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.

Mutation grid

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

Also check out the Pimcore's data type documentation.

  • Boolean Select
  • Checkbox
  • Country
  • Countries (Multiselect)
  • Date
  • DateTime
  • Email
  • External Image
  • Field Collections
  • Firstname
  • Gender
  • Geopoint
  • Image
  • ImageGallery
  • Input
  • 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
  • Textarea
  • Time
  • Wysiwyg

Supported mutation operators

  • IfEmpty
  • Locale Switcher
  • ...

See the overview page 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) {
    success
    message
    output(defaultLanguage: "de") {
      id      
      creationDate
      fullpath
      title(language: "en")
    }
  }
}

Response:

{
  "data": {
    "createNews": {
      "success": true,
      "message": "object created: 98",
      "output": {
        "id": "98",
        "creationDate": 1559642310,
        "fullpath": "/tests/testcreate2/testcreate27",
        "title": null
      }
    }
  }
}

Update Object

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"}) {
    success
    output {
      modificationDate
    }
  }
}

Response:

{
  "data": {
    "updateNews": {
      "success": true,
      "output": {
        "modificationDate": 1559746654
      }
    }
  }
}

Delete Object

Request:

mutation {
  deleteBlogCategory(id: 37) {
    success
    message
  }
}

Response:

{
  "data": {
    "deleteBlogCategory": {
      "success": true,
      "message": ""
    }
  }
}

Extend Data Object mutations

It is possible to add custom mutation data types and mutation operators. For details see detail documentation pages:

More Examples

See following list for more examples with data object mutations: