Skip to content

GraphQL ReadStage->getItem() exception handling results in different behavior since 3.2.* #6123

Open
@zwentastic

Description

@zwentastic

API Platform version(s) affected: 3.2.*

Description
GraphQL: In IriConverter->getResourceFromIri() the exception ApiPlatform\Exception\ItemNotFoundException is thrown, when not finding a proper data set. ReadStage->getItem() calls IriConverter->getResourceFromIri() and catches ItemNotFoundExceptions.

In version 3.1.25 catching the exceptions worked.

But since 3.2.0 class ReadStage uses ApiPlatform\Metadata\Exception\ItemNotFoundException instead of ApiPlatform\Exception\ItemNotFoundException, so the exceptions thrown instead catched.

How to reproduce
GraphQL item query that refers to a not existing ID.

In Version 3.1.25 the query returns null

Since version 3.2.0 the query returns null (as data) and also an "Internal server error".

Possible Solution
Catch both exceptions - or throw/catch the correct exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions