ci(server-tests): GraphQL codegen outputs cached incompletely / in the wrong cache
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- github-actions, graphql, typescript
- Domain
- build-system, ci-cd
Research direction
Start in .github/workflows/server-tests.yml and compare its GraphQL and PgTyped cache paths and keys with .github/actions/setup/action.yml and the generate:graphql targets in package.json. Update the cache ownership and paths, preserving distinct cache keys where required. Run the server-tests workflow twice to verify the first run generates outputs after a miss and the exact-hit rerun remains green.
Written by the indexing model from the issue text.
Description
Found while checking Urigo/accounter-fullstack#4581, which fixes the GraphQL codegen cache key. This issue covers two problems with the cached paths in .github/workflows/server-tests.yml. That PR leaves both alone to stay focused.
Background
server-tests.yml runs yarn generate:graphql only when the "Cache GraphQL Generated Types" step misses (if: steps.graphql-cache.outputs.cache-hit != 'true'). generate:graphql first deletes every codegen output with rimraf, then regenerates all of them (see generate:graphql:clear in the root package.json). On an exact hit, generation is skipped, so any codegen output not listed under path: is simply missing for the rest of the job.
.github/actions/setup/action.yml already hit this and fixed it. Its comment reads: "Every generate:graphql output must be listed … packages/server/src/__generated__ was missing, which broke any module value-importing from it."
1. packages/server/src/__generated__ is not cached in server-tests.yml
The GraphQL cache there lists:
path: |
schema.graphql
packages/server/src/modules/**/__generated__
packages/client/src/gql
packages/email-ingestion-gateway/src/gql
It leaves out packages/server/src/__generated__, which holds the base resolver types (baseTypesPath: '../__generated__/types.ts' in codegen.ts).
- Impact today: none (latent). Vitest removes type-only imports, and the only runtime value import from that file is
ChargeSortByFieldinpackages/server/src/modules/ledger/resolvers/ledger.resolver.ts. No test loads it: nothing under test importsmodules-app.tsor the ledger resolver. - Risk: the first test that loads the full application or the ledger module, or any new runtime enum import from
__generated__/types.js, fails with a missing-module error. It fails only on exact cache hits, so the failure looks like a flake. - Fix: add
packages/server/src/__generated__to thatpath:list, the same fix as in the setup action.
2. scraper-app's GraphQL codegen output is stored in the pgtyped cache
The "Cache PgTyped Generated Types" step in server-tests.yml caches packages/scraper-app/src/server/gql/index.ts and adds packages/scraper-app/src/server/graphql/mutations.ts to its key. That file is produced by GraphQL codegen (the packages/scraper-app/src/server/gql/index.ts target in codegen.ts), not by pgtyped (generate:sql is yarn pgtyped in packages/server).
Step order in the job:
- GraphQL cache.
- Generate GraphQL Types.
- Typecheck the gateway.
- pgtyped cache restore.
- Generate Postgres types.
- Problem: on a GraphQL cache miss, step 2 writes fresh scraper-app types. Then an exact pgtyped hit in step 4 overwrites them with the cached copy. That copy is keyed on
mutations.tsbut not on the server schema, so it can be stale after a schema change. - Impact today: low. The document text only changes when
mutations.tschanges, and that file is in the pgtyped key. Only the generated TS types can go stale, and vitest doesn't typecheck. - Fix: move
packages/scraper-app/src/server/gqlinto the GraphQL cachepath:, andpackages/scraper-app/src/server/graphql/mutations.tsinto that key. Remove both from the pgtyped step. This matches how the setup action caches it. - Caution: after this change, the
server-testsGraphQL key and the setup-action key must stay distinct as long as they cache differentpath:sets. Today theserver-testskey is a strict subset of the setup key. If both lists become identical, give one of them its own prefix, e.g.graphql-codegen-server-tests-. Otherwise one workflow could restore the other's cache and miss outputs.
Acceptance
- The
server-tests.ymlGraphQL cache lists everygenerate:graphqloutput that the job's steps use. - The pgtyped cache contains only pgtyped outputs.
- CI shows a cache miss followed by generation on the first run, then an exact hit on a re-run with the job still green.
- Dominant language
- TypeScript
- Stars
- 30
- Forks
- 8
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 200
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Urigo/accounter-fullstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Urigo/accounter-fullstack#4580 ·
Maintainers usually reply within 2 days
-
Document PG18 migration conventions: NOT NULL NOT VALID, and generated columns default to VIRTUALOpen
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Urigo/accounter-fullstack#4366 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Urigo/accounter-fullstack#4579 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
Urigo/accounter-fullstack#4560 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
Urigo/accounter-fullstack#4558 ·
Maintainers usually reply within 2 days
All issues in Urigo/accounter-fullstack
Similar issues
-
priority: P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
prime-radiant-inc/evener#3291 ·
Maintainers usually reply within 1 day
-
accessibility bug revealjs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14961 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
supabase/agent-skills#614 ·
-
Content
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
RunestoneInteractive/rs#1559 · 1 comment ·
Maintainers usually reply within 2 days