From acf10c8f07aa50cdf7ebd62f1c1f8755aa3867c4 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Thu, 28 Mar 2024 10:10:09 +0000 Subject: [PATCH] Fix TypeScript issues --- src/__tests__/starWarsSchema.ts | 2 +- src/mutation/mutation.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/__tests__/starWarsSchema.ts b/src/__tests__/starWarsSchema.ts index ea600cc..4df9a77 100644 --- a/src/__tests__/starWarsSchema.ts +++ b/src/__tests__/starWarsSchema.ts @@ -247,7 +247,7 @@ const shipMutation = mutationWithClientMutationId({ outputFields: { ship: { type: shipType, - resolve: (payload) => getShip(payload.shipId), + resolve: (payload: any) => getShip(payload.shipId), }, faction: { type: factionType, diff --git a/src/mutation/mutation.ts b/src/mutation/mutation.ts index a9c5dcc..1f61ffb 100644 --- a/src/mutation/mutation.ts +++ b/src/mutation/mutation.ts @@ -14,7 +14,11 @@ import type { ThunkObjMap, } from 'graphql'; -type MutationFn = (object: TInput, ctx: TContext, info: GraphQLResolveInfo) => TOutput; +type MutationFn = ( + object: TInput, + ctx: TContext, + info: GraphQLResolveInfo, +) => TOutput; /** * A description of a mutation consumable by mutationWithClientMutationId @@ -44,9 +48,13 @@ interface MutationConfig { * Returns a GraphQLFieldConfig for the mutation described by the * provided MutationConfig. */ -export function mutationWithClientMutationId( +export function mutationWithClientMutationId< + TInput = any, + TOutput = unknown, + TContext = any, +>( config: MutationConfig, -): GraphQLFieldConfig { +): GraphQLFieldConfig { const { name, inputFields, outputFields, mutateAndGetPayload } = config; const augmentedInputFields = () => ({ ...resolveObjMapThunk(inputFields),