graphql_client
graphql_client copied to clipboard
Use generator instead of transformer
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
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 ?
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.
Thanks a lot for your issue. I will have a look at this during the week 👍 .
Hi @Aetet,
I am looking at Generators right now and I have some questions.
- AngularDart seems to use (not everywhere) "old transformers", do you think they will migrate to generators?
- Why should I create a separate package for the generator? The angular codegen transformer seems to be included into the main repo : https://github.com/dart-lang/angular/blob/master/angular/lib/transform/codegen.dart
- Is there any best practice to name a generator repository that is related to a library?
- I have seen that
graphql_client
users will have to launch a "watcher" (as detailed here). Is there a way to launch this command in parallel of launchingpub serve
?
Thanks in advance!
EDIT: Ready almost ready! https://github.com/hourliert/graphql_client/tree/master/graphql_client_generator 😂
Hi, @hourliert
-
AFAIK they want to migrate to new compiler https://github.com/dart-lang/angular/issues/363 but also supports transformers for backward compatibility
-
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.
- Usually generator named like library but with suffix 'generator' like: built_value - built_value_generator
- 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!
Awesome, thanks a lot for your answer. I'll keep this issue updated.
@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.