Conversation
stayallive
left a comment
There was a problem hiding this comment.
I like it, on a technical basis!
I just don't care for the choice for Unit, it seems like a random name that easily clashes with userland (I now learned that this is a type theory thing and makes sense but only if you know the sauce). Why not use enum Void { VOID } or enum Empty { EMPTY } or enum Accepted { ACCEPTED } (close to a HTTP 202 response) or even enum Null { NULL } or something a little closer to what it is actually doing?
Regardless, this seems like a nice addition!
# Conflicts: # CHANGELOG.md # src/Console/IdeHelperCommand.php
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
|
This PR becomes a bit old. scalar Void @scalar(class: "App\\GraphQL\\Scalars\\VoidType")With following dummy implementation (a class simply named "Void" isn't allowed in PHP) : class VoidType extends ScalarType
{
public function serialize($value): mixed {
return null;
}
public function parseValue($value): mixed {
return null;
}
public function parseLiteral(Node $valueNode, ?array $variables = null): mixed {
return null;
}
}By making Void a type rather than a directive, it becomes much more clear when defining the schema : type Query {
foo: Void
}The approach proposed with type Query {
foo: Int @void
}Is it void or Int ? |
See graphql/graphql-spec#906
Changes
@voidto unify the definition of fields with no return valueBreaking changes
None, since the service provider is optional. When added by default, it will reserve the directive name
@voidand the type nameUnit.