Techdocs
Search…
Using Mutations
The mutation methods allow you to change the session on Nosto's end and request personalized recommendations. Each mutation operation allows you to update the cart and customer information, all while giving you access to recommendations for the sessions.
Any mobile experience built atop Nosto's GraphQL API should use the mutation operation as it feeds data into to the recommender systems while providing personalization data.
_The given example updates the customer's information and his current shopping cart contents sends an event that the customer is currently viewing product number 400 and requests the personalized recommendations associated with a given product for him aliased as front_page_1.
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
mutation MySession {
6
updateSession(id: "ad8f0d0e-1156-4df2-b385-10e03f8f8a44",
7
params: {
8
customer: {
9
firstName: "John"
10
lastName: "Doe"
11
marketingPermission: true
12
customerReference: "319330"
13
}
14
event: {
15
type: VIEWED_PRODUCT
16
target: "400"
17
}
18
cart: {
19
items: [
20
{
21
productId: "100",
22
skuId: "100-1",
23
name: "#100",
24
unitPrice: 199,
25
priceCurrencyCode: "EUR",
26
quantity: 1
27
},
28
{
29
productId: "200",
30
skuId: "200-1",
31
name: "#200",
32
unitPrice: 299,
33
priceCurrencyCode: "EUR",
34
quantity: 2
35
},
36
{
37
productId: "300",
38
skuId: "300-1",
39
name: "#300",
40
unitPrice: 399,
41
priceCurrencyCode: "EUR",
42
quantity: 3
43
},
44
]
45
}
46
}) {
47
id,
48
recos (preview: false, image: VERSION_8_400_400) {
49
front_page_1: related(productIds: ["525834092559"],
50
relationship: VIEWED_TOGETHER
51
params: {
52
minProducts: 3,
53
maxProducts: 5
54
}) {
55
primary {
56
productId
57
}
58
}
59
}
60
}
61
}
62
EOF
Copied!
Last modified 1yr ago
Copy link