Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Search Functionality for Agenda Item Categories #2805

Merged
merged 1 commit into from
Dec 29, 2024
Merged
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
6 changes: 5 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ type AgendaItem {
users: [User]
}

input AgendaItemCategoryWhereInput {
name_contains: String
}

type AgendaSection {
_id: ID!
createdAt: Date!
Expand Down Expand Up @@ -1556,7 +1560,7 @@ type Query {
agendaCategory(id: ID!): AgendaCategory!
agendaItemByEvent(relatedEventId: ID!): [AgendaItem]
agendaItemByOrganization(organizationId: ID!): [AgendaItem]
agendaItemCategoriesByOrganization(organizationId: ID!): [AgendaCategory]
agendaItemCategoriesByOrganization(organizationId: ID!, where: AgendaItemCategoryWhereInput): [AgendaCategory]
chatById(id: ID!): Chat!
chatsByUserId(id: ID!, where: ChatWhereInput): [Chat]
checkAuth: User!
Expand Down
3 changes: 3 additions & 0 deletions src/resolvers/Query/agendaItemCategoriesByOrganization.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { QueryResolvers } from "../../types/generatedGraphQLTypes";
import { AgendaCategoryModel } from "../../models";
import { getWhere } from "./helperFunctions/getWhere";
/**
* This query will fetch all categories for the organization from database.
* @param _parent-
Expand All @@ -8,7 +9,9 @@ import { AgendaCategoryModel } from "../../models";
*/
export const agendaItemCategoriesByOrganization: QueryResolvers["agendaItemCategoriesByOrganization"] =
async (_parent, args) => {
const where = getWhere(args.where);
return await AgendaCategoryModel.find({
organizationId: args.organizationId,
...where,
}).lean();
};
2 changes: 2 additions & 0 deletions src/resolvers/Query/helperFunctions/getWhere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
ActionItemCategoryWhereInput,
ChatWhereInput,
EventVolunteerWhereInput,
AgendaItemCategoryWhereInput,
} from "../../../types/generatedGraphQLTypes";

/**
Expand Down Expand Up @@ -42,6 +43,7 @@ export const getWhere = <T = unknown>(
DonationWhereInput &
ActionItemWhereInput &
ActionItemCategoryWhereInput &
AgendaItemCategoryWhereInput &
CampaignWhereInput &
FundWhereInput &
PledgeWhereInput &
Expand Down
4 changes: 4 additions & 0 deletions src/typeDefs/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export const inputs = gql`
is_disabled: Boolean
}

input AgendaItemCategoryWhereInput {
name_contains: String
}

input CreateAgendaCategoryInput {
name: String!
description: String
Expand Down
5 changes: 4 additions & 1 deletion src/typeDefs/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const queries = gql`

agendaItemByOrganization(organizationId: ID!): [AgendaItem]

agendaItemCategoriesByOrganization(organizationId: ID!): [AgendaCategory]
agendaItemCategoriesByOrganization(
organizationId: ID!
where: AgendaItemCategoryWhereInput
): [AgendaCategory]

getAgendaItem(id: ID!): AgendaItem

Expand Down
7 changes: 7 additions & 0 deletions src/types/generatedGraphQLTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export type AgendaItem = {
users?: Maybe<Array<Maybe<User>>>;
};

export type AgendaItemCategoryWhereInput = {
name_contains?: InputMaybe<Scalars['String']['input']>;
};

export type AgendaSection = {
__typename?: 'AgendaSection';
_id: Scalars['ID']['output'];
Expand Down Expand Up @@ -2463,6 +2467,7 @@ export type QueryAgendaItemByOrganizationArgs = {

export type QueryAgendaItemCategoriesByOrganizationArgs = {
organizationId: Scalars['ID']['input'];
where?: InputMaybe<AgendaItemCategoryWhereInput>;
};


Expand Down Expand Up @@ -3510,6 +3515,7 @@ export type ResolversTypes = {
AdvertisementsConnection: ResolverTypeWrapper<Omit<AdvertisementsConnection, 'edges'> & { edges?: Maybe<Array<Maybe<ResolversTypes['AdvertisementEdge']>>> }>;
AgendaCategory: ResolverTypeWrapper<InterfaceAgendaCategoryModel>;
AgendaItem: ResolverTypeWrapper<InterfaceAgendaItemModel>;
AgendaItemCategoryWhereInput: AgendaItemCategoryWhereInput;
AgendaSection: ResolverTypeWrapper<InterfaceAgendaSectionModel>;
AggregatePost: ResolverTypeWrapper<AggregatePost>;
AggregateUser: ResolverTypeWrapper<AggregateUser>;
Expand Down Expand Up @@ -3745,6 +3751,7 @@ export type ResolversParentTypes = {
AdvertisementsConnection: Omit<AdvertisementsConnection, 'edges'> & { edges?: Maybe<Array<Maybe<ResolversParentTypes['AdvertisementEdge']>>> };
AgendaCategory: InterfaceAgendaCategoryModel;
AgendaItem: InterfaceAgendaItemModel;
AgendaItemCategoryWhereInput: AgendaItemCategoryWhereInput;
AgendaSection: InterfaceAgendaSectionModel;
AggregatePost: AggregatePost;
AggregateUser: AggregateUser;
Expand Down
Loading