Provided by: libgraphql-perl_0.54-1_all
NAME
GraphQL::Subscription - Implement GraphQL subscriptions
SYNOPSIS
use GraphQL::Subscription qw(subscribe); my $result = subscribe($schema, $doc, $root_value);
DESCRIPTION
Implements a GraphQL "subscription" - a feed of events, commonly of others' mutations.
METHODS
subscribe 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: • an error result if the subscription fails (generated by GraphQL) • a GraphQL::AsyncIterator instance generated by a resolver, probably hooked up to a GraphQL::PubSub instance 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.