spring-projects / spring-projects/spring-graphql

Using @Transactional for Subscriptions data fetcher

Open
#1,372 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
1.6k
Forks
336
PR merge metrics
No merged PRs in 30d

Description

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:

https://github.com/spring-projects/spring-graphql/issues/448#issuecomment-1825502735

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the issue's TransactionalAsyncExecutionStrategy example and the AsyncExecutionStrategy.execute entry point, including DataFetcherExceptionHandler, ExecutionContext, and ExecutionStrategyParameters. Review the referenced spring-graphql issue comment for prior context. Done would be a clear, supported answer or implementation for running subscription data fetchers for each message within a transaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java, spring
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.