Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

feat: limit number of events in the chapterCard #2127

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
30 changes: 15 additions & 15 deletions client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5208,7 +5208,20 @@
{
"name": "chapters",
"description": null,
"args": [],
"args": [
{
"name": "limit",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
Expand Down Expand Up @@ -5318,20 +5331,7 @@
{
"name": "dashboardEvents",
"description": null,
"args": [
{
"name": "limit",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
Expand Down
8 changes: 4 additions & 4 deletions client/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ export type QueryChapterVenuesArgs = {
chapterId: Scalars['Int'];
};

export type QueryChaptersArgs = {
limit?: InputMaybe<Scalars['Int']>;
};

export type QueryDashboardChapterArgs = {
id: Scalars['Int'];
};
Expand All @@ -576,10 +580,6 @@ export type QueryDashboardEventArgs = {
id: Scalars['Int'];
};

export type QueryDashboardEventsArgs = {
limit?: InputMaybe<Scalars['Int']>;
};

export type QueryDashboardSponsorArgs = {
id: Scalars['Int'];
};
Expand Down
3 changes: 2 additions & 1 deletion client/src/modules/chapters/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const CHAPTER_USER = gql`
}
`;

// https://graphql.org/learn/pagination/#slicing
export const CHAPTERS = gql`
query chapters {
chapters {
Expand All @@ -51,7 +52,7 @@ export const CHAPTERS = gql`
description
logo_url
banner_url
events {
events(first: 2) {
Sboonny marked this conversation as resolved.
Show resolved Hide resolved
id
canceled
start_at
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/home/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const HOME_PAGE_QUERY = gql`
description
banner_url
logo_url
events {
events(first: 2) {
id
canceled
start_at
Expand Down
5 changes: 4 additions & 1 deletion server/src/controllers/Chapter/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ import { CreateChapterInputs, UpdateChapterInputs } from './inputs';
@Resolver()
export class ChapterResolver {
@Query(() => [ChapterCardRelations])
async chapters(): Promise<ChapterCardRelations[]> {
async chapters(
@Arg('limit', () => Int, { nullable: true }) limit?: number,
): Promise<ChapterCardRelations[]> {
return await prisma.chapters.findMany({
include: {
events: {
where: {
AND: [{ canceled: false }, { ends_at: { gt: new Date() } }],
},
take: limit,
orderBy: { start_at: 'asc' },
Sboonny marked this conversation as resolved.
Show resolved Hide resolved
},
chapter_users: {
Expand Down
2 changes: 0 additions & 2 deletions server/src/controllers/Events/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ export class EventResolver {
@Query(() => [EventWithVenue])
async dashboardEvents(
@Ctx() ctx: Required<ResolverCtx>,
@Arg('limit', () => Int, { nullable: true }) limit?: number,
): Promise<EventWithVenue[]> {
return await prisma.events.findMany({
where: {
Expand All @@ -361,7 +360,6 @@ export class EventResolver {
}),
},
include: { venue: true },
take: limit,
orderBy: { start_at: 'asc' },
});
}
Expand Down