maloguertin / msw-trpc

tPRC support for MSW
208 stars 21 forks source link

Bug: `output` is used inside `getMutationInput` #38

Closed Tomomi-K1 closed 6 months ago

Tomomi-K1 commented 8 months ago

Describe the bug Inside getMutationInput, output is used instead of input to get the return value. When using a transformer, when it's mutation, deserialization is not applied for mutation input.

this should be changed from:

const getMutationInput = async (req: Request, transformer: CombinedDataTransformer) => {
  const body = await req.json()

  return transformer.output.deserialize(body)
}

to:

const getMutationInput = async (req: Request, transformer: CombinedDataTransformer) => {
  const body = await req.json()

  return transformer.input.deserialize(body)
}