Repository navigation
feat!: release v4 + adjusts - #3299
Conversation
- Introduced a new cached operations file to store GraphQL query results. - Updated the cache-graphql command to save cached operations. - Modified request method to utilize cached operations for determining HTTP method.
WalkthroughThe CLI's ChangesGraphQL Caching Data Flow
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli/src/commands/cache-graphql.ts (1)
13-13: ⚡ Quick win
configPath/configflag /configFileNameare dead code post-refactor.The command still hard-exits (
process.exit(1)) ifdiscovery.config.default.jsisn't found (lines 51–56), yetconfigPathis only consumed in alogger.infocall and the file is never opened or read. This directly contradicts the PR's stated goal of decouplingcache-graphqlfromdiscovery.config. Any environment where the config file is absent will hit a spurious failure.♻️ Proposed cleanup
-const configFileName = 'discovery.config.default.js' const cachedOperationsFileName = 'cached-operations.json' export default class CacheGraphql extends Command { static flags = { queries: Flags.string({ name: 'queries', description: 'The path to locate persisted-document file.', }), - config: Flags.string({ - name: 'config', - description: 'The path where the discovery.config is located', - }), } ... async run() { const { args, flags } = await this.parse(CacheGraphql) const rootPath = getBasePath() const argPath = (args?.store && path.resolve(rootPath, args.store)) || rootPath const { tmpDir } = withBasePath(argPath) - const configPath = - this.getConfigFile(flags.config && path.resolve(argPath, flags.config)) || - this.getConfigFile(tmpDir) || - this.getConfigFile(argPath) const persistedDocumentsPath = ... - if (!configPath) { - return this.errorFileNotFound( - configFileName, - `\n ${tmpDir}\n ${argPath}` - ) - } if (!persistedDocumentsPath) { ... } ... if (fsExtra.pathExistsSync(tmpDir)) logger.info(`${chalk.blue('[Info]')} - .faststore Path at: ${tmpDir}`) - logger.info(`${chalk.blue('[Info]')} - Config file location: ${configPath}`) logger.info(...)Also applies to: 22-25, 43-56, 74-74
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/commands/cache-graphql.ts` at line 13, The configPath/config flag and the configFileName constant are dead after the refactor and are causing a spurious hard exit; remove the unused const configFileName, remove the command flag named "config" and any reads of configPath (including the logger.info that prints it), and delete the file-existence check that calls process.exit(1) (the block that looks for discovery.config.default.js and exits on missing file). Ensure no other code in cache-graphql.ts (search for symbols configFileName, configPath, and the "config" flag registration) relies on that file so the command no longer fails when discovery.config.default.js is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/cli/src/commands/cache-graphql.ts`:
- Line 13: The configPath/config flag and the configFileName constant are dead
after the refactor and are causing a spurious hard exit; remove the unused const
configFileName, remove the command flag named "config" and any reads of
configPath (including the logger.info that prints it), and delete the
file-existence check that calls process.exit(1) (the block that looks for
discovery.config.default.js and exits on missing file). Ensure no other code in
cache-graphql.ts (search for symbols configFileName, configPath, and the
"config" flag registration) relies on that file so the command no longer fails
when discovery.config.default.js is absent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ee23aa40-368a-47b5-b69b-56809b972d2e
⛔ Files ignored due to path filters (2)
.github/workflows/release-dev.ymlis excluded by none and included by none.gitignoreis excluded by none and included by none
📒 Files selected for processing (2)
packages/cli/src/commands/cache-graphql.tspackages/core/src/sdk/graphql/request.ts
What's the purpose of this pull request?
This PR aims to:
!.release-dev.ymlfile.The CI's
pnpm buildrancache-graphql, which rewrote the versioneddiscovery.config.default.js(Biome formatting mismatch broke lint, and the dirty working tree brokelerna publish).The fix was to extract
cachedOperationsinto a generated file under@generated/(gitignored), so the build no longer touches versioned files.How does it work
This pull request refactors how cached GraphQL operations are managed and consumed in the codebase. Instead of embedding cached operations in the
discovery.configfile, the process now outputs them to a dedicatedcached-operations.jsonfile, which is then imported at runtime. This streamlines the workflow and decouples cached operations from configuration, making the system more modular and maintainable.Refactoring cached GraphQL operations handling:
cache-graphql.tsnow writes cached operations to a newcached-operations.jsonfile instead of modifying thediscovery.configfile. This file is generated alongside persisted documents and contains only the cached operation names. [1] [2] [3]request.tsis updated to import and use the newcached-operations.jsonfile to determine whether an operation should use the GET or POST HTTP method, improving separation of concerns and error handling.Minor cleanup:
prettierimport was removed fromcache-graphql.ts, reflecting the fact that formatting is no longer needed for the new JSON output.Summary by CodeRabbit