Skip to content

refactor(shield)!: createRule mirrors rule signature; doc + 3.0.0-beta.7#143

Merged
cuzzlor merged 2 commits intomainfrom
docs/base-request-info-jsdoc-and-bump
Apr 26, 2026
Merged

refactor(shield)!: createRule mirrors rule signature; doc + 3.0.0-beta.7#143
cuzzlor merged 2 commits intomainfrom
docs/base-request-info-jsdoc-and-bump

Conversation

@cuzzlor
Copy link
Copy Markdown
Collaborator

@cuzzlor cuzzlor commented Apr 26, 2026

Summary

  • Breaking: createRule now mirrors graphql-shield's rule() — curried createRule(name?, options?)(fn) instead of createRule(fn, cache?). The implicit 'strict' cache default is removed; pass { cache: 'strict' } explicitly if needed.
  • Strongly types parent, args, ctx (and adds info: GraphQLResolveInfo) on the inner fn via generics; return type now matches shield's boolean | string | Error.
  • Add interface-level and per-property JSDoc to BaseRequestInfo in src/request-info.ts, clarifying that url is a path + query string (combine with baseUrl for the absolute URL).
  • README createRule section updated for the new signature.
  • Bump version 3.0.0-beta.63.0.0-beta.7.

Migration

// before
const isOwner = createRule<Ctx, Parent>((p, _, c) => p.ownerId === c.user?.id, 'contextual')

// after
const isOwner = createRule<Ctx, Parent>(undefined, { cache: 'contextual' })(
  (p, _, c) => p.ownerId === c.user?.id,
)

Test plan

  • CI passes (typecheck, lint, build).
  • Downstream consumers updated to the curried call form.

🤖 Generated with Claude Code

cuzzlor and others added 2 commits April 26, 2026 15:18
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
BREAKING CHANGE: createRule is now curried as createRule(name?, options?)(fn),
matching graphql-shield's rule(). The previous (fn, cache?) form and the
implicit 'strict' cache default are removed — pass { cache: 'strict' }
explicitly if needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cuzzlor cuzzlor changed the title doc: add JSDoc to BaseRequestInfo, bump to 3.0.0-beta.7 refactor(shield)!: createRule mirrors rule signature; doc + 3.0.0-beta.7 Apr 26, 2026
@cuzzlor cuzzlor merged commit d90eac3 into main Apr 26, 2026
2 checks passed
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