Skip to content

Resolvers: Add a way to export/import resolvers while preserving type safety #3367

@matthew-salerno

Description

@matthew-salerno

Description

First mention in #3132. My resolvers are getting quite large. I would to split them out of my openapi-ts.config.ts file. However, I cannot do this without losing type safety:

// Not type checked anymore!
// Type was: (ctx: NumberResolverContext$1) => PipeResult | undefined
// Type is now: (ctx: any) => any
export const myNumberResolver = function number(ctx) {
  ...
}

I would like to be able to provide type info like I can for transformers:

// Nice and easy, I get to reuse TypeTransformer
// Still type checked for correctness
export const myTransformer: TypeTransformer = ({ schema }) => {
  ...
}

This can be marked enhancement, I wanted to be able to link the stackblitz reproducer but couldn't when I used the enhancement template.

Reproducible example or configuration

https://stackblitz.com/edit/ttamttam-heyapi-resolver-imports

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature 🚀Feature request.important 📌This issue is important and will be addressed when capacity allows.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions