Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stocaaro opened this issue Sep 23, 2024 · 2 comments
Open

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

stocaaro opened this issue Sep 23, 2024 · 2 comments

Comments

@stocaaro
Copy link

stocaaro commented Sep 23, 2024

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 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

@stocaaro stocaaro changed the title feat: Non-async codegen function interface feat(@graphql-codegen/core): Non-async codegen function interface Sep 23, 2024
@saihaj
Copy link
Collaborator

saihaj commented Sep 28, 2024

Why can you not run codegen before running CDK build?

@stocaaro
Copy link
Author

stocaaro commented Sep 30, 2024

We looked into that. The graphql schema we're running codegen against isn't finalized until the cdk artifacts are being composed, which supports having multipe schema's combined into a single API surface.

We have been running codegen after the cdk build was complete, however, now we want to allow customers to consume a generated introspection schema from within a lambda, which would require running codegen after the cdk build starts, but before it is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants