diff --git a/functions/graphql/form/resolver.ts b/functions/graphql/form/resolver.ts index 0355ab7..516f397 100644 --- a/functions/graphql/form/resolver.ts +++ b/functions/graphql/form/resolver.ts @@ -32,8 +32,7 @@ const queries = { { input }: { input: GetFormResponsesByFormIdInput }, ctx: ServerContext ) => { - ensureAuthenticated(ctx) - return FormService.getFormResponsesByFormId(input.formId, ctx) + return FormService.getFormResponsesByFormId(input.formId) }, getFormResponsesByProjectId: async ( _: any, diff --git a/services/form.ts b/services/form.ts index d2f81bd..b0023e1 100644 --- a/services/form.ts +++ b/services/form.ts @@ -107,21 +107,27 @@ class FormService { }) } - public static getFormResponsesByFormId(formId: string, ctx: ServerContext) { - if (!ctx.user?.id) throw new AccessDeniedError() - + public static getFormResponsesByFormId(formId: string) { return prismaClient.formResponse.findMany({ where: { - AND: [ - { - form: { - id: formId, - project: { - ProjectAccessMapping: { every: { user: { id: ctx.user.id } } }, // TODO: Need to test more deeply - }, - }, - }, - ], + formId, + }, + orderBy: { + updatedAt: 'desc', + }, + select: { + approved: true, + company: true, + createdAt: true, + email: true, + imageURL: true, + id: true, + jobTitle: true, + rating: true, + testimonial: true, + name: true, + websiteUrl: true, + formId: true, }, }) }