Skip to content
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

Implement fetch adapter #340

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

markspolakovs
Copy link

This should allow using trpc-openapi with Next 13 and other serverless runtimes (eg Cloudflare Workers) (ref. #289).

I've created a sample project at https://github.com/markspolakovs/trpc-openapi-next-13-example.

Should be feature-complete and tested, only thing I'd appreciate thoughts on is an odd typing issue that might be an artifact of my setup - if I remove the as any on https://github.com/markspolakovs/trpc-openapi-next-13-example/blob/190b59da05c9f7ebeb2968aea0648d7f7c93e844/app/api/trpc/_router.ts#L19 I get an error:

Argument of type 'CreateRouterInner<RootConfig<{ ctx: {}; meta: OpenApiMeta; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>, { ...; }>' is not assignable to parameter of type 'OpenApiRouter'.
  The types returned by 'createCaller(...)' are incompatible between these types.
    Type 'DecoratedProcedureRecord<{ echo: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: OpenApiMeta; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; ... 5 more ...; _output_out: string; }, unknown>; }> & { ...; }' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
      Type 'DecoratedProcedureRecord<{ echo: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: OpenApiMeta; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; ... 5 more ...; _output_out: string; }, unknown>; }> & { ...; }' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
        Types of property 'query' are incompatible.
          Type 'inferHandlerFn<{}>' is not assignable to type 'inferHandlerFn<any>'.
            Types of parameters 'path' and 'path' are incompatible.
              Type 'TPath' is not assignable to type 'never'.
                Type 'string' is not assignable to type 'never'.ts(2345)

@markspolakovs
Copy link
Author

Oops, didn't see that #315 also implements this 😅 (though in my defence it hasn't had any activity in a month)

@rwieruch
Copy link

rwieruch commented Jul 17, 2023

Thanks for your work @markspolakovs ! I tested your adapter and get the following error:

The edge runtime does not support Node.js 'stream' module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants