dotansimha / dotansimha/graphql-code-generator-community
[typescript-generic-sdk] Return Type needs to be Promise<AsyncIterable<R>>
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Which packages are impacted by your issue?
@graphql-codegen/typescript-generic-sdk
### Describe the bug
I was trying to implement a requester in nodejs with apolloClient in typescript (see my gist).
With a subscription being returned as an `AsyncIterable`, there is no way of knowing, when the subscription has been established/is listening.
Making the return type `Promise>` would provide the proper interface to represent the availability of the connection.
Awaiting for the first `[Symbol.asyncIterator]().next()` isn't the same, as a subscription might omit onConnect data afaik.
Also it's kind of unhandy syntax compared to just using an additional await.
With that in place one should be able to run a mutation after the subscription is established, to not miss the message.
https://gist.github.com/engelant/3f976774b5d1c6d9848e7ad346ef913a
### Your Example Website or App
https://github.com/dotansimha/graphql-code-generator-community/tree/main
### Steps to Reproduce the Bug or Issue
1. Generate sdk code with typescript-generic-sdk plugin
2. The return type of a subscription is innsufficient to represent the connection state
### Expected behavior
As a user I would like to be able to easily ensure my subscription is established before executing further code.
### Screenshots or Videos
_No response_
### Platform
https://github.com/dotansimha/graphql-code-generator-community/tree/main
### Codegen Config File
_No response_
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in the @graphql-codegen/typescript-generic-sdk package by locating where subscription return types are defined and generated. Use the linked gist to understand the requester scenario, then verify that generated subscriptions expose Promise> and let callers wait for establishment before running subsequent code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100