-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
V11 support #55
Comments
Hey 👋 I was running into this too, so I fixed it by tracking down the issues in the https://gist.github.com/andrewgeorgemitchell/33f3a97ce3d4d8312b71834a940091d8 To use this just copy this gist into a file in your repo for example And then update your tRPC playground route handler like this: import type { NextApiHandler } from 'next'
import { zodResolveTypes } from './trpc-playground-fix' // 👈 Import zodResolveTypes from gist file
import { nextHandler } from 'trpc-playground/handlers/next'
import { appRouter } from 'api'
const setupHandler = nextHandler({
router: appRouter,
// tRPC api path, pages/api/trpc/[trpc].ts in this case
trpcApiEndpoint: '/api/trpc',
playgroundEndpoint: '/api/trpc-playground',
resolveTypes: zodResolveTypes, // 👈 Pass in the updated zodResolveTypes function with the fixes to resolveTypes option
request: {
superjson: true,
},
})
const handler: NextApiHandler = async (req, res) => {
const playgroundHandler = await setupHandler
await playgroundHandler(req, res)
}
export default handler @sachinraja FWIW the issue is that All my version of the
To: Totally understand if you don't want to fix this until tRPC v11 is actually done, but I'm also down to help get a canary/next version up for trpc-playground that fixes this issue in the package in a non janky way. |
@andrewgeorgemitchell thank you for the fix, I will check it |
@andrewgeorgemitchell I just convert your changes to a patch file for pnpm if you want to use it with patch package replace |
@omarkhatibco I think this patch is missing one change from @andrewgeorgemitchell's gist for these two lines having In the patch, instead of the below code: if (procedure._def?.query)
procedureTypeDef += `query: (${inputType}) => void,`;
else if (procedure._def?.mutation)
procedureTypeDef += `mutate: (${inputType}) => void,`; it should be like this: if (procedure._def?.type === 'query')
procedureTypeDef += `query: (${inputType}) => void,`;
else if (procedure._def?.type === 'mutation')
procedureTypeDef += `mutate: (${inputType}) => void,`; And it will need to be changed in all Due to this missing change, all the types in "trpc-playground" could not identify Please check! |
Any chance we could get this fix merged into the core? |
any chance ? |
I created a PR for this (#61). Use this patch if you want to use trpc-playground on trpc v11: |
Hi,
I'm using the playground with the latest trpc version 11, now it's working fine expect that I get no autocomplete even the docs are empty
it seems the function
getRouterSchema
unable to get the types.I'm using it with a test server based on fastify
The text was updated successfully, but these errors were encountered: