Skip to content

Conversation

ronjalh
Copy link
Member

@ronjalh ronjalh commented Oct 17, 2026 •

Summary

A change in schema.graphql that a resolver does not follow now fails tsc. Closes #74.

Stacked on #77 (calculator), which is on #65 (server). The base is 72-calculate-dscore. Change the base to dev when those are merged. It does not need the login.

What's in it

  • GraphQL Code Generator (@graphql-codegen/cli, typescript, typescript-resolvers) in backend/codegen.ts. npm run codegen writes backend/src/generated/graphql.ts. Like the Prisma client next to it, it is not committed, so after npm ci run npm run db:generate and npm run codegen (README updated).
  • The database rows that resolvers return are mapped to the GraphQL types in codegen.ts. The three resolver files end with satisfies Resolvers<Context>.
  • Proof: renaming Element.value to score in the schema makes tsc fail with 'value' does not exist in type 'ElementResolvers'.
  • The first run found two real mismatches, both fixed here:
    • ElementGroup.apparatus could return null, although the schema says it never does. It now throws a clear error (the foreign key makes it impossible).
    • totalCount could be undefined when the query did not ask for it. CatalogConnection.totalCount now has its own resolver that fails clearly if it is read without being calculated (the behaviour is the same as before: it is only calculated when asked for).
  • Element.variants and Vault.variants are typed per kind (a variant group only holds one kind).
  • docs/API.md and docs/AI_USAGE.md updated.

Notes

  • npm audit reports a high braces problem inside @graphql-codegen/cli's dependencies. It is a build tool, not part of the running server (npm audit --omit=dev is clean).
  • The frontend part (typed queries) comes with Apollo Client (feat: set up Apollo Client in the frontend #75).

Testing

  • Lint, tsc --noEmit and the 122 tests pass against a database (0 skipped). No behaviour changed, so no new tests; the type check is the test.

🤖 Generated with Claude Code

@ronjalh ronjalh requested a review from a team as a code owner October 17, 2026 08:18
@ronjalh ronjalh self-assigned this Oct 17, 2026
@ronjalh ronjalh marked this pull request as draft October 17, 2026 09:17
@ronjalh ronjalh force-pushed the 72-calculate-dscore branch from c139cd2 to aea1ed0 Compare October 17, 2026 09:23
npm run codegen makes backend/src/generated/graphql.ts from schema.graphql.
The resolvers end with satisfies Resolvers<Context>, so a resolver that
does not match the schema fails tsc. The types found two mismatches in the
catalog resolvers: ElementGroup.apparatus could be null, and totalCount
could be missing. Both are fixed.
@ronjalh ronjalh force-pushed the 74-graphql-codegen branch from 41053dc to bcd34bd Compare October 17, 2026 09:24
@ronjalh ronjalh marked this pull request as ready for review October 17, 2026 09:37
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant