Skip to content

Using @Transactional for Subscriptions data fetcher #1372

@MathisPct

Description

@MathisPct

Hello,

We were wondering whether it’s possible to define an execution strategy (or anything else) that would run the data fetchers for each new message in the subscription flux within a transaction, similar to the following code, which handles this for queries and mutations :

public class TransactionalAsyncExecutionStrategy extends AsyncExecutionStrategy {

    public TransactionalAsyncExecutionStrategy(
            final DataFetcherExceptionHandler handler
    ) {
        super(handler);
    }

    @Override
    @Transactional
    public CompletableFuture<ExecutionResult> execute(
            final ExecutionContext executionContext,
            final ExecutionStrategyParameters parameters
    ) throws NonNullableFieldWasNullException {
        return super.execute(executionContext, parameters);
    }
}

How can we cover this case ?

Thank you by advance

Another sources:

#448 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions