leonardfactory / babel-plugin-transform-typescript-metadata

Babel plugin to emit decorator metadata like typescript compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support type-graphql's plans for a more advanced reflection system

vjpr opened this issue · comments

type-graphql is a popular TS library for GraphQL. They plan on writing a TS compiler extension to DRY up type info in field definitions.

MichalLytek/type-graphql#296

How hard would it be to support this? Do you have time? Could you provide some pointers on the difficulties and where to begin?

Hi @vjpr, if I'm correct the typegraphql plugin is currently checking for a limited field of usage, like supporting promises and arrays, as seen here.

The Reflect.metadata output is here, and it seems to me that the typegraphql:info is a simple object literal with some info. It should not be hard to implement it in the plugin, and maybe I can find some time in the next weeks to add support (surely behind a flag).

However, I cannot find a spec in order to understand the desired output. The code seems to do the following:

  1. Promises unwrapping (Promise<T> is treated as T)
  2. Arrays unwrapping
  3. Unions are processed but only as T | null (i.e. T | U is not supported)

These things may be implemented, but since this is a POC I'd like to have more info from the awesome job made by @19majkel94, since I'm worried do proceed without a clean plan ahead. Do you have any info / plans / specs available? I was not able to find them in the repo

I don't have a proper specs as I don't know how much info I will need. The plans are described here:
https://github.com/19majkel94/typegraphql-reflection-poc#further-work

I am going to create a TypeGraphQL-specific plugin and in the feature I might turn it into an universal reflection plugin with described specs that can be implemented e.g. by a babel plugin.

But the very future step might be not possible in current babel typescript pipeline as I would like to provide support for raw TS constructs like interfaces, without constraints to classes and decorators only.

Closing this, if someone has news feel free to let me know!