Skip to content

feat: adding cache-graphql command to faststore/cli - #3122

Merged
ommeirelles merged 24 commits into
fix/storybookfrom
feat/cache-requests
Dec 2, 2025
Merged

ommeirelles merged 24 commits into
fix/storybookfrom
feat/cache-requests

Conversation

@ommeirelles

@ommeirelles ommeirelles commented Nov 18, 2025 •

Copy link
Copy Markdown
Contributor
  • faststore/cli command to calculate graphql chaced queries

You can test it by running the cli on the starter or on the core mannualy.

Ex:

  • Running on core
  $ pnpm i
  $ cd ./packages/core
  $ (../cli & pnpm build)
  $ node ../cli/bin/run generate-types
  $ node ../cli/bin/run cache-graphql

Builds the cli, and regenerated the types to create the persisted-documents.json file and run the cache-graphql.

After running it you should see the discovery.config.default.js changed to include all the queries names that would be cached.

@ommeirelles
ommeirelles requested a review from a team as a code owner November 18, 2025 18:41
@ommeirelles
ommeirelles requested review from emersonlaurentino and hellofanny and removed request for a team November 18, 2025 18:42
@ommeirelles
ommeirelles force-pushed the feat/cache-requests branch 2 times, most recently from 6de7787 to e802b3d Compare November 19, 2025 20:07
@codesandbox-ci

codesandbox-ci Bot commented Nov 25, 2025 •

Copy link
Copy Markdown

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.

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved

@lemagnetic lemagnetic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested cache-graphql command. It works correctly - discovery.config.default.js was updated with 21 queries in `cachedOperations

Comment thread .github/workflows/ci.yml Resolved

@eduardoformiga eduardoformiga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Questions:
Should we use only the starter to test in this PR? I can't see the scripts command as previously in the core package.
Can you please provide a starter PR/preview so that we can test it in a best way or provide the steps to test the changes?

@ommeirelles

Copy link
Copy Markdown
Contributor Author

Questions: Should we use only the starter to test in this PR? I can't see the scripts command as previously in the core package. Can you please provide a starter PR/preview so that we can test it in a best way or provide the steps to test the changes?

You can test it by running the cli on the starter or on the core mannualy.

Ex:

  • Running on core
  $ pnpm i
  $ cd ./packages/core
  $ (../cli & pnpm build)
  $ node ../cli/bin/run generate-types
  $ node ../cli/bin/run cache-graphql

Builds the cli, and regenerated the types to create the persisted-documents.json file and run the cache-graphql.

After running it you should see the discovery.config.default.js changed to include all the queries names that would be cached.

@eduardoformiga eduardoformiga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good job! Looks like it worked as expected.
Screenshot 2025-12-01 at 19 32 42

*The final discovery.config.default.js was generated with a lot of diffs related to formatting. I think it's not a big deal so far, though.

Comment thread .github/workflows/ci.yml
run: |
cd starter
yarn install
yarn add [email protected]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎗️ Remember to include it on the starter template afterward instead of here.

Comment thread packages/cli/package.json
"graphql": "catalog:"
},
"engines": {
"node": ">=20"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure when we did this update, but I think we also need to remember to update this config in the starter template.
🎗️ Remember to include it on the starter template.

current setting in starter template:

"volta": {
   "node": "18.19.0",
   "yarn": "1.19.1"
 },

Comment thread packages/cli/src/commands/build.ts Resolved

/* This piece of code was taken out of @faststore/graphql-utils */
const baseRequest = async <V = any, D = any>(
/* This piece of code was taken out of @vtex/faststore-graphql-utils */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/* This piece of code was taken out of @vtex/faststore-graphql-utils */
/* This piece of code was taken out of @faststore/graphql-utils */

I think this was before undoing the renaming 🤔

@ommeirelles
ommeirelles merged commit 97f0ffa into fix/storybook Dec 2, 2025
@ommeirelles
ommeirelles deleted the feat/cache-requests branch December 2, 2025 14:11
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.

4 participants