Skip to content

chore(docs): gqlorm auth implementation plan (not)#1783

Merged
Tobbe merged 1 commit into
mainfrom
tobbe-gqlorm-auth-doc
May 14, 2026
Merged

chore(docs): gqlorm auth implementation plan (not)#1783
Tobbe merged 1 commit into
mainfrom
tobbe-gqlorm-auth-doc

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented May 14, 2026

AI slop vomit. Just wanted to keep this here for AI to reference later

@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for cedarjs ready!

Name Link
🔨 Latest commit 1347a20
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6a05db4ac45e8a000877b649
😎 Deploy Preview https://deploy-preview-1783--cedarjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added this to the chore milestone May 14, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR adds an AI-generated planning document (docs/implementation-plans/gqlorm-auth-scoping-implementation-plan.md) describing a three-stage strategy to introduce proper auth scoping into the gqlorm generated backend, replacing today's hard-coded userId/organizationId convention branches with pluggable model-level scope providers. No code is changed.

  • The plan's description of the current architecture is largely accurate against the actual source, but three factual gaps were found: a frontend/backend pluralization mismatch, the GqlormDb interface not including findFirst for non-membership scoped models, and the Stage 2 schema shape using first: Int where the frontend query builder uses Prisma's take convention.
  • The docs/implementation-docs/2026-03-26-cedarjs-project-overview.md overview file remains factually correct — no code was changed and the overview's gqlorm description still accurately reflects the codebase.

Confidence Score: 4/5

Docs-only change; no runtime behavior is affected and the project overview remains accurate, but the plan itself contains factual gaps that future implementers should be aware of before treating it as a reliable reference.

The change is purely a documentation addition with no code modifications. The three factual issues found are all in the planning document itself — anyone using the plan as a spec without cross-checking the real code could introduce bugs, but merging this file as a reference artifact carries no direct runtime risk.

docs/implementation-plans/gqlorm-auth-scoping-implementation-plan.md — three sections describe current or proposed behavior that doesn't quite match the actual codebase

Important Files Changed

Filename Overview
docs/implementation-plans/gqlorm-auth-scoping-implementation-plan.md New AI-generated implementation plan for gqlorm auth scoping; directionally accurate but contains factual gaps around pluralization, the GqlormDb interface, and a first vs take naming inconsistency in the Stage 2 schema proposal

Reviews (1): Last reviewed commit: "chore(docs): gqlorm auth implementation ..." | Re-trigger Greptile

Comment on lines +148 to +151

1. **Per-model scoping is the right abstraction**
- The current implementation already reasons per model during codegen.
- Replacing hard-coded convention branches with per-model scope providers
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.

P1 Frontend pluralization doesn't match backend codegen

The plan states the frontend "generates GraphQL query documents" with a plural field for findMany, implying the generated field names align with the backend. They don't — packages/gqlorm/src/generator/graphqlGenerator.ts uses naive ${model}s (append-s) pluralization, and even has a // TODO: Use Cedar's pluralization function comment acknowledging the gap. The backend codegen uses pluralize(camelName) from @cedarjs/utils/cedarPluralize. For any model with an irregular plural (Person → people, Category → categories), the frontend would query a field that doesn't exist in the generated backend schema. This divergence is directly relevant to Stages 1–2, which assume the frontend and backend field names are already aligned.

Comment on lines +470 to +475
- add tests for `defineGqlormAuth`, merge helpers, and scope result semantics

#### `packages/internal/src/generate/gqlormSchema.ts`

- add auth config file detection
- refactor current auth emission logic
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.

P1 GqlormDb interface doesn't include findFirst for scoped non-membership models

The plan recommends using findFirst internally for all scoped singular queries (to merge id lookup with an auth where clause). However, the current generateGqlormBackendContent in gqlormSchema.ts only adds findFirst to the GqlormDb interface for the membership model when anyModelNeedsOrgScoping is true — not for the other models being scoped. Implementing item 7 without also updating the interface-generation loop would produce TypeScript errors in the generated backend.ts for any scoped model that tries to call db.<model>.findFirst(…).

Comment on lines +547 to +554

- `where`
- `orderBy`
- `first`
- `skip`

for singular and plural operations.

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.

P1 first: Int should be take: Int to match frontend query builder conventions

The proposed Stage 2 plural field shape uses first: Int as the limit argument, but the frontend QueryBuilder / FindManyArgs uses Prisma's take convention throughout. If the generated backend SDL exposes a first argument and the frontend generator sends take, the limit will be silently ignored on every paginated query. The arg should be take: Int (or the frontend generator updated in the same stage to emit first) so both sides agree.

@Tobbe Tobbe merged commit ced63d0 into main May 14, 2026
33 checks passed
@Tobbe Tobbe deleted the tobbe-gqlorm-auth-doc branch May 14, 2026 17:14
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.

1 participant