Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions apis/api-gateway/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2199,6 +2199,18 @@ 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_JOURNEYS_MODERN, key: "id", extension: true) @join__type(graph: API_LANGUAGES, key: "id", extension: true) @join__type(graph: API_MEDIA, key: "id", extension: true) @join__type(graph: API_USERS, key: "id") {
id: ID!
languageUserRoles: [LanguageRole!]! @join__field(graph: API_LANGUAGES)
mediaUserRoles: [MediaRole!]! @join__field(graph: API_MEDIA)
firstName: String! @join__field(graph: API_USERS)
lastName: String @join__field(graph: API_USERS)
email: String! @join__field(graph: API_USERS)
imageUrl: String @join__field(graph: API_USERS)
superAdmin: Boolean @join__field(graph: API_USERS)
emailVerified: Boolean! @join__field(graph: API_USERS)
}

type UserTeamInvite @join__type(graph: API_JOURNEYS) @join__type(graph: API_JOURNEYS_MODERN) {
id: ID!
teamId: ID!
Expand Down Expand Up @@ -3257,16 +3269,6 @@ type ZodFieldError @join__type(graph: API_MEDIA) {
path: [String!]!
}

type AuthenticatedUser @join__type(graph: API_USERS, key: "id") {
id: ID!
firstName: String!
lastName: String
email: String!
imageUrl: String
superAdmin: Boolean
emailVerified: Boolean!
}

interface BaseError @join__type(graph: API_ANALYTICS) @join__type(graph: API_MEDIA) {
message: String
}
Expand Down Expand Up @@ -3738,21 +3740,25 @@ enum PlausibleEvent @join__type(graph: API_JOURNEYS_MODERN) {
journeyResponses @join__enumValue(graph: API_JOURNEYS_MODERN)
}

enum LanguageRole @join__type(graph: API_LANGUAGES) {
publisher @join__enumValue(graph: API_LANGUAGES)
}

enum LanguageIdType @join__type(graph: API_LANGUAGES) {
databaseId @join__enumValue(graph: API_LANGUAGES)
bcp47 @join__enumValue(graph: API_LANGUAGES)
}

enum LanguageRole @join__type(graph: API_LANGUAGES) {
publisher @join__enumValue(graph: API_LANGUAGES)
}

enum DefaultPlatform @join__type(graph: API_MEDIA) {
ios @join__enumValue(graph: API_MEDIA)
android @join__enumValue(graph: API_MEDIA)
web @join__enumValue(graph: API_MEDIA)
}

enum MediaRole @join__type(graph: API_MEDIA) {
publisher @join__enumValue(graph: API_MEDIA)
}

enum ImageAspectRatio @join__type(graph: API_MEDIA) {
hd @join__enumValue(graph: API_MEDIA)
banner @join__enumValue(graph: API_MEDIA)
Expand All @@ -3764,10 +3770,6 @@ enum MaxResolutionTier @join__type(graph: API_MEDIA) {
uhd @join__enumValue(graph: API_MEDIA)
}

enum MediaRole @join__type(graph: API_MEDIA) {
publisher @join__enumValue(graph: API_MEDIA)
}

enum SegmindModel @join__type(graph: API_MEDIA) {
sdxl1__0_txt2img @join__enumValue(graph: API_MEDIA)
kandinsky2__2_txt2img @join__enumValue(graph: API_MEDIA)
Expand Down
7 changes: 7 additions & 0 deletions apis/api-journeys-modern/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ interface Action {
parentBlock: Block!
}

type AuthenticatedUser
@key(fields: "id")
@extends
{
id: ID! @external
}

interface Block {
id: ID!
journeyId: ID!
Expand Down
2 changes: 1 addition & 1 deletion apis/api-journeys-modern/src/schema/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import './user'

export { UserRef } from './user'
export { AuthenticatedUserRef, UserRef } from './user'
14 changes: 14 additions & 0 deletions apis/api-journeys-modern/src/schema/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})
8 changes: 7 additions & 1 deletion apis/api-journeys/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2739,6 +2739,12 @@ enum Role {
publisher
}

extend type AuthenticatedUser
@key(fields: "id")
{
id: ID! @external
}

enum UserTeamRole {
manager
member
Expand Down Expand Up @@ -3048,4 +3054,4 @@ type _Service {
sdl: String
}

union _Entity = Journey | JourneyProfile | JourneyVisitor | Language | ShortLink | Tag | Team | User | UserInvite | UserJourney | UserRole | UserTeam | Video | VideoBlock | Visitor
union _Entity = AuthenticatedUser | Journey | JourneyProfile | JourneyVisitor | Language | ShortLink | Tag | Team | User | UserInvite | UserJourney | UserRole | UserTeam | Video | VideoBlock | Visitor
18 changes: 18 additions & 0 deletions apis/api-journeys/src/__generated__/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apis/api-journeys/src/app/__generated__/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apis/api-journeys/src/app/modules/userTeam/userTeam.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ extend type User @key(fields: "id") {
id: ID! @external
}

extend type AuthenticatedUser @key(fields: "id") {
id: ID! @external
}

enum UserTeamRole {
manager
member
Expand Down
8 changes: 8 additions & 0 deletions apis/api-languages/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ type AudioPreview
codec: String!
}

type AuthenticatedUser
@key(fields: "id")
@extends
{
id: ID! @external
languageUserRoles: [LanguageRole!]!
}

type Continent {
id: ID!
name(languageId: ID, primary: Boolean): [ContinentName!]!
Expand Down
23 changes: 23 additions & 0 deletions apis/api-languages/src/schema/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,26 @@ builder.externalRef('User', builder.selection<{ id: string }>('id')).implement({
})
})
})

builder
.externalRef('AuthenticatedUser', builder.selection<{ id: string }>('id'))
.implement({
externalFields: (t) => ({
id: t.id({ nullable: false })
}),
fields: (t) => ({
languageUserRoles: t.field({
type: [LanguageRole],
nullable: false,
resolve: async (data) => {
return (
(
await prisma.userLanguageRole.findUnique({
where: { userId: data.id }
})
)?.roles ?? []
)
}
})
})
})
8 changes: 8 additions & 0 deletions apis/api-media/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ type ArclightApiKey
defaultPlatform: DefaultPlatform!
}

type AuthenticatedUser
@key(fields: "id")
@extends
{
id: ID! @external
mediaUserRoles: [MediaRole!]!
}

interface BaseError {
message: String
}
Expand Down
2 changes: 1 addition & 1 deletion apis/api-media/src/schema/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './enums'
import './user'

export { UserRef } from './user'
export { AuthenticatedUserRef, UserRef } from './user'
26 changes: 26 additions & 0 deletions apis/api-media/src/schema/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,29 @@ UserRef.implement({
})
})
})

export const AuthenticatedUserRef = builder.externalRef(
'AuthenticatedUser',
builder.selection<{ id: string }>('id')
)

AuthenticatedUserRef.implement({
externalFields: (t) => ({
id: t.id({ nullable: false })
}),
fields: (t) => ({
mediaUserRoles: t.field({
type: [MediaRole],
nullable: false,
resolve: async (data) => {
return (
(
await prisma.userMediaRole.findUnique({
where: { id: data.id }
})
)?.roles ?? []
)
}
})
})
})
2 changes: 1 addition & 1 deletion libs/shared/gql/src/__generated__/graphql-env.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.