-
-
Notifications
You must be signed in to change notification settings - Fork 22
support trpc v11 #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
support trpc v11 #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -50,7 +50,7 @@ | |||||
"type-check": "tsc" | ||||||
}, | ||||||
"peerDependencies": { | ||||||
"@trpc/server": "^10", | ||||||
"@trpc/server": "11.0.0-rc.593", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"zod": "^3" | ||||||
}, | ||||||
"dependencies": { | ||||||
|
@@ -61,7 +61,7 @@ | |||||
"zod-to-ts": "^1.1.2" | ||||||
}, | ||||||
"devDependencies": { | ||||||
"@trpc/server": "10.5.0", | ||||||
"@trpc/server": "11.0.0-rc.593", | ||||||
"@types/aws-lambda": "8.10.109", | ||||||
"@types/express": "4.17.15", | ||||||
"@types/koa": "2.13.5", | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,32 +25,33 @@ export const getProcedureSchemas = (procedures: Procedures) => { | |
const procedureTypes: ProcedureTypes = { queries: {}, mutations: {} } | ||
|
||
Object.entries(procedures) | ||
.filter(([, { _def }]) => _def.query || _def.mutation) | ||
.filter(([, { _def }]) => _def.type === 'query' || _def.type === 'mutation') | ||
.forEach(([procedureName, procedure]) => { | ||
const inputParser = getInputFromInputParsers(procedure._def.inputs) | ||
if (typeof inputParser === 'function') { | ||
return z.any() | ||
} | ||
|
||
const defaultInputValue = inputParser ? getDefaultForDef(inputParser._def) : '' | ||
|
||
let procedureType = '' | ||
let docsType = '' | ||
|
||
if (inputParser) { | ||
const { node } = zodToTs(inputParser) | ||
procedureType = `input: ${printNode(node)}` | ||
|
||
docsType = printNode(createTypeAlias(node, 'input', inputParser.description)) | ||
} | ||
// const inputParser = getInputFromInputParsers(procedure._def.inputs) | ||
// if (typeof inputParser === 'function') { | ||
// return z.any() | ||
// } | ||
// | ||
// const defaultInputValue = inputParser ? getDefaultForDef(inputParser._def) : '' | ||
const defaultInputValue = '' | ||
|
||
const procedureType = '' | ||
const docsType = '' | ||
|
||
// if (inputParser) { | ||
// const { node } = zodToTs(inputParser) | ||
// procedureType = `input: ${printNode(node)}` | ||
// | ||
// docsType = printNode(createTypeAlias(node, 'input', inputParser.description)) | ||
// } | ||
Comment on lines
+30
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you look into this please? Found from comment: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like all of the changes in that gist should be in this PR. Thoughts? |
||
|
||
const procedureDefaults = { | ||
inputLength: defaultInputValue.length, | ||
value: `await trpc.${procedureName}.${procedure._def.query ? 'query' : 'mutate'}(${defaultInputValue})`, | ||
value: `await trpc.${procedureName}.${procedure._def.type === 'query' ? 'query' : 'mutate'}(${defaultInputValue})`, | ||
} | ||
|
||
const procedureObject = procedure._def.query ? procedureSchemas.queries : procedureSchemas.mutations | ||
const typeProcedureObject = procedure._def.query ? procedureTypes.queries : procedureTypes.mutations | ||
const procedureObject = procedure._def.type === 'query' ? procedureSchemas.queries : procedureSchemas.mutations | ||
const typeProcedureObject = procedure._def.type === 'query' ? procedureTypes.queries : procedureTypes.mutations | ||
procedureObject[procedureName] = { default: procedureDefaults, type: docsType } | ||
typeProcedureObject[procedureName] = procedureType | ||
}) | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -36,12 +36,12 @@ | |||||
"type-check": "tsc" | ||||||
}, | ||||||
"peerDependencies": { | ||||||
"@trpc/server": "^10" | ||||||
"@trpc/server": "11.0.0-rc.593" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to be strict about peer dependencies.
Suggested change
|
||||||
}, | ||||||
"dependencies": { | ||||||
"ts-essentials": "^9.3.0" | ||||||
}, | ||||||
"devDependencies": { | ||||||
"@trpc/server": "10.5.0" | ||||||
"@trpc/server": "11.0.0-rc.593" | ||||||
} | ||||||
} |
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.
This should be changed to 11.0.1 across the board.