ChilliCream / ChilliCream/graphql-platform

Connection doesn't provide a request context for method based `getTotalCount`

Open
#6,718 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Product

Hot Chocolate

Is your feature request related to a problem?

I have a very complex query system. We have over 300 entities in our "public" API and many more besides. When returning new Connection() from data fetching methods you can provide a getTotalCount async method. This is lovely but fails if you require anything to resolve from the service provider.

For myself since the API is very complex I have undertaken to duplicate the core logic of ConnectionType, EdgeType, ConnectionPageInfo (etc) in order to provide this and other functionality, but others may benefit from simply having access to the context for getTotalCount, thus allowing expensive count operations to only happen on demand instead of needing to pre-resolve everything from the service provider.

The solution you'd like

An overload should be provided with Func<HotChocolate.Resolvers.IResolverContext, CancellationToken, ValueTask<int>> getTotalCount

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.

Research direction

Start by locating the Connection implementation and how its method-based getTotalCount callback is invoked, then read the related ConnectionType, EdgeType, and ConnectionPageInfo types. Verify how IResolverContext is exposed to resolver callbacks. Done means the requested overload accepts the resolver context and cancellation token while preserving the existing callback form.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.