Skip to content

Distinguish errors of validators, within the executor and within business logic #1373

Open
@wutsch0

Description

@wutsch0

Hi,
accoring to your error-handling documentation there are 3 kinds of errors: Syntax, Validation and Execution.

Syntax errors seem to be well covered by GraphQL\Error\SyntaxError, but for all other error cases the base GraphQL\Error\Error is used, which makes it impossible to distinguish errors qualitatively. This would e.g. be needed to filter out errors in bug trackers. E.g. if triggered by clients which send invalid queries, such as leaving out required parameters or sending incorrect parameter types.
Theoretically it would also be possible to distinguish those kinds of cases by properties provided on GraphQL\Error\Error. So far there is only a category property which could be used, but it changes based on if a previous exceptions is provided during construction time. As both cases appear within the codebase, this property can not be used to distinguish such use cases at the moment.

Introducing more error types via exceptions inheriting from GraphQL\Error\Error seems to be the cleaner approach, but would have the disadventage of breaking backwards compatibility, since e.g. the visitors of validation rules should return more specific exceptions as of now.
A backwards compatible way could be to introduce additional properties in GraphQL\Error\Error as described above, but would have the disadventage of not enabling a hierachy within exceptions.

What is your opinion on that topic?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions