From 809b7e41ce292b28c3d365c868417a1be7aa4c61 Mon Sep 17 00:00:00 2001 From: Mnigos Date: Sat, 25 Jan 2025 16:28:06 +0100 Subject: [PATCH] docs(pages/integrations): add mention about transformer usage --- docs/pages/docs/integrations.mdx | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/docs/pages/docs/integrations.mdx b/docs/pages/docs/integrations.mdx index 720642b..2fb5101 100644 --- a/docs/pages/docs/integrations.mdx +++ b/docs/pages/docs/integrations.mdx @@ -6,6 +6,56 @@ import { Callout, Steps, Tabs } from 'nextra-theme-docs'; # Integrations +### Data Transformers +You are able to serialize the response data & input args. Right now the only supported transformer is `superjson`. + +You need to use `superjson` version `1.13.3` because version `^2.0.0` doesn't support commonjs. + +To use `superjson`, you can install it using your preferred package manager: + + + + ```bash copy + npm install superjson@1.13.3 + ``` + + + ```bash copy + pnpm add superjson@1.13.3 + ``` + + + ```bash copy + yarn add superjson@1.13.3 + ``` + + + ```bash copy + bun install superjson@1.13.3 + ``` + + + +And then you can use it in your `TRPCModule` options: + +```typescript filename="app.module.ts" copy +import { Module } from '@nestjs/common'; +import { TRPCModule } from 'nestjs-trpc'; +import { superjson } from 'superjson'; + +@Module({ + imports: [ + TRPCModule.forRoot({ + autoSchemaFile: './src/@generated', + transformer: superjson, + }), + ], +}) +export class AppModule {} +``` + + + ### Accessing the AppRouter In some circumstances ,for example end-to-end tests or integrating with other `trpc` plugins, you may want to get a reference to the generated appRouter object. In end-to-end tests, you can then run queries using the appRouter object directly without using any HTTP listeners.