GraphQL requests cannot be fully executed in some cases - malformed query, insufficient access, or validation errors. For schema and query errors, refer to GraphQL’s specification https://spec.graphql.org/June2018/#sec-Errors. This section will cover validation errors, extending GraphQL’s schema
Atomic mutations
All mutations succeed, or none succeed. When sending multiple mutations in one request, and any one of them results in an error, all other mutations should be considered failed as well. In such cases, retrieved data
is only informative and should be discarded.
Error Structure¶
In case of an error, a top-level error
field will be returned by 3RPMS and will contain one or more errors. Each error will always have, at minimum, a message
field.
Message language¶
By default, error messages are in German. To see errors in English, add a Accept-Language
header to each graphql request:
Accept-Language: en
Besides german (de
) and english (en
), no other language is supported at the moment
Validation¶
Validation errors always will have the extensions.category
field set to "validation"
.
Validation errors are meant to be resolvable by users, for example, by modifying the form in your application or changing data in 3RPMS directly, and attempting again.
Forwards Compatibility
Validation messages can change, and additional validations may be added at any time. These messages must not be used in comparisons.
Argument errors¶
For errors related to input arguments, extensions.argumentPath
field will contain a path to the field that caused an error (similar to path
in GraphQL schema errors).
Request
query AvailableRooms {
inventory(filter: {
period: {
start:"2022-09-08"
end:"2022-09-08"
}
categories:["a", "b", "c"]
}) {
# ...
}
}
In this example, filter
has invalid data - a requested category (“c”) does not exist.
Response
{
"errors": [
{
"message": "Sorry, Property Category not found",
"extensions": {
"argumentPath": [
"filter",
"categories",
2
],
"category": "validation"
},
"path": [
"inventory"
],
}
]
}
extensions.argumentPath
can be followed to find the field that caused an error.
Non-argument errors¶
For validation errors that cannot be attributed to any specific input input argument, extensions.argumentPath
will not be added
Request
In this example, provided data is correct, but room cannot be updated for other reasons.
mutation CheckIn {
updateRoomStay(input:{id:"119157" check_in:"2022-09-08T16:00:00+00:00"}) {
roomStay {
check_in
check_out
}
}
}
Response
{
"errors": [
{
"message": "This reservation was cancelled",
"extensions": {
"category": "validation"
},
"path": [
"updateRoomStay"
]
}
]
}