Split trust node lookup into node and aliasedNode

The trust node query previously accepted a String and resolved both GIDs
and slugs through one field, which forced the frontend to lose the ID
type guarantee. Restore node(id: ID!) as a strict GID lookup and add a
dedicated aliasedNode(alias: String!) that parses a GID first and falls
back to slug resolution before delegating to Node.

Inline the former nodeByGID switch directly into Node and drop the helper
file. Point the trust DocumentPage query at aliasedNode so slug-or-ID URLs
keep working.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-06-22 11:24:43 +02:00
parent bfd672e0fe
commit cb7fb8f5e9
5 changed files with 138 additions and 164 deletions

View File

@@ -45,7 +45,7 @@ import type { DocumentPageRequestReportAccessMutation } from "./__generated__/Do
import type { DocumentPageRequestTrustCenterFileAccessMutation } from "./__generated__/DocumentPageRequestTrustCenterFileAccessMutation.graphql";
export const documentPageQuery = graphql`
query DocumentPageQuery($id: String!) {
query DocumentPageQuery($alias: String!) {
currentTrustCenter {
logo {
downloadUrl
@@ -54,7 +54,7 @@ export const documentPageQuery = graphql`
downloadUrl
}
}
node(id: $id) @required(action: THROW) {
aliasedNode(alias: $alias) @required(action: THROW) {
__typename
... on Document {
id
@@ -183,7 +183,7 @@ function extractMimeType(dataUri: string): string {
return match?.[1] ?? "application/octet-stream";
}
function getNodeTitle(node: DocumentPageQueryType["response"]["node"]): string | undefined {
function getNodeTitle(node: DocumentPageQueryType["response"]["aliasedNode"]): string | undefined {
switch (node.__typename) {
case "Document":
return node.title;
@@ -196,7 +196,7 @@ function getNodeTitle(node: DocumentPageQueryType["response"]["node"]): string |
}
}
function getNodeId(node: DocumentPageQueryType["response"]["node"]): string | undefined {
function getNodeId(node: DocumentPageQueryType["response"]["aliasedNode"]): string | undefined {
switch (node.__typename) {
case "Document":
case "TrustCenterFile":
@@ -220,7 +220,7 @@ export function DocumentPage({ queryRef }: Props) {
const data = usePreloadedQuery<DocumentPageQueryType>(documentPageQuery, queryRef);
const trustCenter = data.currentTrustCenter;
const node = data.node;
const node = data.aliasedNode;
if (
node.__typename !== "Document"

View File

@@ -27,7 +27,7 @@ function DocumentPageQueryLoader() {
useEffect(() => {
if (documentId) {
loadQuery({ id: documentId });
loadQuery({ alias: documentId });
}
}, [documentId, loadQuery]);