diff --git a/src/api/arenaApi.ts b/src/api/arenaApi.ts index 00296b29..9cdefdf3 100644 --- a/src/api/arenaApi.ts +++ b/src/api/arenaApi.ts @@ -14,6 +14,7 @@ import { GQLArenaTopic, GQLArenaUser, GQLBaseUser, + GQLFullArenaUser, GQLMutationNewArenaTopicArgs, GQLMutationReplyToTopicArgs, GQLQueryArenaCategoryArgs, @@ -27,11 +28,16 @@ const toBaseUser = (user: any): Omit => ({ id: user.uid, displayName: user.displayname, username: user.username, - location: user.location, profilePicture: user.picture, slug: user.userslug, }); +const toFullArenaUser = (user: any): GQLFullArenaUser => ({ + ...toBaseUser(user), + location: user.location, + groupTitleArray: user.groupTitleArray, +}); + const toArenaUser = (user: any): GQLArenaUser => ({ ...toBaseUser(user), groupTitleArray: user.groupTitleArray, @@ -131,13 +137,13 @@ export const fetchCsrfTokenForSession = async ( export const fetchArenaUser = async ( { username }: GQLQueryArenaUserArgs, context: Context, -): Promise => { +): Promise => { const response = await fetch( `/groups/api/user/username/${username}`, context, ); const resolved: any = await resolveJson(response); - return toArenaUser(resolved); + return toFullArenaUser(resolved); }; export const fetchArenaCategories = async ( diff --git a/src/resolvers/arenaResolvers.ts b/src/resolvers/arenaResolvers.ts index 728d9e57..f1c99ebf 100644 --- a/src/resolvers/arenaResolvers.ts +++ b/src/resolvers/arenaResolvers.ts @@ -14,14 +14,13 @@ import { fetchArenaTopic, fetchArenaTopicsByUser, fetchArenaNotifications, - fetchCsrfTokenForSession, newTopic, replyToTopic, } from '../api/arenaApi'; import { GQLArenaCategory, - GQLArenaUser, GQLArenaTopic, + GQLFullArenaUser, GQLQueryArenaCategoryArgs, GQLQueryArenaUserArgs, GQLQueryArenaTopicArgs, @@ -47,7 +46,7 @@ export const Query: Pick< _: any, params: GQLQueryArenaUserArgs, context: ContextWithLoaders, - ): Promise { + ): Promise { return fetchArenaUser(params, context); }, async arenaCategories( diff --git a/src/resolvers/index.ts b/src/resolvers/index.ts index 7240041b..5d3d4a55 100644 --- a/src/resolvers/index.ts +++ b/src/resolvers/index.ts @@ -71,7 +71,6 @@ import { import { Query as ArenaQuery, - resolvers as ArenaResolvers, Mutations as ArenaMutations, } from './arenaResolvers'; @@ -113,7 +112,6 @@ export const resolvers = { ...uptimeResolvers, ...ImageResolvers, ...ProgrammeResolvers, - ...ArenaResolvers, TaxonomyEntity: { // Resolves TaxonomyEntity interface __resolveType(entity: any) { diff --git a/src/schema.ts b/src/schema.ts index 7db1102c..b6df67fc 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1199,7 +1199,7 @@ export const typeDefs = gql` slug: String! } - type ArenaUser implements BaseUser { + type FullArenaUser implements BaseUser { id: Int! displayName: String! username: String! @@ -1209,6 +1209,15 @@ export const typeDefs = gql` groupTitleArray: [String!]! } + type ArenaUser implements BaseUser { + id: Int! + displayName: String! + username: String! + profilePicture: String + slug: String! + groupTitleArray: [String!]! + } + type ArenaNotificationUser implements BaseUser { id: Int! displayName: String! @@ -1392,7 +1401,7 @@ export const typeDefs = gql` resourceEmbeds(resources: [ResourceEmbedInput!]!): ResourceEmbed! arenaCategories: [ArenaCategory!]! arenaCategory(categoryId: Int!, page: Int!): ArenaCategory - arenaUser(username: String!): ArenaUser + arenaUser(username: String!): FullArenaUser arenaTopic(topicId: Int!, page: Int): ArenaTopic arenaRecentTopics: [ArenaTopic!]! arenaTopicsByUser(userSlug: String!): [ArenaTopic!]! diff --git a/src/types/schema.d.ts b/src/types/schema.d.ts index aff51de9..656ce5a7 100644 --- a/src/types/schema.d.ts +++ b/src/types/schema.d.ts @@ -99,7 +99,6 @@ export type GQLArenaUser = GQLBaseUser & { displayName: Scalars['String']; groupTitleArray: Array; id: Scalars['Int']; - location?: Maybe; profilePicture?: Maybe; slug: Scalars['String']; username: Scalars['String']; @@ -593,6 +592,17 @@ export type GQLFrontpageSearchResult = { subject: Scalars['String']; }; +export type GQLFullArenaUser = GQLBaseUser & { + __typename?: 'FullArenaUser'; + displayName: Scalars['String']; + groupTitleArray: Array; + id: Scalars['Int']; + location?: Maybe; + profilePicture?: Maybe; + slug: Scalars['String']; + username: Scalars['String']; +}; + export type GQLGloss = { __typename?: 'Gloss'; examples?: Maybe>>; @@ -1156,7 +1166,7 @@ export type GQLQuery = { arenaRecentTopics: Array; arenaTopic?: Maybe; arenaTopicsByUser: Array; - arenaUser?: Maybe; + arenaUser?: Maybe; article?: Maybe; articleResource?: Maybe; audio?: Maybe; @@ -1959,7 +1969,7 @@ export type GQLResolversTypes = { AudioLicense: ResolverTypeWrapper; AudioSearch: ResolverTypeWrapper; AudioSummary: ResolverTypeWrapper; - BaseUser: GQLResolversTypes['ArenaNotificationUser'] | GQLResolversTypes['ArenaUser']; + BaseUser: GQLResolversTypes['ArenaNotificationUser'] | GQLResolversTypes['ArenaUser'] | GQLResolversTypes['FullArenaUser']; Boolean: ResolverTypeWrapper; Breadcrumb: ResolverTypeWrapper; BrightcoveCustomFields: ResolverTypeWrapper; @@ -2000,6 +2010,7 @@ export type GQLResolversTypes = { FrontpageMenu: ResolverTypeWrapper; FrontpageSearch: ResolverTypeWrapper; FrontpageSearchResult: ResolverTypeWrapper; + FullArenaUser: ResolverTypeWrapper; Gloss: ResolverTypeWrapper; GlossLicense: ResolverTypeWrapper; Grade: ResolverTypeWrapper; @@ -2112,7 +2123,7 @@ export type GQLResolversParentTypes = { AudioLicense: GQLAudioLicense; AudioSearch: GQLAudioSearch; AudioSummary: GQLAudioSummary; - BaseUser: GQLResolversParentTypes['ArenaNotificationUser'] | GQLResolversParentTypes['ArenaUser']; + BaseUser: GQLResolversParentTypes['ArenaNotificationUser'] | GQLResolversParentTypes['ArenaUser'] | GQLResolversParentTypes['FullArenaUser']; Boolean: Scalars['Boolean']; Breadcrumb: GQLBreadcrumb; BrightcoveCustomFields: GQLBrightcoveCustomFields; @@ -2153,6 +2164,7 @@ export type GQLResolversParentTypes = { FrontpageMenu: GQLFrontpageMenu; FrontpageSearch: GQLFrontpageSearch; FrontpageSearchResult: GQLFrontpageSearchResult; + FullArenaUser: GQLFullArenaUser; Gloss: GQLGloss; GlossLicense: GQLGlossLicense; Grade: GQLGrade; @@ -2327,7 +2339,6 @@ export type GQLArenaUserResolvers; groupTitleArray?: Resolver, ParentType, ContextType>; id?: Resolver; - location?: Resolver, ParentType, ContextType>; profilePicture?: Resolver, ParentType, ContextType>; slug?: Resolver; username?: Resolver; @@ -2478,7 +2489,7 @@ export type GQLAudioSummaryResolvers = { - __resolveType: TypeResolveFn<'ArenaNotificationUser' | 'ArenaUser', ParentType, ContextType>; + __resolveType: TypeResolveFn<'ArenaNotificationUser' | 'ArenaUser' | 'FullArenaUser', ParentType, ContextType>; displayName?: Resolver; id?: Resolver; profilePicture?: Resolver, ParentType, ContextType>; @@ -2813,6 +2824,17 @@ export type GQLFrontpageSearchResultResolvers; }; +export type GQLFullArenaUserResolvers = { + displayName?: Resolver; + groupTitleArray?: Resolver, ParentType, ContextType>; + id?: Resolver; + location?: Resolver, ParentType, ContextType>; + profilePicture?: Resolver, ParentType, ContextType>; + slug?: Resolver; + username?: Resolver; + __isTypeOf?: IsTypeOfResolverFn; +}; + export type GQLGlossResolvers = { examples?: Resolver>>, ParentType, ContextType>; gloss?: Resolver; @@ -3275,7 +3297,7 @@ export type GQLQueryResolvers, ParentType, ContextType>; arenaTopic?: Resolver, ParentType, ContextType, RequireFields>; arenaTopicsByUser?: Resolver, ParentType, ContextType, RequireFields>; - arenaUser?: Resolver, ParentType, ContextType, RequireFields>; + arenaUser?: Resolver, ParentType, ContextType, RequireFields>; article?: Resolver, ParentType, ContextType, RequireFields>; articleResource?: Resolver, ParentType, ContextType, Partial>; audio?: Resolver, ParentType, ContextType, RequireFields>; @@ -3748,6 +3770,7 @@ export type GQLResolvers = { FrontpageMenu?: GQLFrontpageMenuResolvers; FrontpageSearch?: GQLFrontpageSearchResolvers; FrontpageSearchResult?: GQLFrontpageSearchResultResolvers; + FullArenaUser?: GQLFullArenaUserResolvers; Gloss?: GQLGlossResolvers; GlossLicense?: GQLGlossLicenseResolvers; Grade?: GQLGradeResolvers;