diff --git a/src/resolvers/User/index.ts b/src/resolvers/User/index.ts index 538fe582cf..1a4d395c54 100644 --- a/src/resolvers/User/index.ts +++ b/src/resolvers/User/index.ts @@ -1,8 +1,10 @@ import type { UserResolvers } from "../../types/generatedGraphQLTypes"; // import { tagsAssignedWith } from "./tagsAssignedWith"; import { posts } from "./posts"; +import { tagsAssigned } from "./tagsAssigned"; export const User: UserResolvers = { // tagsAssignedWith, posts, + tagsAssigned, }; diff --git a/src/resolvers/User/tagsAssigned.ts b/src/resolvers/User/tagsAssigned.ts new file mode 100644 index 0000000000..536edf6331 --- /dev/null +++ b/src/resolvers/User/tagsAssigned.ts @@ -0,0 +1,31 @@ +import { ActionItemCategory, OrganizationTagUser, TagUser } from "../../models"; +import type { + OrganizationResolvers, + UserResolvers, +} from "../../types/generatedGraphQLTypes"; + +/** + * Resolver function for the `actionItemCategories` field of an `Organization`. + * + * This function retrieves the action item categories related to a specific organization. + * + * @param parent - The parent object representing the organization. It contains information about the organization, including the ID of the organization. + * @returns A promise that resolves to the action item category documents found in the database. These documents represent the action item categories related to the organization. + * + * @see ActionItemCategory - The ActionItemCategory model used to interact with the action item categories collection in the database. + * @see OrganizationResolvers - The type definition for the resolvers of the Organization fields. + * + */ +export const tagsAssigned: UserResolvers["tagsAssigned"] = async (parent) => { + const tags = await TagUser.find({ + userId: parent._id, + }).lean(); + + const tagIds = tags.map((tag) => tag.tagId); + + return await OrganizationTagUser.find({ + _id: { $in: tagIds }, + }) + .sort({ _id: -1 }) + .lean(); +}; diff --git a/src/typeDefs/types.ts b/src/typeDefs/types.ts index 658a1d1785..6e22b859ea 100644 --- a/src/typeDefs/types.ts +++ b/src/typeDefs/types.ts @@ -658,6 +658,7 @@ export const types = gql` last: PositiveInt organizationId: ID ): UserTagsConnection + tagsAssigned: [UserTag] updatedAt: DateTime! } type AppUserProfile { diff --git a/src/types/generatedGraphQLTypes.ts b/src/types/generatedGraphQLTypes.ts index 4c19947760..10b1d4ac27 100644 --- a/src/types/generatedGraphQLTypes.ts +++ b/src/types/generatedGraphQLTypes.ts @@ -1251,8 +1251,6 @@ export type Mutation = { removeEventVolunteer: EventVolunteer; removeEventVolunteerGroup: EventVolunteerGroup; removeFromUserTags?: Maybe; - removeFund: Fund; - removeFundraisingCampaign: FundraisingCampaign; removeFundraisingCampaignPledge: FundraisingCampaignPledge; removeGroupChat: GroupChat; removeMember: Organization; @@ -1718,16 +1716,6 @@ export type MutationRemoveFromUserTagsArgs = { }; -export type MutationRemoveFundArgs = { - id: Scalars['ID']['input']; -}; - - -export type MutationRemoveFundraisingCampaignArgs = { - id: Scalars['ID']['input']; -}; - - export type MutationRemoveFundraisingCampaignPledgeArgs = { id: Scalars['ID']['input']; }; @@ -3003,6 +2991,7 @@ export type User = { pluginCreationAllowed: Scalars['Boolean']['output']; posts?: Maybe; registeredEvents?: Maybe>>; + tagsAssigned?: Maybe>>; tagsAssignedWith?: Maybe; updatedAt: Scalars['DateTime']['output']; }; @@ -4455,8 +4444,6 @@ export type MutationResolvers>; removeEventVolunteerGroup?: Resolver>; removeFromUserTags?: Resolver, ParentType, ContextType, RequireFields>; - removeFund?: Resolver>; - removeFundraisingCampaign?: Resolver>; removeFundraisingCampaignPledge?: Resolver>; removeGroupChat?: Resolver>; removeMember?: Resolver>; @@ -4810,6 +4797,7 @@ export type UserResolvers; posts?: Resolver, ParentType, ContextType, Partial>; registeredEvents?: Resolver>>, ParentType, ContextType>; + tagsAssigned?: Resolver>>, ParentType, ContextType>; tagsAssignedWith?: Resolver, ParentType, ContextType, Partial>; updatedAt?: Resolver; __isTypeOf?: IsTypeOfResolverFn;