dart-graphql / graphql_client

GraphQL Client.
https://pub.dartlang.org/packages/graphql_client
MIT License
78 stars 9 forks source link

Use generator instead of transformer #9

Open Aetet opened 7 years ago

Aetet commented 7 years ago

As I know dart team will deprecate transformer API favor to builder api. Like https://github.com/google/built_value.dart I think it would be great if it ll be builder from the beginning

hourliert commented 7 years ago

Thanks for your comment. I have never wrote a transformer but I am eager to learn.

Do you mean that this is the Builder API: https://github.com/dart-lang/build ?

Aetet commented 7 years ago

Yep. This is it. Example of the generator: https://github.com/google/built_value.dart/tree/master/built_value_generator

Generator must be separate package. This prevent problems from analyzer, source_gen deps. Because they always must be sync with upstream.

hourliert commented 7 years ago

Thanks a lot for your issue. I will have a look at this during the week 👍 .

hourliert commented 7 years ago

Hi @Aetet,

I am looking at Generators right now and I have some questions.

Thanks in advance!

EDIT: Ready almost ready! https://github.com/hourliert/graphql_client/tree/master/graphql_client_generator 😂

Aetet commented 7 years ago

Hi, @hourliert

  1. AFAIK they want to migrate to new compiler https://github.com/dart-lang/angular/issues/363 but also supports transformers for backward compatibility

  2. The main issue - all modules even for dev dependency must satisfy by version. For example you have following deps:

    dep:
    built_value: 
    angular: 4.0.0
    dev_dep:
    # for coverage
    dart_dev: 1.0.0

And if your package for coverage dart_dev wants analyzer 0.28.0 and angular 0.30.0 - because of semver we cannot resolve this deps.

So you need downgrade angular, or patch dart_dev by yourself, or separate dart_dev as external package. And run it like cli.

Occasionally will run into this problem. For built_value_generator, dartfmt, less_transformer, etc. That's why you need to reduce it with separate package. To solve this problem by infrastructure we need separate section at pubspec for this deps. But AFAIK it won't be shipped at Dart 2.0.

  1. Usually generator named like library but with suffix 'generator' like: built_value - built_value_generator
  2. As I can see at the issues https://github.com/dart-lang/angular/issues/420 they want to deprecate pub serve too. I think dart developers at https://gitter.im/dart-lang/angular2 can answer your questions more precisely.

I think good practice to use single repo for generator and library, but have separate package for them at pub.

Thanks to you!

hourliert commented 7 years ago

Awesome, thanks a lot for your answer. I'll keep this issue updated.

g33kidd commented 6 years ago

@hourliert Has there been any progress on this front? This would indeed be a handy feature! I'd love to help out where I can.