GraphQlClientGenerator
GraphQlClientGenerator copied to clipboard
[WIP]: Add fluent builder pattern
Note: This is a work in progress. It contains a lot of duplicated code. It does not cover all of the possible "With..." methods. The purpose of this PR is to evaluate the usefulness of this approach.
This PR extends the generator to add additional With...
methods with a Func<...Builder, ...Builder>
parameter to facilitate calling .With(builder => builder.WithSomeField())
. It'll make writing code easier since the developer need not deal with the actual class name that is expected but may just continue writing fluently.
Example of a generated method:
public QueryQueryBuilder WithMe(Func<MeQueryBuilder, MeQueryBuilder> meQueryBuilderTransformation, string alias = null)
{
return WithObjectField("me", alias, meQueryBuilderTransformation(new MeQueryBuilder()), new GraphQlDirective[] { include, skip });
}
This would have to be refined to include all possible With-methods that are being generated. Also, the new generated method should call the existing method instead of duplicating the body.
Thank you for this great library. Thoughts are much appreciated.