Skip to content

v0.6.0

Choose a tag to compare

@mcg-web mcg-web released this 22 Sep 11:20
· 2107 commits to master since this release

v0.6.0 (2016-09-22)

Thank you to @adri for the contribution (#64)

Context

When writing resolvers for mutations or queries I often convert exceptions from the business layer into errors or warnings visible to the GraphQL API user. A mutation resolver can look like this:

    public function someMutation($someId)
    {
        try {
            // do something
        } catch (SomethingWentWrong $e) {
            throw new UserError($e->getMessage());
        } catch (AnotherError $e) {
            throw new UserError($e->getMessage());
        } catch (ShouldNotHappen $e) {
            throw new UserError($e->getMessage());
        } catch (\InvalidArgumentException $e) {
            throw new UserError($e->getMessage());
        }
    }

Doing this manually for all mutations adds some bloat. This is the same for REST APIs which is why FOSRestBundle added the exception configuration.

What has been done

  • Added a configuration to map exceptions that should be displayed as warnings or errors
  • Added unit tests for the configuration
  • Added a functional test
  • Wrote documentation in the readme how to use it

How to test

  • For an example how to use it, please see the updated readme