-
Hello, I don't know if the question has already been asked/answered, i don't find any traces of it. type Mutation {
createTokens(
emails: [String!]!
): CreateTokensPayload!
}
type Token {
data: String!
email: String!
}
type CreateTokensPayload {
tokens: [Token]
} If everything work fine, i should have this result: {
"data": {
"createTokens": [
{
"data": "sze",
"email": "[email protected]"
},
{
"data": "azead",
"email": "[email protected]"
},
{
"data": "adzadzd",
"email": "[email protected]"
}
]
}
} If an error occur only on email {
"errors": [
{
"message": "error message",
"locations": [
{
"line": 6,
"column": 7
}
],
"path": [
"createTokens",
1,
"email"
]
}
],
"data": {
"createTokens": [
{
"data": "sze",
"email": "[email protected]"
},
null,
{
"data": "adzadzd",
"email": "[email protected]"
}
]
}
} I don't find a way to do this with Ariadne, any suggestions? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
The part of errors spec you are referring to is about errors during data retrieval. This means that error for invalid e-mail should be raised in resolver for For example you {
"tokens": [
{"data": "valid data", "email": "[email protected]", "error": None},
{"data": "valid data", "email": None, "error": "Invalid email!"},
{"data": "valid data", "email": "[email protected]", "error": None},
]
} With email resolver like this: def resolve_email(obj, *_):
if obj.get("error"):
raise ValueError(obj["error"])
return obj["email"] |
Beta Was this translation helpful? Give feedback.
The part of errors spec you are referring to is about errors during data retrieval. This means that error for invalid e-mail should be raised in resolver for
Token
'semail
field.For example you
createTokens
mutation could return this data:With email resolver like this: