Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flatten POST/mutation requests'
input
(#671)
- Loading branch information
Showing
6 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
import { z } from 'zod'; | ||
import * as trpc from '../src'; | ||
import { routerToServerAndClient } from './_testHelpers'; | ||
import fetch from 'node-fetch'; | ||
test('call mutation with `input`-prop', async () => { | ||
const { close, httpUrl } = routerToServerAndClient( | ||
trpc.router().mutation('myMutation', { | ||
input: z.object({ | ||
name: z.string(), | ||
}), | ||
async resolve({ input }) { | ||
return { input }; | ||
}, | ||
}), | ||
); | ||
|
||
const res = await fetch(`${httpUrl}/myMutation`, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
input: { | ||
name: 'alexdotjs', | ||
}, | ||
}), | ||
}); | ||
const json = await res.json(); | ||
|
||
expect(json.result).toMatchInlineSnapshot(` | ||
Object { | ||
"data": Object { | ||
"input": Object { | ||
"name": "alexdotjs", | ||
}, | ||
}, | ||
"type": "data", | ||
} | ||
`); | ||
|
||
close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c85f62e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
www – ./www
www.trpc.io
www.tmp.trpc.io
trpc.io
www-git-main.tmp.trpc.io
c85f62e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
todomvc – ./examples/next-prisma-todomvc
todomvc.tmp.trpc.io
todomvc.trpc.io
trpc.tmp.trpc.io
todomvc-git-main.tmp.trpc.io