ChilliCream / ChilliCream/graphql-platform

IResolverContext.ContextData is disposed when using Subscriptions returning IAsyncEnumerable

Open
#6,684 6 comments 0 reactions 1 assignee View on GitHub

@michaelstaib is already working on this.

Since Nov 10, 2023.

🌶️ hot chocolate Area: Subscriptions
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Is there an existing issue for this?
  • I have searched the existing issues
Product

Hot Chocolate

Describe the bug

Hello ChilliCream team!

I have some issues with trying to keep some state in ContextData while using Subscriptions.

If I use something like public async ValueTask<ISourceStream<Appointment>> SubscribeToCreatedAppointments(IResolverContext context, ..., I have full access over IResolverContext and its ContextData and it all works perfectly.

But if I use something like public async IAsyncEnumerable<Appointment> SubscribeToCreatedAppointments(IResolverContext context, ..., I get disposed errors from trying to use IResolverContext.ContextData.

I'm not completely sure if it is by design or if it is a bug. In any case, can you please let me know if I'm missing something to make IAsyncEnumerable work for Subscriptions?

Cheers!

Steps to reproduce

In any subscription return IAsyncEnumerable:

e.g. public async IAsyncEnumerable<Appointment> SubscribeToCreatedAppointments(IResolverContext context, ...

I cannot access ContextData as apparently it's disposed.

Relevant log output

No response

Additional Context?

No response

Version

13.6.1

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.