Skip to content

Alternative error reporting #343

Open
@t1

Description

@t1

Clients that are used to REST services can easily use GraphQL just as if it was a REST endpoint that requires POSTing a query string and returns the data wrapped in a data field. But handling errors by checking an errors field feels un-RESTful and causes opposition.

Maybe we could provide an alternative, non-standard mechanism for error reporting to ease acceptance by RESTful thinkers?

My first idea subject to discussion is this: if the client request has an Accept header application/graphql.data+json, then the response body is only the data without the wrapping; or the list or errors, if it's not empty. This makes partial results impossible, of course. Validation errors would result in a 400 status; other errors in a 500; we may define a mechanism to specify the status code for an exception, e.g. a @Status annotation similar to the @ErrorCode annotation already defined in SmallRye GraphQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions