Skip to content

[cli] Handle partial generation success #10376

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

Draft
wants to merge 3 commits into
base: federation-fixes
Choose a base branch
from

Conversation

eddeee888
Copy link
Collaborator

@eddeee888 eddeee888 commented Jun 27, 2025

Description

Introduce allowPartialOutputs to allow users to write partial success to files.

This is a breaking change because we change how executeCodegen function works (exposed and can be imported): previously if any generates fails, it'd throw. Now, it will return the error and output files as result and let the caller decide what to do with them.

The main caller of executeCodegen is the CLI and it (1.) throws if there is complete failure or (2) use allowPartialOutputs to write on partial success or not

Related #9701

Type of change

  • Breaking change

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit test

Copy link

changeset-bot bot commented Jun 27, 2025

🦋 Changeset detected

Latest commit: e7b390c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphql-codegen/plugin-helpers Minor
@graphql-codegen/cli Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eddeee888 eddeee888 force-pushed the handle-partial-error branch 2 times, most recently from c000be1 to 9c57b83 Compare June 27, 2025 11:50
Copy link
Contributor

github-actions bot commented Jun 27, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/cli 6.0.0-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/core 4.0.3-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/add 5.0.4-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/fragment-matcher 5.1.1-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 4.0.4-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/schema-ast 4.1.1-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/time 5.0.2-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 6.0.0-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 4.0.17-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 4.0.18-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 4.6.2-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 5.0.0-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 5.1.3-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 4.1.7-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 4.8.4-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 4.0.18-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/testing 3.0.5-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎
@graphql-codegen/plugin-helpers 6.0.0-alpha-20250702094259-330e4c0c023358d9861caa216bc6e850fd799b01 npm ↗︎ unpkg ↗︎

Copy link
Contributor

github-actions bot commented Jun 27, 2025

💻 Website Preview

The latest changes are available as preview in: https://pr-10376.graphql-code-generator.pages.dev

@eddeee888 eddeee888 changed the title Handle partial error Handle partial generation success Jul 1, 2025
@eddeee888 eddeee888 force-pushed the handle-partial-error branch from c0ce057 to 330e4c0 Compare July 2, 2025 09:41
@eddeee888 eddeee888 changed the base branch from master to federation-fixes July 2, 2025 09:41
@eddeee888 eddeee888 changed the title Handle partial generation success [cli] Handle partial generation success Jul 2, 2025
@@ -78,7 +78,10 @@ export const createWatcher = (
const debouncedExec = debounce(() => {
if (!isShutdown) {
executeCodegen(initialContext)
.then(onNext, () => Promise.resolve())
.then(
({ result }) => onNext(result),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: apply the same allowPartialOutputs treatment for watcher

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

Successfully merging this pull request may close these issues.

1 participant