-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add directive @void
to unify the definition of fields with no return value
#1992
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@void
to 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
@void
and the type nameUnit
.