diff --git a/apis/api-gateway/schema.graphql b/apis/api-gateway/schema.graphql index 16bc417680f..f6a96c81fb0 100644 --- a/apis/api-gateway/schema.graphql +++ b/apis/api-gateway/schema.graphql @@ -2199,7 +2199,7 @@ type UserRole @join__type(graph: API_JOURNEYS, key: "id") @join__type(graph: AP roles: [Role!] } -type AuthenticatedUser @join__type(graph: API_JOURNEYS, key: "id", extension: true) @join__type(graph: API_USERS, key: "id") { +type AuthenticatedUser @join__type(graph: API_JOURNEYS, key: "id", extension: true) @join__type(graph: API_JOURNEYS_MODERN, key: "id", extension: true) @join__type(graph: API_USERS, key: "id") { id: ID! firstName: String! @join__field(graph: API_USERS) lastName: String @join__field(graph: API_USERS) diff --git a/apis/api-journeys-modern/schema.graphql b/apis/api-journeys-modern/schema.graphql index cdefbabbfdb..0ee985a166e 100644 --- a/apis/api-journeys-modern/schema.graphql +++ b/apis/api-journeys-modern/schema.graphql @@ -7,6 +7,13 @@ interface Action { parentBlock: Block! } +type AuthenticatedUser + @key(fields: "id") + @extends +{ + id: ID! @external +} + interface Block { id: ID! journeyId: ID! diff --git a/apis/api-journeys-modern/src/schema/user/index.ts b/apis/api-journeys-modern/src/schema/user/index.ts index ddac8a72157..51b52301de8 100644 --- a/apis/api-journeys-modern/src/schema/user/index.ts +++ b/apis/api-journeys-modern/src/schema/user/index.ts @@ -1,3 +1,3 @@ import './user' -export { UserRef } from './user' +export { AuthenticatedUserRef, UserRef } from './user' diff --git a/apis/api-journeys-modern/src/schema/user/user.ts b/apis/api-journeys-modern/src/schema/user/user.ts index 30b98bee598..c8645a8c4dc 100644 --- a/apis/api-journeys-modern/src/schema/user/user.ts +++ b/apis/api-journeys-modern/src/schema/user/user.ts @@ -13,3 +13,17 @@ UserRef.implement({ // No additional fields needed - this is just the external reference }) }) + +// Define the federated AuthenticatedUser type reference - this should only be defined once +export const AuthenticatedUserRef = builder.externalRef( + 'AuthenticatedUser', + builder.selection<{ id: string }>('id') +) + +// Implement the external fields for the AuthenticatedUser type +AuthenticatedUserRef.implement({ + externalFields: (t) => ({ id: t.id({ nullable: false }) }), + fields: (t) => ({ + // No additional fields needed - this is just the external reference + }) +})