File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,23 @@ const postsRouter = createTRPCRouter({
31
31
text : input . text ,
32
32
} ;
33
33
} ) ,
34
+ createNestedPost : procedure
35
+ . input (
36
+ z . object ( {
37
+ text : z . string ( ) ,
38
+ } )
39
+ )
40
+ . input (
41
+ z . object ( {
42
+ title : z . string ( ) ,
43
+ } )
44
+ )
45
+ . mutation ( ( { input } ) => {
46
+ return {
47
+ id : "aoisdjfoasidjfasodf" ,
48
+ text : input . text ,
49
+ } ;
50
+ } ) ,
34
51
} ) ;
35
52
36
53
export const appRouter = createTRPCRouter ( {
Original file line number Diff line number Diff line change 84
84
"tslib" : " ^2.4.1" ,
85
85
"typescript" : " ^5.4.5" ,
86
86
"url" : " ^0.11.0" ,
87
- "zod" : " ^3.19.1" ,
88
87
"zustand" : " ^4.1.5"
89
88
},
90
89
"dependencies" : {
Original file line number Diff line number Diff line change @@ -76,10 +76,26 @@ function nodeAndInputSchemaFromInputs(
76
76
} ) ,
77
77
} ;
78
78
}
79
- if ( inputs . length !== 1 ) {
79
+
80
+ let input = inputs [ 0 ] ;
81
+ if ( inputs . length < 1 ) {
80
82
return { parseInputResult : "failure" } ;
81
83
}
82
- const input = inputs [ 0 ] ;
84
+
85
+ if ( inputs . length > 1 ) {
86
+ const allInputsAreZodObjects = inputs . every (
87
+ ( input ) => input instanceof z . ZodObject
88
+ ) ;
89
+ if ( ! allInputsAreZodObjects ) {
90
+ return { parseInputResult : "failure" } ;
91
+ }
92
+
93
+ input = inputs . reduce (
94
+ ( acc , input : z . AnyZodObject ) => ( acc as z . AnyZodObject ) . merge ( input ) ,
95
+ emptyZodObject
96
+ ) ;
97
+ }
98
+
83
99
const iType = inputType ( input ) ;
84
100
if ( iType == "unsupported" ) {
85
101
return { parseInputResult : "failure" } ;
You can’t perform that action at this time.
0 commit comments