thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API

Home Page:https://graphqlite.thecodingmachine.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First party support for `void` return type

oprypkhantc opened this issue · comments

Currently if you try to return void from a mutation (as it the case with "delete" type of mutations), you get an error for being unable to map the Void_ type. Because this is a common and valid use case for PHP, I believe it should be supported by graphqlite natively, the same way as DateTime is natively supported:

#[Mutation]
public function deleteSomeEntity(SomeEntity $entity): void
{
    $entity->delete();
}

It's a somewhat common practice to add a scalar type Void to handle such cases. This can be done in graphqlite too with a root type mapper.

As always, if this is desirable, I can PR this improvement. Thoughts?

sounds good!
There is a package intended for misc types but it was never really used: https://github.com/thecodingmachine/graphqlite-misc-types
Void sounds like a good type like ID to have in the base library.

Perfect :)

I agree - would be a great addition to the base types. We've been returning true in these cases, which really isn't nearly as desirable.