Background
The dashboard has two parallel React Query caches for the exact same export_metadata payload:
|
useMetadataQuery (legacy) |
useExportMetadata (current) |
| Path |
database/dataGrid/hooks/useMetadataQuery/ |
common/hooks/useExportMetadata/ |
| Cache key |
caller-supplied (in practice always 'default.metadata') |
[EXPORT_METADATA_QUERY_KEY, project?.subdomain] |
| Stale time |
none (default) |
5 min |
| Refetch on focus |
yes (default) |
no |
| Returns |
one source pre-narrowed (Partial<HasuraMetadataSource> & { resourceVersion }) |
full ExportMetadataResponse; callers narrow with select |
| Endpoint |
POST /v1/metadata { type: 'export_metadata', version: 2 } |
same, via generated Orval client |
Mutations that touch metadata currently have to invalidate both keys to keep the UI consistent (see RolePermissionEditorForm.tsx, StorageRolePermissionEditorForm.tsx). This is easy to forget — and any site that forgets one of the two ends up reading stale data.
Proposal
Migrate all useMetadataQuery(['default.metadata'], ...) call sites to useExportMetadata, passing a select to derive the slice they need, then delete useMetadataQuery / fetchMetadata.
Call sites to migrate
Reads:
database/dataGrid/components/ColumnAutocomplete/ColumnAutocomplete.tsx:104
database/dataGrid/components/EditPermissionsForm/EditPermissionsForm.tsx:83
database/dataGrid/components/CustomCheckEditor/TableComboBox.tsx:33
database/dataGrid/components/CustomCheckEditor/RelationshipNodeRenderer.tsx:44
database/dataGrid/components/CustomCheckEditor/AddNodeButton.tsx:52
database/dataGrid/components/CustomCheckEditor/RelationshipComboBox.tsx:49
storage/dataGrid/components/EditStoragePermissions/StoragePermissionsForm.tsx:48
Invalidations to drop (the EXPORT_METADATA_QUERY_KEY invalidation right next to each already covers it):
database/dataGrid/components/EditPermissionsForm/RolePermissionEditorForm.tsx:240
storage/dataGrid/components/EditStoragePermissions/StorageRolePermissionEditorForm.tsx:161, 203
Acceptance
useMetadataQuery, fetchMetadata, and the 'default.metadata' string are gone from the codebase.
- All metadata reads go through
useExportMetadata with a select.
- Mutation handlers invalidate only
[EXPORT_METADATA_QUERY_KEY, project?.subdomain].
Background
The dashboard has two parallel React Query caches for the exact same
export_metadatapayload:useMetadataQuery(legacy)useExportMetadata(current)database/dataGrid/hooks/useMetadataQuery/common/hooks/useExportMetadata/'default.metadata')[EXPORT_METADATA_QUERY_KEY, project?.subdomain]Partial<HasuraMetadataSource> & { resourceVersion })ExportMetadataResponse; callers narrow withselectPOST /v1/metadata{ type: 'export_metadata', version: 2 }Mutations that touch metadata currently have to invalidate both keys to keep the UI consistent (see
RolePermissionEditorForm.tsx,StorageRolePermissionEditorForm.tsx). This is easy to forget — and any site that forgets one of the two ends up reading stale data.Proposal
Migrate all
useMetadataQuery(['default.metadata'], ...)call sites touseExportMetadata, passing aselectto derive the slice they need, then deleteuseMetadataQuery/fetchMetadata.Call sites to migrate
Reads:
database/dataGrid/components/ColumnAutocomplete/ColumnAutocomplete.tsx:104database/dataGrid/components/EditPermissionsForm/EditPermissionsForm.tsx:83database/dataGrid/components/CustomCheckEditor/TableComboBox.tsx:33database/dataGrid/components/CustomCheckEditor/RelationshipNodeRenderer.tsx:44database/dataGrid/components/CustomCheckEditor/AddNodeButton.tsx:52database/dataGrid/components/CustomCheckEditor/RelationshipComboBox.tsx:49storage/dataGrid/components/EditStoragePermissions/StoragePermissionsForm.tsx:48Invalidations to drop (the
EXPORT_METADATA_QUERY_KEYinvalidation right next to each already covers it):database/dataGrid/components/EditPermissionsForm/RolePermissionEditorForm.tsx:240storage/dataGrid/components/EditStoragePermissions/StorageRolePermissionEditorForm.tsx:161, 203Acceptance
useMetadataQuery,fetchMetadata, and the'default.metadata'string are gone from the codebase.useExportMetadatawith aselect.[EXPORT_METADATA_QUERY_KEY, project?.subdomain].