From 28877805282e12eb88a387a47b2581c510648cb6 Mon Sep 17 00:00:00 2001 From: Muncherkin <48158637+Muncherkin@users.noreply.github.com> Date: Wed, 19 Apr 2023 09:30:36 +0200 Subject: [PATCH] added requested feature to query allHehes. Resolved linting error from post.api.test.ts --- CHANGELOG.MD | 5 + package-lock.json | 4 +- package.json | 2 +- src/models/generated/graphql.ts | 912 +++++++++----------------------- src/resolvers/hehe.resolver.ts | 5 + src/schemas/hehe.graphql | 1 + test/unit/post.api.test.ts | 2 +- 7 files changed, 253 insertions(+), 678 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 2b6be064..47873896 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -4,6 +4,11 @@ Alla märkbara ändringar ska dokumenteras i denna fil. Baserat på [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), och följer [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.1] - 2023-04-19 + +### Tillagt +- Lagt till en `allHehes` query i `hehe`-resolver/graph för att kunna hämt alla hehes. + ## [1.3.0] - 2023-04-05 ### Tillagt diff --git a/package-lock.json b/package-lock.json index eb18d62f..ad4f1747 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ekorre-ts", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ekorre-ts", - "version": "1.3.0", + "version": "1.3.1", "license": "AGPL-3.0-only", "dependencies": { "@esek/auth-server": "5.0.2", diff --git a/package.json b/package.json index 6ab3117f..0cf5088b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ekorre-ts", - "version": "1.3.0", + "version": "1.3.1", "description": "E-Sektionens backend", "main": "src/index.ts", "scripts": { diff --git a/src/models/generated/graphql.ts b/src/models/generated/graphql.ts index 144d76d0..13b0927f 100644 --- a/src/models/generated/graphql.ts +++ b/src/models/generated/graphql.ts @@ -1,17 +1,6 @@ import type { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; - +import type { ArticleResponse, FileResponse, MeetingResponse, ElectionResponse, ProposalResponse, NominationResponse, HeheResponse, ApiKeyResponse } from '../mappers'; import type { Context } from '../context'; -import type { - ArticleResponse, - FileResponse, - MeetingResponse, - ElectionResponse, - ProposalResponse, - NominationResponse, - HeheResponse, - ApiKeyResponse, -} from '../mappers'; - export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -43,13 +32,13 @@ export type AccessInput = { export enum AccessResourceType { Door = 'door', - Feature = 'feature', + Feature = 'feature' } export enum AccessType { Admin = 'ADMIN', Authenticated = 'AUTHENTICATED', - Public = 'PUBLIC', + Public = 'PUBLIC' } export type ApiKey = { @@ -76,6 +65,7 @@ export type Article = { title: Scalars['String']; }; + /** Body is saved as HTML serversInte, but edited in MarkDown */ export type ArticleTagsArgs = { includeSpecial?: InputMaybe; @@ -84,7 +74,7 @@ export type ArticleTagsArgs = { /** News are the ones to be used by a website newsreel */ export enum ArticleType { Information = 'INFORMATION', - News = 'NEWS', + News = 'NEWS' } export type CasLoginResponse = { @@ -106,7 +96,7 @@ export enum Door { Pa = 'pa', Pump = 'pump', Sikrit = 'sikrit', - Ulla = 'ulla', + Ulla = 'ulla' } export type DoorInfo = { @@ -143,7 +133,7 @@ export enum EmergencyContactType { Mom = 'MOM', Other = 'OTHER', SignificantOther = 'SIGNIFICANT_OTHER', - Sister = 'SISTER', + Sister = 'SISTER' } /** Features are used for mapping access to a feature (ex article or election) for user or a post. This is not limited to efterphest */ @@ -158,7 +148,7 @@ export enum Feature { NewsEditor = 'news_editor', PostAdmin = 'post_admin', Superadmin = 'superadmin', - UserAdmin = 'user_admin', + UserAdmin = 'user_admin' } export type FeatureInfo = { @@ -196,7 +186,7 @@ export enum FileType { Pdf = 'PDF', Powerpoint = 'POWERPOINT', Spreadsheet = 'SPREADSHEET', - Text = 'TEXT', + Text = 'TEXT' } export type GroupedPost = { @@ -260,7 +250,7 @@ export enum MeetingDocumentType { LateDocuments = 'lateDocuments', Protocol = 'protocol', /** Kallelse */ - Summons = 'summons', + Summons = 'summons' } export enum MeetingType { @@ -273,7 +263,7 @@ export enum MeetingType { /** Valmöte */ Vm = 'VM', /** Vårterminsmöte */ - Vtm = 'VTM', + Vtm = 'VTM' } /** We don't need every part; It should already exist */ @@ -363,47 +353,56 @@ export type Mutation = { validateToken: Scalars['Boolean']; }; + export type MutationActivatePostArgs = { id: Scalars['Int']; }; + export type MutationAddArticleArgs = { entry: NewArticle; }; + export type MutationAddElectablesArgs = { electionId: Scalars['Int']; postIds: Array; }; + export type MutationAddEmergencyContactArgs = { name: Scalars['String']; phone: Scalars['String']; type: EmergencyContactType; }; + export type MutationAddFileToMeetingArgs = { fileId: Scalars['String']; fileType: MeetingDocumentType; meetingId: Scalars['Int']; }; + export type MutationAddHeheArgs = { fileId: Scalars['ID']; number: Scalars['Int']; year: Scalars['Int']; }; + export type MutationAddMeetingArgs = { number?: InputMaybe; type: MeetingType; year?: InputMaybe; }; + export type MutationAddPostArgs = { info: NewPost; }; + export type MutationAddUsersToPostArgs = { end?: InputMaybe; id: Scalars['Int']; @@ -411,200 +410,243 @@ export type MutationAddUsersToPostArgs = { usernames: Array; }; + export type MutationCasCreateUserArgs = { hash: Scalars['String']; input: NewUser; }; + export type MutationCasLoginArgs = { token: Scalars['String']; }; + export type MutationChangePasswordArgs = { newPassword: Scalars['String']; oldPassword: Scalars['String']; }; + export type MutationCreateApiKeyArgs = { description: Scalars['String']; }; + export type MutationCreateElectionArgs = { electables: Array; nominationsHidden: Scalars['Boolean']; }; + export type MutationCreateFolderArgs = { name: Scalars['String']; path: Scalars['String']; }; + export type MutationCreateUserArgs = { input: NewUser; }; + export type MutationDeactivatePostArgs = { id: Scalars['Int']; }; + export type MutationDeleteApiKeyArgs = { key: Scalars['String']; }; + export type MutationDeleteFileArgs = { id: Scalars['ID']; }; + export type MutationForgetUserArgs = { username: Scalars['String']; }; + export type MutationIssueTokensArgs = { username: Scalars['String']; }; + export type MutationLinkLoginProviderArgs = { input: ProviderOptions; }; + export type MutationLoginArgs = { password: Scalars['String']; username: Scalars['String']; }; + export type MutationModifyArticleArgs = { articleId: Scalars['Int']; entry: ModifyArticle; }; + export type MutationModifyPostArgs = { info: ModifyPost; }; + export type MutationNominateArgs = { postIds: Array; username: Scalars['String']; }; + export type MutationOpenElectionArgs = { electionId: Scalars['Int']; }; + export type MutationProposeArgs = { electionId: Scalars['Int']; postId: Scalars['Int']; username: Scalars['String']; }; + export type MutationProviderLoginArgs = { input: ProviderOptions; }; + export type MutationRefreshArgs = { refreshToken: Scalars['String']; }; + export type MutationRemoveArticleArgs = { articleId: Scalars['Int']; }; + export type MutationRemoveElectablesArgs = { electionId: Scalars['Int']; postIds: Array; }; + export type MutationRemoveEmergencyContactArgs = { id: Scalars['Int']; }; + export type MutationRemoveFileFromMeetingArgs = { fileType: MeetingDocumentType; meetingId: Scalars['Int']; }; + export type MutationRemoveHeheArgs = { number: Scalars['Int']; year: Scalars['Int']; }; + export type MutationRemoveHistoryEntryArgs = { id: Scalars['Int']; }; + export type MutationRemoveMeetingArgs = { id: Scalars['Int']; }; + export type MutationRemoveProposalArgs = { electionId: Scalars['Int']; postId: Scalars['Int']; username: Scalars['String']; }; + export type MutationRequestPasswordResetArgs = { resetLink: Scalars['String']; returnTo?: InputMaybe; username: Scalars['String']; }; + export type MutationResetPasswordArgs = { password: Scalars['String']; token: Scalars['String']; username: Scalars['String']; }; + export type MutationRespondToNominationArgs = { accepts: NominationAnswer; postId: Scalars['Int']; }; + export type MutationSendEmailArgs = { options: SendEmailOptions; }; + export type MutationSetApiKeyAccessArgs = { access: AccessInput; key: Scalars['String']; }; + export type MutationSetElectablesArgs = { electionId: Scalars['Int']; postIds: Array; }; + export type MutationSetHiddenNominationsArgs = { electionId: Scalars['Int']; hidden: Scalars['Boolean']; }; + export type MutationSetIndividualAccessArgs = { access: AccessInput; username: Scalars['String']; }; + export type MutationSetPostAccessArgs = { access: AccessInput; postId: Scalars['Int']; }; + export type MutationSetUserPostEndArgs = { end: Scalars['Date']; id: Scalars['Int']; }; + export type MutationUnlinkLoginProviderArgs = { id: Scalars['Int']; }; + export type MutationUpdateUserArgs = { input: UpdateUser; }; + export type MutationValidatePasswordResetTokenArgs = { token: Scalars['String']; username: Scalars['String']; }; + export type MutationValidateTokenArgs = { token: Scalars['String']; }; @@ -653,7 +695,7 @@ export type Nomination = { export enum NominationAnswer { No = 'NO', NotAnswered = 'NOT_ANSWERED', - Yes = 'YES', + Yes = 'YES' } export type Post = { @@ -678,6 +720,7 @@ export type Post = { utskott: Utskott; }; + export type PostHistoryArgs = { current?: InputMaybe; }; @@ -694,7 +737,7 @@ export enum PostType { /** Upp till _n_ stycken */ N = 'N', /** Unik, finns bara 1, t.ex. utskottsordförande */ - U = 'U', + U = 'U' } /** Valberedningens förslag */ @@ -714,6 +757,7 @@ export type ProviderOptions = { * does not take an `electionId` parameter. */ export type Query = { + allHehes: Array; apiKey: ApiKey; apiKeys: Array; article: Article; @@ -757,6 +801,16 @@ export type Query = { utskott: Utskott; }; + +/** + * Queries and mutations that relies on an election being open + * does not take an `electionId` parameter. + */ +export type QueryAllHehesArgs = { + sortOrder?: InputMaybe; +}; + + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -765,6 +819,7 @@ export type QueryApiKeyArgs = { key: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -774,6 +829,7 @@ export type QueryArticleArgs = { slug?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -785,6 +841,7 @@ export type QueryArticlesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -793,6 +850,7 @@ export type QueryElectionArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -801,6 +859,7 @@ export type QueryElectionsArgs = { electionIds: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -809,6 +868,7 @@ export type QueryFileArgs = { id: Scalars['ID']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -817,6 +877,7 @@ export type QueryFileSystemArgs = { folder: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -825,6 +886,7 @@ export type QueryFilesArgs = { type?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -833,6 +895,7 @@ export type QueryGroupedPostsArgs = { includeInactive?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -842,6 +905,7 @@ export type QueryHeheArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -850,6 +914,7 @@ export type QueryHehesArgs = { year: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -859,6 +924,7 @@ export type QueryHiddenNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -867,6 +933,7 @@ export type QueryIndividualAccessArgs = { username: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -875,6 +942,7 @@ export type QueryLatestBoardMeetingsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -885,6 +953,7 @@ export type QueryLatestElectionsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -894,6 +963,7 @@ export type QueryLatestHeheArgs = { sortOrder?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -902,6 +972,7 @@ export type QueryLatestnewsArgs = { limit?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -910,6 +981,7 @@ export type QueryMeetingArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -920,6 +992,7 @@ export type QueryMeetingsArgs = { year?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -929,6 +1002,7 @@ export type QueryMyNominationsArgs = { electionId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -939,6 +1013,7 @@ export type QueryNewsentriesArgs = { before?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -947,6 +1022,7 @@ export type QueryNumberOfMembersArgs = { noAlumni?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -956,6 +1032,7 @@ export type QueryNumberOfNominationsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -965,6 +1042,7 @@ export type QueryNumberOfProposalsArgs = { postId?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -973,6 +1051,7 @@ export type QueryNumberOfVolunteersArgs = { date?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -981,6 +1060,7 @@ export type QueryPostArgs = { id: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -989,6 +1069,7 @@ export type QueryPostAccessArgs = { postId: Scalars['Int']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -998,6 +1079,7 @@ export type QueryPostsArgs = { utskott?: InputMaybe; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1006,6 +1088,7 @@ export type QuerySearchFilesArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1014,6 +1097,7 @@ export type QuerySearchUserArgs = { search: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1022,6 +1106,7 @@ export type QueryUserArgs = { username: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1030,6 +1115,7 @@ export type QueryUserByCardArgs = { luCard: Scalars['String']; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1038,6 +1124,7 @@ export type QueryUsersArgs = { usernames: Array; }; + /** * Queries and mutations that relies on an election being open * does not take an `electionId` parameter. @@ -1056,7 +1143,7 @@ export type SendEmailOptions = { export enum SortOrder { Asc = 'asc', - Desc = 'desc', + Desc = 'desc' } export type TokenResponse = { @@ -1099,6 +1186,7 @@ export type User = { zipCode?: Maybe; }; + export type UserPostHistoryArgs = { current?: InputMaybe; }; @@ -1121,7 +1209,7 @@ export enum Utskott { Other = 'OTHER', Pengu = 'PENGU', Sre = 'SRE', - Styrelsen = 'STYRELSEN', + Styrelsen = 'STYRELSEN' } export type WithIndex = TObject & Record; @@ -1129,41 +1217,34 @@ export type ResolversObject = WithIndex; export type ResolverTypeWrapper = Promise | T; + export type ResolverWithResolve = { resolve: ResolverFn; }; -export type Resolver = - | ResolverFn - | ResolverWithResolve; +export type Resolver = ResolverFn | ResolverWithResolve; export type ResolverFn = ( parent: TParent, args: TArgs, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => Promise | TResult; export type SubscriptionSubscribeFn = ( parent: TParent, args: TArgs, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => AsyncIterable | Promise>; export type SubscriptionResolveFn = ( parent: TParent, args: TArgs, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => TResult | Promise; -export interface SubscriptionSubscriberObject< - TResult, - TKey extends string, - TParent, - TContext, - TArgs, -> { +export interface SubscriptionSubscriberObject { subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>; resolve?: SubscriptionResolveFn; } @@ -1177,27 +1258,17 @@ export type SubscriptionObject | SubscriptionResolverObject; -export type SubscriptionResolver< - TResult, - TKey extends string, - TParent = {}, - TContext = {}, - TArgs = {}, -> = +export type SubscriptionResolver = | ((...args: any[]) => SubscriptionObject) | SubscriptionObject; export type TypeResolveFn = ( parent: TParent, context: TContext, - info: GraphQLResolveInfo, + info: GraphQLResolveInfo ) => Maybe | Promise>; -export type IsTypeOfResolverFn = ( - obj: T, - context: TContext, - info: GraphQLResolveInfo, -) => boolean | Promise; +export type IsTypeOfResolverFn = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise; export type NextResolverFn = () => Promise; @@ -1206,7 +1277,7 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping between all available schema types and the resolvers types */ @@ -1229,9 +1300,7 @@ export type ResolversTypes = ResolversObject<{ Feature: Feature; FeatureInfo: ResolverTypeWrapper; File: ResolverTypeWrapper; - FileSystemResponse: ResolverTypeWrapper< - Omit & { files: Array } - >; + FileSystemResponse: ResolverTypeWrapper & { files: Array }>; FileSystemResponsePath: ResolverTypeWrapper; FileType: FileType; GroupedPost: ResolverTypeWrapper; @@ -1282,9 +1351,7 @@ export type ResolversParentTypes = ResolversObject<{ EmergencyContact: EmergencyContact; FeatureInfo: FeatureInfo; File: FileResponse; - FileSystemResponse: Omit & { - files: Array; - }; + FileSystemResponse: Omit & { files: Array }; FileSystemResponsePath: FileSystemResponsePath; GroupedPost: GroupedPost; Hehe: HeheResponse; @@ -1314,19 +1381,13 @@ export type ResolversParentTypes = ResolversObject<{ UserPostHistoryEntry: UserPostHistoryEntry; }>; -export type AccessResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Access'] = ResolversParentTypes['Access'], -> = ResolversObject<{ +export type AccessResolvers = ResolversObject<{ doors?: Resolver, ParentType, ContextType>; features?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type ApiKeyResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['ApiKey'] = ResolversParentTypes['ApiKey'], -> = ResolversObject<{ +export type ApiKeyResolvers = ResolversObject<{ access?: Resolver; creator?: Resolver; description?: Resolver; @@ -1334,10 +1395,7 @@ export type ApiKeyResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type ArticleResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Article'] = ResolversParentTypes['Article'], -> = ResolversObject<{ +export type ArticleResolvers = ResolversObject<{ articleType?: Resolver; author?: Resolver; body?: Resolver; @@ -1347,20 +1405,12 @@ export type ArticleResolvers< lastUpdatedBy?: Resolver; signature?: Resolver; slug?: Resolver; - tags?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + tags?: Resolver, ParentType, ContextType, Partial>; title?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type CasLoginResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['CasLoginResponse'] = ResolversParentTypes['CasLoginResponse'], -> = ResolversObject<{ +export type CasLoginResponseResolvers = ResolversObject<{ exists?: Resolver; hash?: Resolver; username?: Resolver; @@ -1371,19 +1421,13 @@ export interface DateScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type DoorInfoResolvers = ResolversObject<{ description?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type ElectionResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Election'] = ResolversParentTypes['Election'], -> = ResolversObject<{ +export type ElectionResolvers = ResolversObject<{ acceptedNominations?: Resolver, ParentType, ContextType>; closedAt?: Resolver, ParentType, ContextType>; createdAt?: Resolver; @@ -1397,10 +1441,7 @@ export type ElectionResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type EmergencyContactResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['EmergencyContact'] = ResolversParentTypes['EmergencyContact'], -> = ResolversObject<{ +export type EmergencyContactResolvers = ResolversObject<{ id?: Resolver; name?: Resolver; phone?: Resolver; @@ -1408,19 +1449,13 @@ export type EmergencyContactResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type FeatureInfoResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['FeatureInfo'] = ResolversParentTypes['FeatureInfo'], -> = ResolversObject<{ +export type FeatureInfoResolvers = ResolversObject<{ description?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['File'] = ResolversParentTypes['File'], -> = ResolversObject<{ +export type FileResolvers = ResolversObject<{ accessType?: Resolver; createdAt?: Resolver, ParentType, ContextType>; createdBy?: Resolver, ParentType, ContextType>; @@ -1433,37 +1468,25 @@ export type FileResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileSystemResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['FileSystemResponse'] = ResolversParentTypes['FileSystemResponse'], -> = ResolversObject<{ +export type FileSystemResponseResolvers = ResolversObject<{ files?: Resolver, ParentType, ContextType>; path?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type FileSystemResponsePathResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['FileSystemResponsePath'] = ResolversParentTypes['FileSystemResponsePath'], -> = ResolversObject<{ +export type FileSystemResponsePathResolvers = ResolversObject<{ id?: Resolver; name?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type GroupedPostResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['GroupedPost'] = ResolversParentTypes['GroupedPost'], -> = ResolversObject<{ +export type GroupedPostResolvers = ResolversObject<{ posts?: Resolver, ParentType, ContextType>; utskott?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type HeheResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Hehe'] = ResolversParentTypes['Hehe'], -> = ResolversObject<{ +export type HeheResolvers = ResolversObject<{ file?: Resolver; number?: Resolver; uploader?: Resolver; @@ -1471,10 +1494,7 @@ export type HeheResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type HistoryEntryResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['HistoryEntry'] = ResolversParentTypes['HistoryEntry'], -> = ResolversObject<{ +export type HistoryEntryResolvers = ResolversObject<{ end?: Resolver, ParentType, ContextType>; holder?: Resolver; id?: Resolver; @@ -1482,10 +1502,7 @@ export type HistoryEntryResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type LoginProviderResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['LoginProvider'] = ResolversParentTypes['LoginProvider'], -> = ResolversObject<{ +export type LoginProviderResolvers = ResolversObject<{ email?: Resolver, ParentType, ContextType>; id?: Resolver; provider?: Resolver; @@ -1493,20 +1510,14 @@ export type LoginProviderResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type LoginResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['LoginResponse'] = ResolversParentTypes['LoginResponse'], -> = ResolversObject<{ +export type LoginResponseResolvers = ResolversObject<{ accessToken?: Resolver; refreshToken?: Resolver; user?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type MeetingResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Meeting'] = ResolversParentTypes['Meeting'], -> = ResolversObject<{ +export type MeetingResolvers = ResolversObject<{ appendix?: Resolver, ParentType, ContextType>; documents?: Resolver, ParentType, ContextType>; id?: Resolver; @@ -1520,330 +1531,64 @@ export type MeetingResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type MutationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation'], -> = ResolversObject<{ - activatePost?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addArticle?: Resolver< - ResolversTypes['Article'], - ParentType, - ContextType, - RequireFields - >; - addElectables?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addEmergencyContact?: Resolver< - ResolversTypes['EmergencyContact'], - ParentType, - ContextType, - RequireFields - >; - addFileToMeeting?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addHehe?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - addMeeting?: Resolver< - ResolversTypes['Meeting'], - ParentType, - ContextType, - RequireFields - >; - addPost?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - addUsersToPost?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - casCreateUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - casLogin?: Resolver< - ResolversTypes['CasLoginResponse'], - ParentType, - ContextType, - RequireFields - >; - changePassword?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; +export type MutationResolvers = ResolversObject<{ + activatePost?: Resolver>; + addArticle?: Resolver>; + addElectables?: Resolver>; + addEmergencyContact?: Resolver>; + addFileToMeeting?: Resolver>; + addHehe?: Resolver>; + addMeeting?: Resolver>; + addPost?: Resolver>; + addUsersToPost?: Resolver>; + casCreateUser?: Resolver>; + casLogin?: Resolver>; + changePassword?: Resolver>; closeElection?: Resolver; - createApiKey?: Resolver< - ResolversTypes['String'], - ParentType, - ContextType, - RequireFields - >; - createElection?: Resolver< - ResolversTypes['Election'], - ParentType, - ContextType, - RequireFields - >; - createFolder?: Resolver< - ResolversTypes['File'], - ParentType, - ContextType, - RequireFields - >; - createUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - deactivatePost?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - deleteApiKey?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - deleteFile?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - forgetUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - issueTokens?: Resolver< - ResolversTypes['TokenResponse'], - ParentType, - ContextType, - RequireFields - >; - linkLoginProvider?: Resolver< - ResolversTypes['LoginProvider'], - ParentType, - ContextType, - RequireFields - >; - login?: Resolver< - ResolversTypes['LoginResponse'], - ParentType, - ContextType, - RequireFields - >; + createApiKey?: Resolver>; + createElection?: Resolver>; + createFolder?: Resolver>; + createUser?: Resolver>; + deactivatePost?: Resolver>; + deleteApiKey?: Resolver>; + deleteFile?: Resolver>; + forgetUser?: Resolver>; + issueTokens?: Resolver>; + linkLoginProvider?: Resolver>; + login?: Resolver>; logout?: Resolver; - modifyArticle?: Resolver< - ResolversTypes['Article'], - ParentType, - ContextType, - RequireFields - >; - modifyPost?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - nominate?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - openElection?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - propose?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - providerLogin?: Resolver< - ResolversTypes['LoginResponse'], - ParentType, - ContextType, - RequireFields - >; - refresh?: Resolver< - ResolversTypes['TokenResponse'], - ParentType, - ContextType, - RequireFields - >; - removeArticle?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeElectables?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeEmergencyContact?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeFileFromMeeting?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeHehe?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeHistoryEntry?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeMeeting?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - removeProposal?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - requestPasswordReset?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - resetPassword?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - respondToNomination?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - sendEmail?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setApiKeyAccess?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setElectables?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setHiddenNominations?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setIndividualAccess?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setPostAccess?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - setUserPostEnd?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - unlinkLoginProvider?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - updateUser?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - validatePasswordResetToken?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; - validateToken?: Resolver< - ResolversTypes['Boolean'], - ParentType, - ContextType, - RequireFields - >; + modifyArticle?: Resolver>; + modifyPost?: Resolver>; + nominate?: Resolver>; + openElection?: Resolver>; + propose?: Resolver>; + providerLogin?: Resolver>; + refresh?: Resolver>; + removeArticle?: Resolver>; + removeElectables?: Resolver>; + removeEmergencyContact?: Resolver>; + removeFileFromMeeting?: Resolver>; + removeHehe?: Resolver>; + removeHistoryEntry?: Resolver>; + removeMeeting?: Resolver>; + removeProposal?: Resolver>; + requestPasswordReset?: Resolver>; + resetPassword?: Resolver>; + respondToNomination?: Resolver>; + sendEmail?: Resolver>; + setApiKeyAccess?: Resolver>; + setElectables?: Resolver>; + setHiddenNominations?: Resolver>; + setIndividualAccess?: Resolver>; + setPostAccess?: Resolver>; + setUserPostEnd?: Resolver>; + unlinkLoginProvider?: Resolver>; + updateUser?: Resolver>; + validatePasswordResetToken?: Resolver>; + validateToken?: Resolver>; }>; -export type NominationResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Nomination'] = ResolversParentTypes['Nomination'], -> = ResolversObject<{ +export type NominationResolvers = ResolversObject<{ answer?: Resolver; post?: Resolver; user?: Resolver; @@ -1854,20 +1599,12 @@ export interface ObjectScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type PostResolvers = ResolversObject<{ access?: Resolver; active?: Resolver; description?: Resolver; email?: Resolver, ParentType, ContextType>; - history?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + history?: Resolver, ParentType, ContextType, Partial>; id?: Resolver; interviewRequired?: Resolver, ParentType, ContextType>; postType?: Resolver; @@ -1878,228 +1615,62 @@ export type PostResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type ProposalResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Proposal'] = ResolversParentTypes['Proposal'], -> = ResolversObject<{ +export type ProposalResolvers = ResolversObject<{ post?: Resolver; user?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type QueryResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query'], -> = ResolversObject<{ - apiKey?: Resolver< - ResolversTypes['ApiKey'], - ParentType, - ContextType, - RequireFields - >; +export type QueryResolvers = ResolversObject<{ + allHehes?: Resolver, ParentType, ContextType, Partial>; + apiKey?: Resolver>; apiKeys?: Resolver, ParentType, ContextType>; article?: Resolver>; - articles?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + articles?: Resolver, ParentType, ContextType, Partial>; doors?: Resolver, ParentType, ContextType>; - election?: Resolver< - ResolversTypes['Election'], - ParentType, - ContextType, - RequireFields - >; - elections?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; + election?: Resolver>; + elections?: Resolver, ParentType, ContextType, RequireFields>; features?: Resolver, ParentType, ContextType>; - file?: Resolver< - ResolversTypes['File'], - ParentType, - ContextType, - RequireFields - >; - fileSystem?: Resolver< - ResolversTypes['FileSystemResponse'], - ParentType, - ContextType, - RequireFields - >; + file?: Resolver>; + fileSystem?: Resolver>; files?: Resolver, ParentType, ContextType, Partial>; - groupedPosts?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - hehe?: Resolver< - ResolversTypes['Hehe'], - ParentType, - ContextType, - RequireFields - >; - hehes?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - hiddenNominations?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - individualAccess?: Resolver< - ResolversTypes['Access'], - ParentType, - ContextType, - RequireFields - >; - latestBoardMeetings?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestElections?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestHehe?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - latestnews?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + groupedPosts?: Resolver, ParentType, ContextType, Partial>; + hehe?: Resolver>; + hehes?: Resolver, ParentType, ContextType, RequireFields>; + hiddenNominations?: Resolver, ParentType, ContextType, RequireFields>; + individualAccess?: Resolver>; + latestBoardMeetings?: Resolver, ParentType, ContextType, Partial>; + latestElections?: Resolver, ParentType, ContextType, Partial>; + latestHehe?: Resolver, ParentType, ContextType, Partial>; + latestnews?: Resolver, ParentType, ContextType, Partial>; me?: Resolver; - meeting?: Resolver< - ResolversTypes['Meeting'], - ParentType, - ContextType, - RequireFields - >; - meetings?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - myNominations?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - newsentries?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; - numberOfMembers?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - Partial - >; - numberOfNominations?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - RequireFields - >; - numberOfProposals?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - RequireFields - >; - numberOfVolunteers?: Resolver< - ResolversTypes['Int'], - ParentType, - ContextType, - Partial - >; + meeting?: Resolver>; + meetings?: Resolver, ParentType, ContextType, Partial>; + myNominations?: Resolver, ParentType, ContextType, RequireFields>; + newsentries?: Resolver, ParentType, ContextType, Partial>; + numberOfMembers?: Resolver>; + numberOfNominations?: Resolver>; + numberOfProposals?: Resolver>; + numberOfVolunteers?: Resolver>; openElection?: Resolver; - post?: Resolver< - ResolversTypes['Post'], - ParentType, - ContextType, - RequireFields - >; - postAccess?: Resolver< - ResolversTypes['Access'], - ParentType, - ContextType, - RequireFields - >; + post?: Resolver>; + postAccess?: Resolver>; posts?: Resolver, ParentType, ContextType, Partial>; - searchFiles?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - searchUser?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - user?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - userByCard?: Resolver< - ResolversTypes['User'], - ParentType, - ContextType, - RequireFields - >; - users?: Resolver< - Array, - ParentType, - ContextType, - RequireFields - >; - utskott?: Resolver< - ResolversTypes['Utskott'], - ParentType, - ContextType, - RequireFields - >; + searchFiles?: Resolver, ParentType, ContextType, RequireFields>; + searchUser?: Resolver, ParentType, ContextType, RequireFields>; + user?: Resolver>; + userByCard?: Resolver>; + users?: Resolver, ParentType, ContextType, RequireFields>; + utskott?: Resolver>; }>; -export type TokenResponseResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['TokenResponse'] = ResolversParentTypes['TokenResponse'], -> = ResolversObject<{ +export type TokenResponseResolvers = ResolversObject<{ accessToken?: Resolver; refreshToken?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type UserResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User'], -> = ResolversObject<{ +export type UserResolvers = ResolversObject<{ access?: Resolver; address?: Resolver, ParentType, ContextType>; class?: Resolver; @@ -2112,12 +1683,7 @@ export type UserResolvers< luCard?: Resolver, ParentType, ContextType>; phone?: Resolver, ParentType, ContextType>; photoUrl?: Resolver, ParentType, ContextType>; - postHistory?: Resolver< - Array, - ParentType, - ContextType, - Partial - >; + postHistory?: Resolver, ParentType, ContextType, Partial>; posts?: Resolver, ParentType, ContextType>; username?: Resolver; website?: Resolver, ParentType, ContextType>; @@ -2126,10 +1692,7 @@ export type UserResolvers< __isTypeOf?: IsTypeOfResolverFn; }>; -export type UserPostHistoryEntryResolvers< - ContextType = Context, - ParentType extends ResolversParentTypes['UserPostHistoryEntry'] = ResolversParentTypes['UserPostHistoryEntry'], -> = ResolversObject<{ +export type UserPostHistoryEntryResolvers = ResolversObject<{ end?: Resolver, ParentType, ContextType>; post?: Resolver; start?: Resolver; @@ -2165,3 +1728,4 @@ export type Resolvers = ResolversObject<{ User?: UserResolvers; UserPostHistoryEntry?: UserPostHistoryEntryResolvers; }>; + diff --git a/src/resolvers/hehe.resolver.ts b/src/resolvers/hehe.resolver.ts index 3a36984e..476de6d2 100644 --- a/src/resolvers/hehe.resolver.ts +++ b/src/resolvers/hehe.resolver.ts @@ -34,6 +34,11 @@ const heheResolver: Resolvers = { const h = await api.getAllHehes(limit ?? undefined, sortOrder ?? undefined); return reduce(h, heheReduce); }, + allHehes: async (_, { sortOrder }, ctx) => { + await hasAuthenticated(ctx); + const h = await api.getAllHehes(undefined, sortOrder ?? undefined); + return reduce(h, heheReduce); + }, }, Mutation: { addHehe: async (_, { fileId, number, year }, ctx) => { diff --git a/src/schemas/hehe.graphql b/src/schemas/hehe.graphql index 9f01e898..177f36e9 100644 --- a/src/schemas/hehe.graphql +++ b/src/schemas/hehe.graphql @@ -2,6 +2,7 @@ type Query { hehe(number: Int!, year: Int!): Hehe! hehes(year: Int!): [Hehe!]! latestHehe(limit: Int, sortOrder: SortOrder): [Hehe!]! + allHehes(sortOrder: SortOrder): [Hehe!]! } type Mutation { diff --git a/test/unit/post.api.test.ts b/test/unit/post.api.test.ts index 0ea8a4da..c3f9bbd6 100644 --- a/test/unit/post.api.test.ts +++ b/test/unit/post.api.test.ts @@ -1,7 +1,7 @@ import { PostAPI } from '@/api/post.api'; import prisma from '@/api/prisma'; import config from '@/config'; -import { BadRequestError, NotFoundError } from '@/errors/request.errors'; +import { BadRequestError } from '@/errors/request.errors'; import { midnightTimestamp } from '@/util'; import { ModifyPost, NewPost, NewUser, PostType, Utskott } from '@generated/graphql'; import { PrismaPost } from '@prisma/client';