fix(graphql-codegen): generate barrel file for ORM-only mode #659
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Previously, the barrel file (
index.ts) at the output root was only generated when bothreactQueryandormwere enabled. This caused import errors when using ORM-only mode, as the output directory would have anorm/subdirectory but noindex.tsto re-export from it.Now the barrel file is always generated (when not in dry-run mode), with exports based on which generators are enabled:
export * from './orm'export * from './hooks'export * from './types',export * from './hooks',export * from './orm'This fixes the CI failure in constructive-db PR #444 where tests couldn't import
createClientfrom the SDK.Implementation
Added a new
generateRootBarrel()function inbarrel.tsusing Babel AST for consistency with the rest of the codebase. The function conditionally addsexport * fromstatements based on which generators are enabled.Review & Testing Checklist for Human
Test Plan
orm: trueonly and verifyoutput/index.tscontainsexport * from './orm'reactQuery: trueonly and verifyoutput/index.tscontainsexport * from './hooks'Notes