Skip to content

Custom errors management with partial results #1016

Answered by rafalp
tvallois asked this question in Q&A
Discussion options

You must be logged in to vote

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's email field.

For example you createTokens mutation could return this data:

{
    "tokens": [
        {"data": "valid data", "email": "valid@example.com", "error": None},
        {"data": "valid data", "email": None, "error": "Invalid email!"},
        {"data": "valid data", "email": "valid2@example.com", "error": None},
    ]
}

With email resolver like this:

def resolve_email(obj, *_):
    if obj.get("error"):
        raise ValueError(obj["error"])

    return obj["email"]

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@rafalp
Comment options

@tvallois
Comment options

@rafalp
Comment options

@tvallois
Comment options

@tvallois
Comment options

Answer selected by rafalp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants