Skip to content

chore(tooling): Apollo codegen setup#58

Closed
tataihono wants to merge 1 commit intomainfrom
feat/40-apollo-codegen-setup
Closed

chore(tooling): Apollo codegen setup#58
tataihono wants to merge 1 commit intomainfrom
feat/40-apollo-codegen-setup

Conversation

@tataihono
Copy link
Copy Markdown
Contributor

@tataihono tataihono commented Feb 18, 2026

Summary

Apollo/GraphQL codegen setup for web. Generates TypeScript types from Strapi schema. Web ready for Apollo Client + Experience queries (#41).

Resolves #40

Contracts Changed

  • yes
  • no

Regeneration Required

  • yes
  • no

Validation

  • Contracts validated
  • Generated code verified (no manual edits)
  • Tests and build passed
  • Terraform plan reviewed (if infra change)

Summary by CodeRabbit

  • New Features

    • Integrated GraphQL support with Apollo Client
  • Chores

    • Added GraphQL Code Generator for automatic TypeScript type generation
    • Updated configuration to exclude generated files from linting and formatting

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 18, 2026

Walkthrough

Sets up Apollo GraphQL Code Generator to generate TypeScript types from a GraphQL schema located at apps/cms/schema.graphql. Adds codegen configuration, CLI dependencies, build script, and excludes generated output from linting and formatting.

Changes

Cohort / File(s) Summary
GraphQL Codegen Configuration
codegen.ts
New configuration file for GraphQL Code Generator that reads schema from apps/cms/schema.graphql and generates TypeScript types to apps/web/src/generated/graphql.ts.
Dependency Additions
apps/web/package.json, package.json
Added @apollo/client and graphql to apps/web dependencies; added @graphql-codegen/cli and @graphql-codegen/typescript to root devDependencies and codegen:graphql script.
Linting and Formatting Ignores
.prettierignore, eslint.config.mjs, apps/web/eslint.config.mjs
Excluded apps/web/src/generated from Prettier formatting and ESLint linting across root and app-level configurations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

cms

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(tooling): Apollo codegen setup' directly and clearly summarizes the main change—setting up Apollo GraphQL codegen tooling for TypeScript type generation.
Linked Issues check ✅ Passed All coding requirements from issue #40 are met: codegen configured for schema reading, TypeScript types generated, output to apps/web/src/generated/graphql.ts, root script added, and Apollo Client dependency included.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #40 requirements: codegen configuration, generated file output paths, Apollo/GraphQL dependencies, and ignore patterns for generated files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/40-apollo-codegen-setup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the cms label Feb 18, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
codegen.ts (1)

3-9: Add overwrite and typescript-operations before query files land

Two gaps in the current config:

  1. overwrite: true is missing. Without it, codegen will interactively prompt before overwriting the output file, breaking non-interactive CI runs.

  2. typescript-operations plugin is absent. Apollo's own codegen docs recommend installing and using both @graphql-codegen/typescript and @graphql-codegen/typescript-operations, noting "we recommend using the typescript and typescript-operations plugins directly (at minimum)". Adding typescript-operations now (together with a documents glob and ignoreNoDocuments: true) means the config is ready the moment the first .graphql operation file is committed.

♻️ Proposed expansion
 const config: CodegenConfig = {
+  overwrite: true,
   schema: "./apps/cms/schema.graphql",
+  documents: ["apps/web/src/**/*.{ts,tsx}"],
+  ignoreNoDocuments: true,
   generates: {
     "./apps/web/src/generated/graphql.ts": {
-      plugins: ["typescript"],
+      plugins: ["typescript", "typescript-operations"],
     },
   },
-};
+}

Also add the plugin package in root package.json:

    "@graphql-codegen/typescript": "^5.0.7",
+   "@graphql-codegen/typescript-operations": "^4.5.1",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@codegen.ts` around lines 3 - 9, The Codegen config (variable config:
CodegenConfig) is missing overwrite and the typescript-operations plugin and
should be prepared for operation files; update the config object to include
overwrite: true at the top level, add "typescript-operations" to the plugins
array for the output target (alongside "typescript"), add a documents glob
(e.g., pattern for .graphql/.ts/.tsx operation files) and set ignoreNoDocuments:
true so CI won't fail when no documents exist, and also add the npm package
`@graphql-codegen/typescript-operations` to root package.json
dependencies/devDependencies so the plugin is available at runtime.
package.json (1)

12-12: Consider integrating codegen:graphql into the main codegen script

Issue #40 asks for a codegen script runnable from the repo root. Right now pnpm run codegen skips the GraphQL step. Consumers need to know to run codegen:graphql separately.

♻️ Proposed integration
-   "codegen": "pnpm --filter `@forge/tooling-codegen` run generate && pnpm --filter `@forge/tooling-codegen` run verify",
+   "codegen": "graphql-codegen --config codegen.ts && pnpm --filter `@forge/tooling-codegen` run generate && pnpm --filter `@forge/tooling-codegen` run verify",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 12, Modify the root package.json "codegen" script so it
runs the GraphQL codegen step as part of the main codegen flow: update the
"codegen" script to invoke the existing codegen tasks plus the "codegen:graphql"
script (for example by chaining with && or using a task runner) so running `pnpm
run codegen` executes both the general codegen and the "codegen:graphql"
command; ensure you reference the existing "codegen" and "codegen:graphql"
script names and preserve error propagation (fail the overall script if the
GraphQL step fails).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/package.json`:
- Around line 13-15: Add the missing peer dependency "rxjs" to
apps/web/package.json so `@apollo/client` (version ^4.1.4) has its required peer;
update the "dependencies" block to include "rxjs" with a compatible semver
(e.g., ^7.3.0) alongside "@apollo/client" and "graphql" to silence pnpm peer
warnings and ensure Apollo's observable layer works at runtime.

In `@codegen.ts`:
- Around line 1-12: Remove semicolons from this file to satisfy Prettier: delete
the trailing semicolons on the import line, after the const declaration for
config, and after the export default config statement. Update the import line,
the declaration of const config and the export default config to be
semicolon-free so the file conforms to the project's Prettier rules and CI
checks.

---

Nitpick comments:
In `@codegen.ts`:
- Around line 3-9: The Codegen config (variable config: CodegenConfig) is
missing overwrite and the typescript-operations plugin and should be prepared
for operation files; update the config object to include overwrite: true at the
top level, add "typescript-operations" to the plugins array for the output
target (alongside "typescript"), add a documents glob (e.g., pattern for
.graphql/.ts/.tsx operation files) and set ignoreNoDocuments: true so CI won't
fail when no documents exist, and also add the npm package
`@graphql-codegen/typescript-operations` to root package.json
dependencies/devDependencies so the plugin is available at runtime.

In `@package.json`:
- Line 12: Modify the root package.json "codegen" script so it runs the GraphQL
codegen step as part of the main codegen flow: update the "codegen" script to
invoke the existing codegen tasks plus the "codegen:graphql" script (for example
by chaining with && or using a task runner) so running `pnpm run codegen`
executes both the general codegen and the "codegen:graphql" command; ensure you
reference the existing "codegen" and "codegen:graphql" script names and preserve
error propagation (fail the overall script if the GraphQL step fails).

Comment thread apps/web/package.json
Comment on lines +13 to +15
"@apollo/client": "^4.1.4",
"@forge/client-ts-web": "workspace:*",
"graphql": "^16.12.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check the current state of apps/web/package.json
cat apps/web/package.json

Repository: JesusFilm/forge

Length of output: 739


🏁 Script executed:

# Check if rxjs is anywhere in the codebase
rg '"rxjs"' --max-count 20

Repository: JesusFilm/forge

Length of output: 41


🏁 Script executed:

# Check root package.json
cat package.json

Repository: JesusFilm/forge

Length of output: 1034


🌐 Web query:

Apollo Client v4 rxjs peer dependency requirements

💡 Result:

Apollo Client v4 adds RxJS as a peer dependency—you must install rxjs yourself. Apollo’s v4 migration guide calls out rxjs as a new peer dep and shows installing it alongside @apollo/client and graphql. [1]

For @apollo/client@4.0.0, the declared peer requirement is:

  • rxjs: ^7.3.0 (i.e., RxJS 7.3+ within major v7) [2]

Sources: [1] [2]


Add missing rxjs peer dependency for @apollo/client v4

@apollo/client v4.1.4 requires rxjs (v7.3+) as a peer dependency. Without it in dependencies, pnpm will warn about the missing peer and Apollo Client's observable layer will fail at runtime.

📦 Add the missing peer dependency
  "dependencies": {
    "@apollo/client": "^4.1.4",
+   "rxjs": "^7.8.0",
    "@forge/client-ts-web": "workspace:*",
    "graphql": "^16.12.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@apollo/client": "^4.1.4",
"@forge/client-ts-web": "workspace:*",
"graphql": "^16.12.0",
"@apollo/client": "^4.1.4",
"rxjs": "^7.8.0",
"@forge/client-ts-web": "workspace:*",
"graphql": "^16.12.0",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/package.json` around lines 13 - 15, Add the missing peer dependency
"rxjs" to apps/web/package.json so `@apollo/client` (version ^4.1.4) has its
required peer; update the "dependencies" block to include "rxjs" with a
compatible semver (e.g., ^7.3.0) alongside "@apollo/client" and "graphql" to
silence pnpm peer warnings and ensure Apollo's observable layer works at
runtime.

Comment thread codegen.ts
Comment on lines +1 to +12
import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
schema: "./apps/cms/schema.graphql",
generates: {
"./apps/web/src/generated/graphql.ts": {
plugins: ["typescript"],
},
},
};

export default config;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Prettier violations will fail CI — remove semicolons

Static analysis reports Delete ";" on lines 1, 10, and 12. The project Prettier config disables semicolons; this file must match.

🐛 Proposed fix
-import type { CodegenConfig } from "@graphql-codegen/cli";
+import type { CodegenConfig } from "@graphql-codegen/cli"
 
 const config: CodegenConfig = {
   schema: "./apps/cms/schema.graphql",
   generates: {
     "./apps/web/src/generated/graphql.ts": {
       plugins: ["typescript"],
     },
   },
-};
+}
 
-export default config;
+export default config
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "./apps/cms/schema.graphql",
generates: {
"./apps/web/src/generated/graphql.ts": {
plugins: ["typescript"],
},
},
};
export default config;
import type { CodegenConfig } from "@graphql-codegen/cli"
const config: CodegenConfig = {
schema: "./apps/cms/schema.graphql",
generates: {
"./apps/web/src/generated/graphql.ts": {
plugins: ["typescript"],
},
},
}
export default config
🧰 Tools
🪛 ESLint

[error] 1-1: Delete ;

(prettier/prettier)


[error] 10-10: Delete ;

(prettier/prettier)


[error] 12-12: Delete ;

(prettier/prettier)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@codegen.ts` around lines 1 - 12, Remove semicolons from this file to satisfy
Prettier: delete the trailing semicolons on the import line, after the const
declaration for config, and after the export default config statement. Update
the import line, the declaration of const config and the export default config
to be semicolon-free so the file conforms to the project's Prettier rules and CI
checks.

@tataihono
Copy link
Copy Markdown
Contributor Author

Superseded by #60 (gql.tada + packages/graphql).

@tataihono tataihono closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(tooling): Apollo codegen setup

1 participant