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

feat(generator): add tRPC generator #415

Closed
wants to merge 7 commits into from

Conversation

DaleWebb
Copy link

@DaleWebb DaleWebb commented Jun 2, 2022

Status

READY

Description

This PR introduces a generator for tRPC. tRPC is a library for creating type-safe APIs.

The generator will create a router for each Open API input, with routes for each GET, POST etc.

This includes changes to existing functions. They are to un-promise their response - the Promise didn't appear to be required:

  • src/core/getters/object.ts
  • src/core/getters/ref.ts
  • src/core/resolvers/ref.ts

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

@vercel
Copy link

vercel bot commented Jun 2, 2022

Someone is attempting to deploy a commit to a Personal Account owned by @anymaniax on Vercel.

@anymaniax first needs to authorize it.

Comment on lines -33 to -36
export const getRefInfo = async (
export const getRefInfo = (
$ref: ReferenceObject['$ref'],
context: ContextSpecs,
): Promise<{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't appear to be a reason why this should be a promise.

schema: ComponentObject,
context: ContextSpecs,
imports: GeneratorImport[] = [],
): Promise<{
): {
schema: Schema;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't appear to be a reason why this should be a promise.

@anymaniax
Copy link
Collaborator

Hello @DaleWebb, thanks for the pull request. This new generator only use trpc as gateway to use another api?

@DaleWebb
Copy link
Author

DaleWebb commented Jun 6, 2022

Hello @DaleWebb, thanks for the pull request. This new generator only use trpc as gateway to use another api?

Hey @anymaniax - thanks for responding. Effectively, this implementation of tRPC will generate a typesafe API to endpoints in an OpenAPI spec

@anymaniax
Copy link
Collaborator

can be introduce with v7 #434 and with your own template then maybe

@anymaniax
Copy link
Collaborator

I will do some tests this week to see if we can merge it could be a good template. I add another idea about trpc since moment where instead of the mutator or the http call function we could add a sort of handler to have some business logic directly there. We currently could do it with the mutator but would be annoying to do.

@stijnvanhulle stijnvanhulle mentioned this pull request Aug 20, 2022
4 tasks
@anymaniax anymaniax force-pushed the master branch 2 times, most recently from e2edc19 to 60b251d Compare September 23, 2022 12:55
@anymaniax
Copy link
Collaborator

Hello @DaleWebb, you can now check the new architecture and create your own client with the extracted core. The current version is @orval/[email protected]. If you do so I would be happy to add a section about your client in orval doc

You can now do something like this.

import query from '@orval/query';
import { defineConfig } from 'orval';

export default defineConfig({
  petstore: {
    output: {
       client: query() // query({type: 'svelte-query'}) for another query client,
     }
  }
});

so you could do exactly the same with your own client

@anymaniax anymaniax force-pushed the master branch 2 times, most recently from c066483 to 14b9f50 Compare January 16, 2023 12:24
@melloware melloware closed this Dec 16, 2023
@melloware
Copy link
Collaborator

No response from OP and PR is 2 years old

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.

3 participants