GraphQL::Subscription(3pm) | User Contributed Perl Documentation | GraphQL::Subscription(3pm) |
GraphQL::Subscription - Implement GraphQL subscriptions
use GraphQL::Subscription qw(subscribe); my $result = subscribe($schema, $doc, $root_value);
Implements a GraphQL "subscription" - a feed of events, commonly of others' mutations.
my $result = subscribe( $schema, $doc, # can also be AST $root_value, $context_value, $variable_values, $operation_name, $field_resolver, $promise_code, $subscribe_resolver, );
Takes the same args as "execute" in GraphQL::Execution, except that the $promise_code is mandatory, and there is the optional $subscribe_resolver which, supplied or not, will be used instead of the $field_resolver to resolve the initial subscription. The $field_resolver will still be used for resolving each result.
Returns a promise of either:
The event source returns values by using "publish" in GraphQL::AsyncIterator. To communicate errors, resolvers can throw errors in the normal way, or at the top level, use "error" in GraphQL::AsyncIterator.
The values will be resolved in the normal GraphQL fashion, including that if there is no specific-to-field resolver, it must be a value acceptable to the supplied or default field-resolver, typically a hash-ref with a key of the field's name.
2022-03-27 | perl v5.34.0 |