Skip to content

How to pass a model to the broadcast, to the fields of which field resolvers have already been applied? #975

Answered by zabavnikov
zabavnikov asked this question in Q&A

You must be logged in to vote

Found a temporary solution, but maybe not temporary. :)

Created my MyGraphQLController.
In the query method after these lines

$data = Helpers::applyEach(
   function (BaseOperationParams $baseOperationParams) use ($schemaName, $graphql): array {
       $operationParams = new OperationParams($baseOperationParams);

       return $graphql->execute($schemaName, $operationParams);
   },
   $operations
);

added

$mutationName = array_keys($data['data'])[0];
$subscriptions = array_keys($config->get('graphql.subscriptions'));

if (in_array($mutationName, $subscriptions)) {
    $class = $config->get('graphql.subscriptions')[$mutationName];
    broadcast(new $class($data['data'][$mutationName]))->t…

Replies: 3 comments 7 replies

You must be logged in to vote
2 replies
@zabavnikov

@zabavnikov

You must be logged in to vote
0 replies
Answer selected by zabavnikov

You must be logged in to vote
5 replies
@zabavnikov

@zabavnikov

@zabavnikov

@mfn

mfn Feb 18, 2023
Collaborator

@zabavnikov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants