feat: Replace custom Date/DateTime/UUID scalars with graphql-scalars package and add JSON/JSONObject scalar support#673
Conversation
…package and add JSON/JSONObject scalar support
🦋 Changeset detectedLatest commit: 7d0cb08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughMigrates custom GraphQL scalars (Date, DateTime, Uuid) to graphql-scalars resolvers and introduces JSON/JSONObject scalars. Updates generators, templates, and package dependencies accordingly. Adjusts builder typings and schema docs. Removes lint-staged and a pre-commit lint hook. Minor formatting changes in generated route trees and a whitespace tweak in a Prisma config. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant G as GraphQL Server
participant P as Pothos Schema
participant S as graphql-scalars Resolver
C->>G: GraphQL operation with scalar fields (Date/DateTime/Uuid/JSON/JSONObject)
G->>P: Validate & coerce inputs
P->>S: Delegate scalar parseValue/parseLiteral
S-->>P: Coerced value or error
P-->>G: Resolved inputs
G->>G: Execute resolvers
G->>P: Serialize outputs
P->>S: Delegate scalar serialize
S-->>P: Serialized value
P-->>G: Final response payload
G-->>C: Response
note over S,P: Custom inline logic replaced by library resolvers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
examples/todo-with-auth0/packages/backend/package.json (1)
65-65: Bump graphql-scalars to 1.24.2
No security advisories found for v1.23.0, but a newer patch (1.24.2) is available—update to the latest for any minor fixes..changeset/replace-custom-scalars-with-graphql-scalars.md (1)
15-20: Consider adding migration guidance for breaking changes.The breaking changes are well-documented, but users would benefit from explicit migration steps or code examples showing how to update existing implementations that rely on the old behavior.
For example:
- How to handle existing Date strings that don't conform to RFC 3339
- How to adjust DateTime handling if code expects non-UTC timestamps
- Whether UUID validation failures will require data cleanup
This guidance could be added to the changeset or to a migration guide referenced from the changeset.
packages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.ts (1)
117-174: Add JSDoc to exported generator.The exported
pothosScalarGeneratoris missing JSDoc documentation, which is required by the coding guidelines for all exported functions, interfaces, and classes in this path pattern.Add JSDoc above the export:
+/** + * Generator for Pothos GraphQL scalar types. + * Supports DateTime, Date, UUID, JSON, and JSONObject scalars using graphql-scalars resolvers. + * + * @example + * // Usage in generator configuration + * { type: 'dateTime' } + */ export const pothosScalarGenerator = createGenerator({
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (23)
examples/blog-with-auth/packages/backend/baseplate/generated/package.jsonis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/index.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/scalars/date-time.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/scalars/date.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/scalars/json-object.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/scalars/json.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/scalars/uuid.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/plugins/graphql/builder.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlexamples/todo-with-auth0/packages/admin/src/generated/graphql.tsxis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/package.jsonis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/modules/graphql/index.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/modules/graphql/scalars/date-time.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/modules/graphql/scalars/date.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/modules/graphql/scalars/json-object.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/modules/graphql/scalars/json.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/modules/graphql/scalars/uuid.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/backend/baseplate/generated/src/plugins/graphql/builder.tsis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/packages/web/src/generated/graphql.tsxis excluded by!**/generated/**,!**/generated/**examples/todo-with-auth0/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/fastify-generators/src/generators/pothos/pothos-scalar/generated/template-paths.tsis excluded by!**/generated/**,!**/generated/**packages/fastify-generators/src/generators/pothos/pothos-scalar/generated/template-renderers.tsis excluded by!**/generated/**,!**/generated/**packages/fastify-generators/src/generators/pothos/pothos-scalar/generated/typed-templates.tsis excluded by!**/generated/**,!**/generated/**
📒 Files selected for processing (41)
.changeset/replace-custom-scalars-with-graphql-scalars.md(1 hunks).claude/settings.json(1 hunks).husky/pre-commit(0 hunks)examples/blog-with-auth/package.json(0 hunks)examples/blog-with-auth/packages/backend/baseplate/file-id-map.json(1 hunks)examples/blog-with-auth/packages/backend/package.json(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/index.ts(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/.templates-info.json(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.ts(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.ts(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.ts(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.ts(1 hunks)examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.ts(1 hunks)examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts(1 hunks)examples/todo-with-auth0/package.json(0 hunks)examples/todo-with-auth0/packages/admin/src/route-tree.gen.ts(5 hunks)examples/todo-with-auth0/packages/backend/baseplate/file-id-map.json(1 hunks)examples/todo-with-auth0/packages/backend/package.json(1 hunks)examples/todo-with-auth0/packages/backend/schema.graphql(3 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/index.ts(1 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/.templates-info.json(1 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.ts(1 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.ts(1 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.ts(1 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.ts(1 hunks)examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.ts(1 hunks)examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts(1 hunks)examples/todo-with-auth0/packages/web/src/route-tree.gen.ts(1 hunks)packages/fastify-generators/src/constants/fastify-packages.ts(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/extractor.json(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.ts(4 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.ts(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.ts(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.ts(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.ts(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.ts(1 hunks)packages/fastify-generators/src/generators/prisma/prisma/templates/package/prisma.config.mts(1 hunks)packages/fastify-generators/src/types/field-types.ts(2 hunks)packages/fastify-generators/src/writers/pothos/scalars.ts(1 hunks)packages/fastify-generators/src/writers/prisma-schema/fields.ts(1 hunks)packages/project-builder-server/src/compiler/backend/fastify.ts(1 hunks)
💤 Files with no reviewable changes (3)
- .husky/pre-commit
- examples/todo-with-auth0/package.json
- examples/blog-with-auth/package.json
🧰 Additional context used
📓 Path-based instructions (12)
**/*
📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)
Use kebab-case for file names
Files:
examples/blog-with-auth/packages/backend/package.jsonexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/todo-with-auth0/packages/backend/schema.graphqlexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/types/field-types.tsexamples/blog-with-auth/packages/backend/baseplate/file-id-map.jsonpackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/index.tspackages/fastify-generators/src/writers/prisma-schema/fields.tspackages/fastify-generators/src/writers/pothos/scalars.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/index.tsexamples/todo-with-auth0/packages/backend/baseplate/file-id-map.jsonpackages/project-builder-server/src/compiler/backend/fastify.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.tsexamples/blog-with-auth/packages/backend/src/plugins/graphql/builder.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/web/src/route-tree.gen.tsexamples/todo-with-auth0/packages/backend/package.jsonexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/admin/src/route-tree.gen.tspackages/fastify-generators/src/generators/prisma/prisma/templates/package/prisma.config.mtsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.tspackages/fastify-generators/src/constants/fastify-packages.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/extractor.json
examples/blog-with-auth/{package.json,packages/**/package.json}
📄 CodeRabbit inference engine (examples/blog-with-auth/CLAUDE.md)
Use ESM only by setting
"type": "module"in package.json
Files:
examples/blog-with-auth/packages/backend/package.json
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)
**/*.{ts,tsx}: TypeScript with strict type checking
Always include return types on top-level functions including React components (React.ReactElement)
Include absolute paths in import statements via tsconfig paths (@src/is the alias forsrc/)
If a particular interface or type is not exported, change the file so it is exportedIf a particular interface or type is not exported in a TypeScript file, modify the file to export it
Files:
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/types/field-types.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/index.tspackages/fastify-generators/src/writers/prisma-schema/fields.tspackages/fastify-generators/src/writers/pothos/scalars.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/index.tspackages/project-builder-server/src/compiler/backend/fastify.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.tsexamples/blog-with-auth/packages/backend/src/plugins/graphql/builder.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/web/src/route-tree.gen.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/admin/src/route-tree.gen.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.tspackages/fastify-generators/src/constants/fastify-packages.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)
Node 16 module resolution - include file extensions in imports (
.js)
Files:
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/types/field-types.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/index.tspackages/fastify-generators/src/writers/prisma-schema/fields.tspackages/fastify-generators/src/writers/pothos/scalars.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/index.tspackages/project-builder-server/src/compiler/backend/fastify.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.tsexamples/blog-with-auth/packages/backend/src/plugins/graphql/builder.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/web/src/route-tree.gen.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/admin/src/route-tree.gen.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.tspackages/fastify-generators/src/constants/fastify-packages.ts
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)
**/*.{ts,tsx,js}: Sort imports by group: external libs first, then local imports
Use camelCase for variables/functions, PascalCase for types/classes
Order functions such that functions are placed below the variables/functions they use
We use the prefer using nullish coalescing operator (??) ESLint rule instead of a logical or (||), as it is a safer operator
Use console.info/warn/error instead of console.log
Files:
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/types/field-types.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/index.tspackages/fastify-generators/src/writers/prisma-schema/fields.tspackages/fastify-generators/src/writers/pothos/scalars.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/index.tspackages/project-builder-server/src/compiler/backend/fastify.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.tsexamples/blog-with-auth/packages/backend/src/plugins/graphql/builder.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/web/src/route-tree.gen.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/admin/src/route-tree.gen.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.tspackages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.tspackages/fastify-generators/src/constants/fastify-packages.ts
examples/blog-with-auth/packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (examples/blog-with-auth/CLAUDE.md)
examples/blog-with-auth/packages/**/src/**/*.{ts,tsx}: Always use .js extensions in import statements (even when importing from TypeScript files)
Useimport typefor type-only imports
Always specify explicit return types for all functions
Add JSDoc to all exported functions, interfaces, and classes (document parameters, return values, and fields)
Files:
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/index.tsexamples/blog-with-auth/packages/backend/src/plugins/graphql/builder.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.ts
examples/todo-with-auth0/packages/backend/**/schema.graphql
📄 CodeRabbit inference engine (examples/todo-with-auth0/CLAUDE.md)
Backend must generate
schema.graphqlfor the admin package to consume for code generation
Files:
examples/todo-with-auth0/packages/backend/schema.graphql
examples/todo-with-auth0/packages/{admin,backend}/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (examples/todo-with-auth0/CLAUDE.md)
examples/todo-with-auth0/packages/{admin,backend}/src/**/*.{ts,tsx}: Always use .js extensions in import statements, even when importing from TypeScript files
Useimport typefor type-only imports in TypeScript
Always specify explicit return types for all functions
Files:
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.tsexamples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/index.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.tsexamples/todo-with-auth0/packages/admin/src/route-tree.gen.ts
examples/todo-with-auth0/{packages/admin/src/{app,components,pages,hooks,services}/**/*.{ts,tsx},packages/backend/src/{modules,plugins,prisma,services,utils}/**/*.{ts,tsx}}
📄 CodeRabbit inference engine (examples/todo-with-auth0/CLAUDE.md)
Add JSDoc to all exported functions, interfaces, and classes including descriptions, params, returns, and fields (exclude generated code)
Files:
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.tsexamples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/index.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.tsexamples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.ts
**/index.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)
Prefer barrel exports e.g. export * from './foo.js' instead of individual named exports
Files:
examples/todo-with-auth0/packages/backend/src/modules/graphql/index.tsexamples/blog-with-auth/packages/backend/src/modules/graphql/index.ts
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
When adding or changing a feature, add a new Changeset in
.changeset/with patch bump frontmatter and a description
Files:
.changeset/replace-custom-scalars-with-graphql-scalars.md
examples/todo-with-auth0/{package.json,packages/**/package.json}
📄 CodeRabbit inference engine (examples/todo-with-auth0/CLAUDE.md)
examples/todo-with-auth0/{package.json,packages/**/package.json}: Module system must be ESM only ("type": "module"in package.json)
Package manager is pnpm 10+ (enforce viapackageManagerfield)
Node version 22+ with Volta pinned to 22.18.0
Files:
examples/todo-with-auth0/packages/backend/package.json
🧠 Learnings (2)
📚 Learning: 2025-09-03T17:03:33.250Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/todo-with-auth0/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:03:33.250Z
Learning: Applies to examples/todo-with-auth0/{package.json,packages/**/package.json} : Node version 22+ with Volta pinned to 22.18.0
Applied to files:
examples/todo-with-auth0/packages/backend/package.json
📚 Learning: 2025-09-03T17:03:33.250Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/todo-with-auth0/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:03:33.250Z
Learning: Applies to examples/todo-with-auth0/packages/backend/**/schema.graphql : Backend must generate `schema.graphql` for the admin package to consume for code generation
Applied to files:
examples/todo-with-auth0/packages/backend/package.json
🧬 Code graph analysis (17)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.ts (1)
examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.ts (2)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.ts (1)
DateScalar(16-16)examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.ts (1)
examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.ts (1)
examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.ts (1)
examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date.ts (1)
examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
packages/project-builder-server/src/compiler/backend/fastify.ts (1)
packages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.ts (1)
pothosScalarGenerator(117-175)
packages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.ts (1)
packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-89)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.ts (1)
examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.ts (1)
examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.ts (2)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.ts (1)
DateTimeScalar(20-24)examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.ts (2)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.ts (1)
JSONScalar(22-22)examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.ts (1)
examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.ts (1)
examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.ts (1)
examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.ts (2)
examples/blog-with-auth/packages/backend/baseplate/generated/src/modules/graphql/scalars/date-time.ts (1)
DateTimeScalar(20-24)examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.ts (2)
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.ts (1)
UuidScalar(16-16)examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
builder(26-75)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Lint Examples (todo-with-auth0)
- GitHub Check: Verify Sync (todo-with-auth0)
- GitHub Check: Verify Sync (blog-with-auth)
- GitHub Check: Test E2E
- GitHub Check: Lint
- GitHub Check: test
🔇 Additional comments (33)
.claude/settings.json (1)
17-18: Env override looks good.Setting
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIRhelps keep tooling rooted correctly; no further changes needed.examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/date-time.ts (2)
1-1: Excellent migration to a well-maintained library.Replacing the custom DateTime scalar implementation with
graphql-scalarsfollows best practices for using well-known libraries over custom implementations for common functionality.Also applies to: 20-24
5-19: Keep existing JSDoc: it correctly describes DateTimeResolver behavior. DateTimeResolver enforces RFC 3339 formatting, normalizes all offsets to UTC, and serializes output in UTC.examples/todo-with-auth0/packages/backend/src/plugins/graphql/builder.ts (1)
36-40: LGTM! JSON/JSONObject scalar types properly defined.The scalar type definitions are appropriate:
JSONusesunknownfor maximum flexibility with arbitrary JSON valuesJSONObjectusesRecord<string, unknown>to enforce object structureexamples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date.ts (1)
1-16: Excellent migration to graphql-scalars.The replacement of custom Date scalar logic with
DateResolversimplifies the codebase and delegates parsing/serialization to a well-maintained library. The JSDoc clearly documents the RFC 3339 format and UTC normalization behavior.examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/date-time.ts (1)
1-24: LGTM! Clean DateTime scalar migration.The implementation correctly uses
DateTimeResolverfrom graphql-scalars, and the JSDoc examples effectively illustrate timezone handling (both UTC and offset formats).examples/todo-with-auth0/packages/web/src/route-tree.gen.ts (1)
11-77: Auto-generated formatting changes.These are punctuation-only changes (semicolon removal) in a TanStack Router generated file. No functional impact.
examples/todo-with-auth0/packages/admin/src/route-tree.gen.ts (1)
11-326: Auto-generated formatting changes.Consistent with the web package's route tree, these are punctuation-only changes (semicolon removal) from the TanStack Router generator. No functional impact.
packages/fastify-generators/src/writers/pothos/scalars.ts (1)
59-63: LGTM! Consistent scalar definition.The
jsonObjectscalar is properly added toINBUILT_POTHOS_SCALARSwith structure and typing consistent with other scalar definitions likejsonanduuid.examples/blog-with-auth/packages/backend/baseplate/file-id-map.json (1)
57-58: LGTM! Scalar mappings correctly added.The file-id mappings for
jsonandjson-objectscalars follow the established pattern and correctly point to the corresponding source files.examples/todo-with-auth0/packages/backend/baseplate/file-id-map.json (1)
78-79: LGTM!The JSON and JSONObject scalar mappings follow the established pattern and are correctly placed within the pothos-scalar namespace alongside the other scalar types.
examples/todo-with-auth0/packages/backend/src/modules/graphql/index.ts (1)
6-7: LGTM!The scalar imports follow the established pattern and correctly use
.jsextensions as required by the coding guidelines for Node 16 module resolution.examples/blog-with-auth/packages/backend/src/modules/graphql/index.ts (1)
6-7: LGTM!The scalar imports are consistent with the todo-with-auth0 example and follow all coding guidelines.
examples/blog-with-auth/packages/backend/package.json (1)
56-56: LGTM!The addition of
graphql-scalarsaligns with the migration strategy documented in the changeset. The pinned version ensures consistency across environments.packages/fastify-generators/src/writers/prisma-schema/fields.ts (1)
91-91: LGTM!The
jsonObjectfield type correctly maps to Prisma'sJsontype, mirroring the existingjsonfield. Both GraphQL scalar types (JSON and JSONObject) share the same database representation while enforcing different validation rules at the GraphQL layer.packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json-object.ts (1)
1-28: LGTM!The template is well-structured with excellent JSDoc documentation that clearly explains:
- What JSONObject accepts (objects only)
- What it rejects (arrays, primitives, null)
- When to use JSONObject vs JSON scalar
The
@ts-nocheckdirective on Line 1 is acceptable for template files where placeholders like%pothosImportsare replaced during code generation.examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json-object.ts (1)
1-27: LGTM!The implementation correctly follows the template pattern and adheres to coding guidelines:
- Uses
@src/path alias as specified- Includes
.jsextension for Node 16 module resolution- Comprehensive JSDoc documentation
- Properly imports and registers the JSONObjectResolver from graphql-scalars
The scalar is correctly typed in the builder (as shown in the relevant code snippet from
builder.ts) asRecord<string, unknown>for both Input and Output.examples/todo-with-auth0/packages/backend/schema.graphql (3)
78-86: LGTM! Scalar documentation improved.The documentation updates for Date and DateTime scalars now correctly reference RFC 3339 format specifications, providing clearer guidance for API consumers.
157-165: LGTM! New JSON scalars added with clear documentation.The JSON and JSONObject scalar additions are well-documented and follow the same pattern as existing scalars. The distinction between JSON (any valid JSON) and JSONObject (objects only) is clearly explained.
445-447: LGTM! UUID documentation enhanced with reference link.The UUID scalar documentation now includes a Wikipedia reference for additional context.
examples/blog-with-auth/packages/backend/src/plugins/graphql/builder.ts (1)
36-40: LGTM! JSON scalar type definitions are appropriate.The type definitions correctly represent:
JSON: Usesunknownfor maximum flexibility with any valid JSON valueJSONObject: UsesRecord<string, unknown>to enforce object-only structureThese align well with the corresponding graphql-scalars resolvers.
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json-object.ts (1)
1-27: Add explicit return type annotation.The exported constant
JSONObjectScalarshould have an explicit return type annotation to comply with the coding guidelines.As per coding guidelines.
Apply this diff:
-export const JSONObjectScalar = builder.addScalarType( +export const JSONObjectScalar: ReturnType<typeof builder.addScalarType> = builder.addScalarType( 'JSONObject', JSONObjectResolver, {}, );Likely an incorrect or invalid review comment.
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/json.ts (1)
1-23: Add explicit return type annotation to template.As a generator template, this should include the return type annotation to ensure all generated code follows the project's coding guidelines.
As per coding guidelines.
Apply this diff:
-export const JSONScalar = builder.addScalarType('JSON', JSONResolver, {}); +export const JSONScalar: ReturnType<typeof builder.addScalarType> = builder.addScalarType('JSON', JSONResolver, {});Likely an incorrect or invalid review comment.
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date.ts (1)
1-17: Add explicit return type annotation to template.As a generator template, this should include the return type annotation to ensure all generated code follows the project's coding guidelines.
As per coding guidelines.
Apply this diff:
-export const DateScalar = builder.addScalarType('Date', DateResolver, {}); +export const DateScalar: ReturnType<typeof builder.addScalarType> = builder.addScalarType('Date', DateResolver, {});Likely an incorrect or invalid review comment.
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/json.ts (1)
1-22: Add explicit return type annotation.The exported constant
JSONScalarshould have an explicit return type annotation to comply with the coding guidelines for this project.As per coding guidelines, which state: "Always specify explicit return types for all functions" and "If a particular interface or type is not exported in a TypeScript file, modify the file to export it."
Apply this diff to add the return type:
-export const JSONScalar = builder.addScalarType('JSON', JSONResolver, {}); +export const JSONScalar: ReturnType<typeof builder.addScalarType> = builder.addScalarType('JSON', JSONResolver, {});Alternatively, if a more specific scalar type is available from
@pothos/core, use that instead ofReturnType.Likely an incorrect or invalid review comment.
examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/json.ts (1)
1-22: Add explicit return type annotation.The exported constant
JSONScalarshould have an explicit return type annotation to comply with the coding guidelines for this project.As per coding guidelines.
Apply this diff:
-export const JSONScalar = builder.addScalarType('JSON', JSONResolver, {}); +export const JSONScalar: ReturnType<typeof builder.addScalarType> = builder.addScalarType('JSON', JSONResolver, {});Likely an incorrect or invalid review comment.
packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/uuid.ts (1)
1-17: Add explicit return type annotation to template.Since this is a generator template, the missing return type annotation will be propagated to all generated code. Adding it here ensures all generated scalar files comply with the project's coding guidelines.
As per coding guidelines.
Apply this diff:
-export const UuidScalar = builder.addScalarType('Uuid', UUIDResolver, {}); +export const UuidScalar: ReturnType<typeof builder.addScalarType> = builder.addScalarType('Uuid', UUIDResolver, {});Likely an incorrect or invalid review comment.
examples/todo-with-auth0/packages/backend/src/modules/graphql/scalars/uuid.ts (1)
1-16: LGTM! Clean migration to graphql-scalars.The implementation correctly delegates UUID validation and serialization to the battle-tested
UUIDResolverfrom graphql-scalars, replacing custom validation logic. The JSDoc is comprehensive and includes clear examples.packages/fastify-generators/src/generators/pothos/pothos-scalar/templates/module/scalars/date-time.ts (1)
1-25: LGTM! Consistent template migration.The template correctly migrates to
DateTimeResolverfrom graphql-scalars. The JSDoc helpfully documents timezone handling behavior, which is important for DateTime scalars.examples/blog-with-auth/packages/backend/src/modules/graphql/scalars/uuid.ts (1)
1-16: LGTM! Consistent implementation across examples.This implementation is identical to the todo-with-auth0 example, ensuring consistency across the codebase. The migration to graphql-scalars is clean and correct.
packages/fastify-generators/src/generators/pothos/pothos-scalar/extractor.json (1)
32-57: JSON scalar template files verified
Both json.ts and json-object.ts exist under templates/module/scalars, matching the extractor configuration entries.packages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.ts (2)
139-139: Add explicit return type to run function.The
runfunction is missing an explicit return type annotation, which violates the coding guidelines requirement to "Always specify explicit return types for all functions."Based on the return statement at lines 156-171, add the following return type:
- run({ appModule, paths, pothosConfig, pothosImports, typescriptFile }) { + run({ appModule, paths, pothosConfig, pothosImports, typescriptFile }): { build: (builder: any) => Promise<void> } {⛔ Skipped due to learnings
Learnt from: CR PR: halfdomelabs/baseplate#0 File: examples/todo-with-auth0/CLAUDE.md:0-0 Timestamp: 2025-09-03T17:03:33.250Z Learning: Applies to examples/todo-with-auth0/packages/{admin,backend}/src/**/*.{ts,tsx} : Always specify explicit return types for all functionsLearnt from: CR PR: halfdomelabs/baseplate#0 File: examples/blog-with-auth/CLAUDE.md:0-0 Timestamp: 2025-09-03T17:02:31.412Z Learning: Applies to examples/blog-with-auth/packages/**/src/**/*.{ts,tsx} : Always specify explicit return types for all functions
49-106: ScalarFieldType already covers ‘json’ and ‘jsonObject’. Both literals appear in SCALAR_FIELD_TYPES, so no update is required.
| json: { | ||
| name: 'JSON', | ||
| scalar: 'json', | ||
| templatePath: 'json', | ||
| export: 'JSONScalar', | ||
| inputType: 'unknown', | ||
| outputType: 'unknown', | ||
| dependencies: { | ||
| 'graphql-scalars': FASTIFY_PACKAGES['graphql-scalars'], | ||
| }, | ||
| devDependencies: {}, | ||
| path: 'json.ts', | ||
| }, | ||
| jsonObject: { | ||
| name: 'JSONObject', | ||
| scalar: 'jsonObject', | ||
| templatePath: 'jsonObject', | ||
| export: 'JSONObjectScalar', | ||
| inputType: 'Record<string, unknown>', | ||
| outputType: 'Record<string, unknown>', | ||
| dependencies: { | ||
| 'graphql-scalars': FASTIFY_PACKAGES['graphql-scalars'], | ||
| }, | ||
| devDependencies: {}, | ||
| path: 'json-object.ts', | ||
| }, |
There was a problem hiding this comment.
Critical: Fix template key mismatch for jsonObject.
The templatePath for jsonObject uses camelCase 'jsonObject' (line 97), but the extractor.json defines the template key as kebab-case 'json-object' (extractor.json line 45). This mismatch will cause a runtime error when the generator tries to access the template at lines 161-163.
Apply this diff to fix the template key:
jsonObject: {
name: 'JSONObject',
scalar: 'jsonObject',
- templatePath: 'jsonObject',
+ templatePath: 'json-object',
export: 'JSONObjectScalar',
inputType: 'Record<string, unknown>',
outputType: 'Record<string, unknown>',📝 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.
| json: { | |
| name: 'JSON', | |
| scalar: 'json', | |
| templatePath: 'json', | |
| export: 'JSONScalar', | |
| inputType: 'unknown', | |
| outputType: 'unknown', | |
| dependencies: { | |
| 'graphql-scalars': FASTIFY_PACKAGES['graphql-scalars'], | |
| }, | |
| devDependencies: {}, | |
| path: 'json.ts', | |
| }, | |
| jsonObject: { | |
| name: 'JSONObject', | |
| scalar: 'jsonObject', | |
| templatePath: 'jsonObject', | |
| export: 'JSONObjectScalar', | |
| inputType: 'Record<string, unknown>', | |
| outputType: 'Record<string, unknown>', | |
| dependencies: { | |
| 'graphql-scalars': FASTIFY_PACKAGES['graphql-scalars'], | |
| }, | |
| devDependencies: {}, | |
| path: 'json-object.ts', | |
| }, | |
| json: { | |
| name: 'JSON', | |
| scalar: 'json', | |
| templatePath: 'json', | |
| export: 'JSONScalar', | |
| inputType: 'unknown', | |
| outputType: 'unknown', | |
| dependencies: { | |
| 'graphql-scalars': FASTIFY_PACKAGES['graphql-scalars'], | |
| }, | |
| devDependencies: {}, | |
| path: 'json.ts', | |
| }, | |
| jsonObject: { | |
| name: 'JSONObject', | |
| scalar: 'jsonObject', | |
| templatePath: 'json-object', | |
| export: 'JSONObjectScalar', | |
| inputType: 'Record<string, unknown>', | |
| outputType: 'Record<string, unknown>', | |
| dependencies: { | |
| 'graphql-scalars': FASTIFY_PACKAGES['graphql-scalars'], | |
| }, | |
| devDependencies: {}, | |
| path: 'json-object.ts', | |
| }, |
🤖 Prompt for AI Agents
In
packages/fastify-generators/src/generators/pothos/pothos-scalar/pothos-scalar.generator.ts
around lines 81 to 106, the jsonObject entry uses templatePath: 'jsonObject'
which does not match the extractor.json template key 'json-object'; update the
jsonObject.templatePath value to 'json-object' so the generator can find the
correct template, then run the generator/tests to verify no template-not-found
errors.
Summary by CodeRabbit