dotansimha / dotansimha/graphql-code-generator

feat(@graphql-codegen/core): Non-async `codegen` function interface

Open
#10,149 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Is your feature request related to a problem? Please describe.

I'm working on augmenting the `aws-amplify` library to generate data interfaces for lambda functions to consume, which requires running `codegen` during the infrastructure build step in CDK. CDK doesn't support [awaiting async calls](https://github.com/aws/aws-cdk/issues/8273#issuecomment-640537378) related to concerns about keeping definitions deterministic.

**Would it be possible to support running `codegen` synchronously / without the Promise wrapper?**

Reviewing the implementation, it appears `codegen` is async to support async `profiler`, `cache` and `plugin` implementations. Our current usage doesn't include async behavior for any of these, but there's no way for me to decouple the async wrappers baked into the library behavior.

Our customers schema is composed during CDK execution, which we want to `codegen` so their projects can depend upon an updated `schema` directly in their lambdas.

### Describe the solution you'd like

I've experimented with making/testing this change to `codegen`, offering a `codegenSync` variant implementation with the needed types.

This would either support `profiler`, `plugin` and `cache`'s that are sync only, or strip these features out if they only make sense as async behavior.

If an option like this would be considered for merge into the library, I could turn my prototype into a draft PR.

### Describe alternatives you've considered

- I have explored using `execa` to perform this `async` behavior in a separate process.
- I have explored introducing async behavior into the `cdk` constructs that compose the schema.

### Any additional important details?

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.