Technical Docs
Ask or search…
K

User's Restrictions

Update a user's food restrictions (food preferences).
Use the profileRestrictionsUpdate mutation to update a user's food restrictions.
A list of all the available food restrictions can be retrieved using the Restrictions query.

Required Argument

Arguments
Type
Description
restrictions
[ID]
Array of restrictions ID's

Available Argument

Argument
Type
Description
replace
Boolean
If true, the profile restrictions are set to only the IDs sent in the mutation. If false, the restrictions received are added to the current ones. If this argument is not sent, by default its value will be set to True.
Vegan and vegetarian are very common use cases, for those, please set the following restrictions:
  • For vegetarian, activate the R Animal Origin (non-vegetarian) restriction. Id: UmVzdHJpY3Rpb246ZDY3NTA1MTktZTE4Zi00NWRkLTgxZWYtODAyNzk0MzYyZWRl
  • For vegan, activate the R Animal Origin (all) restriction, Id: UmVzdHJpY3Rpb246YzhmODQwMmMtYzEyNi00OWM3LWEyMzEtNWNmNjI0ZDlmNTlj

Examples

The following example adds two restrictions to the current user's profile:
Mutation
Response
mutation {
profileRestrictionsUpdate(
restrictions: [
"UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1",
"UmVzdHJpY3Rpb246ODU1ZjkzZjYtODQzOC00MTIzLTk3YzktM2U2YzU2MzllZjli"
]) {
success
}
}
{
"data": {
"profileRestrictionsUpdate": {
"success": true
}
}
}
Note that the replace argument is not defined; therefore, those will be the only two restrictions set to the current user's profile.
Validate that the restrictions are successfully updated using the My Profile query to obtain a list of restrictions currently set to the user's profile.
Query
Response
{
myProfile {
programName
restrictions{
id
name
isOnProgram
subcategory
slugname
}
}
}
{
"data": {
"myProfile": {
"programName": "Balanced Diet",
"restrictions": [
{
"id": "UmVzdHJpY3Rpb246ODU1ZjkzZjYtODQzOC00MTIzLTk3YzktM2U2YzU2MzllZjli",
"name": "Dairy",
"isOnProgram": false,
"subcategory": "Most Common",
"slugname": "dairy"
},
{
"id": "UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1",
"name": "Gluten",
"isOnProgram": false,
"subcategory": "Most Common",
"slugname": "gluten"
}
]
}
}
}
In the following example, the replace argument is set as False:
Mutation
Response
mutation {
profileRestrictionsUpdate(
restrictions: [
"UmVzdHJpY3Rpb246NDI3MDM0MTEtNDA3OC00NTkyLWE1YjctNDgxM2I2NzMwYjg3"
]
replace: false
)
{
success
}
}
{
"data": {
"profileRestrictionsUpdate": {
"success": true
}
}
}
Use the My Profile query to obtain a list of restrictions currently set to the user's profile. See that the new restriction has been added to the list of user's restrictions:
Query
Response
{
myProfile {
programName
restrictions{
id
name
isOnProgram
subcategory
slugname
}
}
}
{
"data": {
"myProfile": {
"programName": "Balanced Diet",
"restrictions": [
{
"id": "UmVzdHJpY3Rpb246NDI3MDM0MTEtNDA3OC00NTkyLWE1YjctNDgxM2I2NzMwYjg3",
"name": "Avocado",
"isOnProgram": false,
"subcategory": "Fruits and Vegetables",
"slugname": "avocado"
},
{
"id": "UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1",
"name": "Gluten",
"isOnProgram": false,
"subcategory": "Most Common",
"slugname": "gluten"
},
{
"id": "UmVzdHJpY3Rpb246ODU1ZjkzZjYtODQzOC00MTIzLTk3YzktM2U2YzU2MzllZjli",
"name": "Dairy",
"isOnProgram": false,
"subcategory": "Most Common",
"slugname": "dairy"
}
]
}
}
}