Mutation Examples
🚨 This is currently in early development! If you are interested in using this, please contact us at
dev@momentum.se
to learn more.
What is Mutation?
The mutation type in GraphQL is used to modify data. Similar to a post/put/patch/delete in a traditional REST API.
A mutation regulary takes an input
object with an id
field as well as fields that cover the purpose of the mutation.
All mutations must have a return field, as shown in the example below.
Id
It's possible to use an Id generated by the client for mutations of type create. If not provided by the client, an Id will be generated by the system at successful create.
Mutation Examples
Mark a message
as read by its Id:
mutation markMessageAsRead
{
markNotificationRead(input: {id: "0e628534ef0143d6adfeeb631e3a4e3a"}) {
notification{
id
}
}
}
Create price / pricing
Below follows an example for how a pricing / price can be created.
🚨 Currently we only support create pricing-type of model "pricingSimple".
mutation skapaPrisdel {
createPricing(
input: {
id: "FdJ9yhFWbXgV6dGxH48xWQXB"
refersToId: "0001b0b1786249b7a6e502e16cc0ae41"
typeId: "dc0b66b22d4545ada0576a1bf102ff9d"
startDate: "2025-01-01"
endDate: "2025-07-01"
}
) {
pricing {
id
}
errors {
... on Error {
message
report
}
}
}
}
mutation skapaPrisdelPris {
createPrice(
input: {
amount: 137.00
id: null
pricingId: "FdJ9yhFWbXgV6dGxH48xWQXB"
reasonForChange: "rättat"
validFrom: "2025-01-01T10:15:30Z"
}
) {
pricingPrice {
id
}
errors {
... on Error {
message
report
}
}
}
}
Create actorCommunication
Below follows an example for how you could create / update / remove an actors communication.
mutation createActorCommunication{
createActorCommunication(
input: {
asActorId: "002172b5r1584c7aa64b026974cfb02e"
id: "uJpG3KpgqRQRgFV7qTygQjRS",
typeId: "mobile"
value: "07000000"
}) {
actorCommunication {
id
}
errors{
...on Error{
report
message
}
}
}
}
mutation updateActorCommunication {
updateActorCommunication(
input: {
id: "uJpG3KpgqRQRgFV7qTygQjRS",
value: "07111111"
}) {
actorCommunication {
id
}
errors {
... on Error {
report
message
}
}
}
}
mutation removeActorCommunication {
removeActorCommunication(
input: {
id: "uJpG3KpgqRQRgFV7qTygQjRS"
}) {
actorCommunication {
id
}
errors {
... on Error {
report
message
}
}
}
}
Create errand
Below follows an example for how an errand of class "order" can be created, with an attached row, and the necessary information attached.
🚨 Currently we only support create errand of class "order".
mutation createErrand{
createErrand(input: {
id: "mRMtTdmbXx4RYB6jDRq69T4p123445678"
classId: "order"
refersToId: "57ef589527c44779b9af66af976edc05"
actorOrdererId: "4039d2a5c3864eebb7ed9ec5b653abfb"
})
{
errors{
...on Error{
message
report
}
}
errand{
id
}
}
}
mutation createErrandRow{
createErrandRow(input: {
id: "8f6370af47e54d30aeec1b7c98255dc7"
errandId: "mRMtTdmbXx4RYB6jDRq69T4p123445678"
refersToId: "57ef589527c44779b9af66af976edc05"
path: ["e42253c13bfa4cd0888b67d166c3e39d", "213e98160abf4e3ba1b0f4711fb1fd0a", "c2449b0ae7554f9781800049b8778b05"]
specification: "TestSpec"
})
{
errors{
...on Error{
message
report
}
}
errandRow{
id
number
errand{
number
}
}
}
}
mutation updateErrandRowKeyManagement{
updateErrandRowKeyManagement(input: {
Id: "8f6370af47e54d30aeec1b7c98255dc7"
keyManagement: {
typeId: "isHome"
}
})
{
errors{
...on Error{
message
report
}
}
errandRow{
keyManagement{
id
note
keyManagementType{
displayName
}
}
}
}
}