Skip to content

gql/inviteLinks: Remove Capability enum type reference#1981

Open
jshearer wants to merge 1 commit into
mainfrom
jshearer/stop_naming_capability_temporarily
Open

gql/inviteLinks: Remove Capability enum type reference#1981
jshearer wants to merge 1 commit into
mainfrom
jshearer/stop_naming_capability_temporarily

Conversation

@jshearer
Copy link
Copy Markdown
Contributor

Summary

The CreateInviteLink mutation declared $capability: Capability!, embedding the GraphQL enum type name in the query string. The upcoming authz refactor renames Capability to LegacyCapability, which would cause this query to fail.

This change replaces the typed variable with a fixed per-value mutation that inlines the capability as an unquoted GraphQL enum literal (e.g. capability: admin), so the query body no longer references the enum type by name. After this lands, the backend rename can proceed without a coordinated UI deploy.

Implementation

  • src/api/gql/inviteLinks.ts: three static mutations (one per allowed value), exported as CREATE_INVITE_LINK_BY_CAPABILITY map. Static mutations rather than ${capability} interpolation because the client codegen preset extracts query strings statically.
  • isCreateInviteLinkCapability runtime guard prevents any value outside admin | read | write from reaching the map lookup.
  • GenerateInvitation.tsx: selects the mutation by current capability state and drops capability from the variables payload. The capability useState declaration moved above useMutation to satisfy hook ordering.

Other queries that select userCapability fields and the hand-written Capability type import in GenerateInvitation.tsx are intentionally untouched. Those are wire-format stable across the rename and only need a codegen rerun in a follow-up PR.

@jshearer jshearer requested a review from GregorShear May 26, 2026 19:40
@jshearer jshearer requested a review from a team as a code owner May 26, 2026 19:40
@jshearer jshearer self-assigned this May 26, 2026
@jshearer jshearer force-pushed the jshearer/stop_naming_capability_temporarily branch from 8fe1067 to 3655eea Compare May 26, 2026 21:01
…InviteLink`

The mutation declared `$capability: Capability!`, embedding the GraphQL enum type name in the query body. An upcoming backend rename of `Capability` to `LegacyCapability` would cause this query to fail server-side parsing. Replace the typed variable with a fixed per-value mutation that inlines the capability as an enum literal.

This is just temporary, as once the new authorization system is live we'll be refactoring this whole thing.
@jshearer jshearer force-pushed the jshearer/stop_naming_capability_temporarily branch from 3655eea to 85fa019 Compare May 26, 2026 21:19
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.

2 participants