comigor / artemis

Build dart types from GraphQL schemas and queries
MIT License
495 stars 119 forks source link

custom class name #214

Open BeshoyMelika opened 3 years ago

BeshoyMelika commented 3 years ago

Bug description i have class with this name SignIn$Mutation$AuthPayload i need to custom this name can I custom classes name

Specs Artemis version: [e.g. 6.0.3-beta.1]

build.yaml: ```yaml targets: $default: sources: - $package$ - lib/$lib$ - lib/graphql/** - general.schema.graphql builders: artemis: options: fragments_glob: lib/graphql/fragments.graphql schema_mapping: - schema: general.schema.graphql queries_glob: lib/graphql/auth/*.graphql output: lib/generatedql/auth/graphql_api.dart - schema: general.schema.graphql ```
Artemis output: ```bash [ +168 ms] executing: [/Users/ahmed_pc/Development/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H [ +92 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H [ ] 8b3760638a189741cd9ca881aa2dd237c1df1be5 [ +3 ms] executing: [/Users/ahmed_pc/Development/flutter/] git tag --points-at HEAD [ +150 ms] Exit code 0 from: git tag --points-at HEAD [ ] 1.22.0-12.1.pre [ +21 ms] executing: [/Users/ahmed_pc/Development/flutter/] git rev-parse --abbrev-ref --symbolic @{u} [ +16 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u} [ ] origin/beta [ ] executing: [/Users/ahmed_pc/Development/flutter/] git ls-remote --get-url origin [ +17 ms] Exit code 0 from: git ls-remote --get-url origin [ ] https://github.com/flutter/flutter.git [ +101 ms] executing: [/Users/ahmed_pc/Development/flutter/] git rev-parse --abbrev-ref HEAD [ +53 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD [ ] beta [ +15 ms] executing: sw_vers -productName [ +72 ms] Exit code 0 from: sw_vers -productName [ ] Mac OS X [ ] executing: sw_vers -productVersion [ +22 ms] Exit code 0 from: sw_vers -productVersion [ ] 10.15.6 [ ] executing: sw_vers -buildVersion [ +25 ms] Exit code 0 from: sw_vers -buildVersion [ ] 19G2021 [ +125 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update. [ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update. [ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update. [ +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update. [ +5 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update. [ +8 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update. [ ] Artifact Instance of 'GradleWrapper' is not required, skipping update. [ ] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update. [ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update. [ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update. [ ] Artifact Instance of 'FlutterSdk' is not required, skipping update. [ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update. [ +63 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update. [ +6 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update. [ +98 ms] Using /Users/ahmed_pc/Development/flutter/.pub-cache for the pub cache. [ ] executing: /Users/ahmed_pc/Development/flutter/bin/cache/dart-sdk/bin/pub run build_runner build --verbose [INFO] Generating build script... [INFO] Generating build script completed, took 623ms [INFO] Creating build script snapshot...... [INFO] Creating build script snapshot... completed, took 21.2s [INFO] BuildDefinition:Initializing inputs [INFO] BuildDefinition:Building new asset graph... [INFO] BuildDefinition:Building new asset graph completed, took 844ms [INFO] BuildDefinition:Checking for unexpected pre-existing outputs.... [INFO] BuildDefinition:Checking for unexpected pre-existing outputs. completed, took 2ms [INFO] Build:Running build... [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][ProductsOrderByOrderByClause] [FINE] artemis:artemis on lib/$lib$:| [][ProductsOrderByOrderByClause][ClassName(name:r'ProductsOrderByColumn') ClassPropertyName(name:r'field')] -> ProductsOrderByColumn [FINE] artemis:artemis on lib/$lib$:| [][ProductsOrderByOrderByClause][ClassName(name:r'SortOrder') ClassPropertyName(name:r'order')] -> SortOrder [FINE] artemis:artemis on lib/$lib$:└ [][ProductsOrderByOrderByClause] [FINE] artemis:artemis on lib/$lib$:<- Generated input class ProductsOrderByOrderByClause. [FINE] artemis:artemis on lib/$lib$:-> Enum [FINE] artemis:artemis on lib/$lib$:<- Generated enum ProductsOrderByColumn. [FINE] artemis:artemis on lib/$lib$:-> Enum [FINE] artemis:artemis on lib/$lib$:<- Generated enum SortOrder. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][ProductFilter] [FINE] artemis:artemis on lib/$lib$:| [][ProductFilter][ClassName(name:r'ID') ClassPropertyName(name:r'id')] -> String [FINE] artemis:artemis on lib/$lib$:| [][ProductFilter][ClassName(name:r'String') ClassPropertyName(name:r'name')] -> String [FINE] artemis:artemis on lib/$lib$:| [][ProductFilter][ClassName(name:r'String') ClassPropertyName(name:r'sku')] -> String [FINE] artemis:artemis on lib/$lib$:| [][ProductFilter][ClassName(name:r'ID') ClassPropertyName(name:r'category')] -> List [FINE] artemis:artemis on lib/$lib$:| [][ProductFilter][ClassName(name:r'ID') ClassPropertyName(name:r'brand')] -> List [FINE] artemis:artemis on lib/$lib$:| [][ProductFilter][ClassName(name:r'ID') ClassPropertyName(name:r'store')] -> List [FINE] artemis:artemis on lib/$lib$:└ [][ProductFilter] [FINE] artemis:artemis on lib/$lib$:<- Generated input class ProductFilter. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][OrderInput] [FINE] artemis:artemis on lib/$lib$:| [][OrderInput][ClassName(name:r'ID') ClassPropertyName(name:r'address_id')] -> String [FINE] artemis:artemis on lib/$lib$:| [][OrderInput][ClassName(name:r'ID') ClassPropertyName(name:r'voucher_id')] -> String [FINE] artemis:artemis on lib/$lib$:└ [][OrderInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class OrderInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][LoginInput] [FINE] artemis:artemis on lib/$lib$:| [][LoginInput][ClassName(name:r'String') ClassPropertyName(name:r'email')] -> String [FINE] artemis:artemis on lib/$lib$:| [][LoginInput][ClassName(name:r'String') ClassPropertyName(name:r'password')] -> String [FINE] artemis:artemis on lib/$lib$:| [][LoginInput][ClassName(name:r'String') ClassPropertyName(name:r'device_token')] -> String [FINE] artemis:artemis on lib/$lib$:└ [][LoginInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class LoginInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][ResetPasswordInput] [FINE] artemis:artemis on lib/$lib$:| [][ResetPasswordInput][ClassName(name:r'String') ClassPropertyName(name:r'email')] -> String [FINE] artemis:artemis on lib/$lib$:| [][ResetPasswordInput][ClassName(name:r'String') ClassPropertyName(name:r'new_password')] -> String [FINE] artemis:artemis on lib/$lib$:| [][ResetPasswordInput][ClassName(name:r'String') ClassPropertyName(name:r'token')] -> String [FINE] artemis:artemis on lib/$lib$:└ [][ResetPasswordInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class ResetPasswordInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][RegisterInput] [FINE] artemis:artemis on lib/$lib$:| [][RegisterInput][ClassName(name:r'String') ClassPropertyName(name:r'name')] -> String [FINE] artemis:artemis on lib/$lib$:| [][RegisterInput][ClassName(name:r'String') ClassPropertyName(name:r'email')] -> String [FINE] artemis:artemis on lib/$lib$:| [][RegisterInput][ClassName(name:r'String') ClassPropertyName(name:r'password')] -> String [FINE] artemis:artemis on lib/$lib$:| [][RegisterInput][ClassName(name:r'String') ClassPropertyName(name:r'password_confirmation')] -> String [FINE] artemis:artemis on lib/$lib$:└ [][RegisterInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class RegisterInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][AddressInput] [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'first_name')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'last_name')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'ID') ClassPropertyName(name:r'area_id')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'info')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'additional_info')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'mobile')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'lat')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'String') ClassPropertyName(name:r'lng')] -> String [FINE] artemis:artemis on lib/$lib$:| [][AddressInput][ClassName(name:r'Boolean') ClassPropertyName(name:r'isDefault')] -> bool [FINE] artemis:artemis on lib/$lib$:└ [][AddressInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class AddressInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][UpdateProfile] [FINE] artemis:artemis on lib/$lib$:| [][UpdateProfile][ClassName(name:r'String') ClassPropertyName(name:r'name')] -> String [FINE] artemis:artemis on lib/$lib$:| [][UpdateProfile][ClassName(name:r'String') ClassPropertyName(name:r'mobile')] -> String [FINE] artemis:artemis on lib/$lib$:└ [][UpdateProfile] [FINE] artemis:artemis on lib/$lib$:<- Generated input class UpdateProfile. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][CartInput] [FINE] artemis:artemis on lib/$lib$:| [][CartInput][ClassName(name:r'ID') ClassPropertyName(name:r'product_id')] -> String [FINE] artemis:artemis on lib/$lib$:| [][CartInput][ClassName(name:r'Int') ClassPropertyName(name:r'quantity')] -> int [FINE] artemis:artemis on lib/$lib$:└ [][CartInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class CartInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][ReviewInput] [FINE] artemis:artemis on lib/$lib$:| [][ReviewInput][ClassName(name:r'Int') ClassPropertyName(name:r'product_id')] -> int [FINE] artemis:artemis on lib/$lib$:| [][ReviewInput][ClassName(name:r'Int') ClassPropertyName(name:r'rating')] -> int [FINE] artemis:artemis on lib/$lib$:| [][ReviewInput][ClassName(name:r'String') ClassPropertyName(name:r'review')] -> String [FINE] artemis:artemis on lib/$lib$:└ [][ReviewInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class ReviewInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][WishlistInput] [FINE] artemis:artemis on lib/$lib$:| [][WishlistInput][ClassName(name:r'Int') ClassPropertyName(name:r'product_id')] -> int [FINE] artemis:artemis on lib/$lib$:└ [][WishlistInput] [FINE] artemis:artemis on lib/$lib$:<- Generated input class WishlistInput. [FINE] artemis:artemis on lib/$lib$:-> Input class [FINE] artemis:artemis on lib/$lib$:┌ [][OrderByClause] [FINE] artemis:artemis on lib/$lib$:| [][OrderByClause][ClassName(name:r'String') ClassPropertyName(name:r'field')] -> String [FINE] artemis:artemis on lib/$lib$:| [][OrderByClause][ClassName(name:r'SortOrder') ClassPropertyName(name:r'order')] -> SortOrder [FINE] artemis:artemis on lib/$lib$:└ [][OrderByClause] [FINE] artemis:artemis on lib/$lib$:<- Generated input class OrderByClause. [FINE] artemis:artemis on lib/$lib$:-> Enum [FINE] artemis:artemis on lib/$lib$:<- Generated enum Trashed. [FINE] artemis:artemis on lib/$lib$:-> Class [FINE] artemis:artemis on lib/$lib$:┌ [TypeName(name:r'SignUp'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:| [TypeName(name:r'SignUp'), TypeName(name:r'Mutation')][Mutation][ClassName(name:r'User') ClassPropertyName(name:r'register')] -> SignUp$Mutation$User [FINE] artemis:artemis on lib/$lib$:| -> Class [FINE] artemis:artemis on lib/$lib$:| ┌ [TypeName(name:r'SignUp'), TypeName(name:r'Mutation'), ClassName(name:r'User')][User][null null] () [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignUp'), TypeName(name:r'Mutation'), ClassName(name:r'User')][User][ClassName(name:r'ID') ClassPropertyName(name:r'id')] -> String [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignUp'), TypeName(name:r'Mutation'), ClassName(name:r'User')][User][ClassName(name:r'String') ClassPropertyName(name:r'name')] -> String [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignUp'), TypeName(name:r'Mutation'), ClassName(name:r'User')][User][ClassName(name:r'String') ClassPropertyName(name:r'email')] -> String [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignUp'), TypeName(name:r'Mutation'), ClassName(name:r'User')][User][ClassName(name:r'String') ClassPropertyName(name:r'mobile')] -> String [FINE] artemis:artemis on lib/$lib$:| └ [TypeName(name:r'SignUp'), TypeName(name:r'Mutation'), ClassName(name:r'User')][User][null null] () [FINE] artemis:artemis on lib/$lib$:| <- Generated class SignUp$Mutation$User. [FINE] artemis:artemis on lib/$lib$:└ [TypeName(name:r'SignUp'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:<- Generated class SignUp$Mutation. [FINE] artemis:artemis on lib/$lib$:-> Class [FINE] artemis:artemis on lib/$lib$:┌ [TypeName(name:r'ResetPassword'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:| [TypeName(name:r'ResetPassword'), TypeName(name:r'Mutation')][Mutation][ClassName(name:r'Boolean') ClassPropertyName(name:r'resetPassword')] -> bool [FINE] artemis:artemis on lib/$lib$:└ [TypeName(name:r'ResetPassword'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:<- Generated class ResetPassword$Mutation. [FINE] artemis:artemis on lib/$lib$:-> Class [FINE] artemis:artemis on lib/$lib$:┌ [TypeName(name:r'Logout'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:| [TypeName(name:r'Logout'), TypeName(name:r'Mutation')][Mutation][ClassName(name:r'Boolean') ClassPropertyName(name:r'logout')] -> bool [FINE] artemis:artemis on lib/$lib$:└ [TypeName(name:r'Logout'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:<- Generated class Logout$Mutation. [FINE] artemis:artemis on lib/$lib$:-> Class [FINE] artemis:artemis on lib/$lib$:┌ [TypeName(name:r'ForgetPassword'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:| [TypeName(name:r'ForgetPassword'), TypeName(name:r'Mutation')][Mutation][ClassName(name:r'Boolean') ClassPropertyName(name:r'forgetPassword')] -> bool [FINE] artemis:artemis on lib/$lib$:└ [TypeName(name:r'ForgetPassword'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:<- Generated class ForgetPassword$Mutation. [FINE] artemis:artemis on lib/$lib$:-> Class [FINE] artemis:artemis on lib/$lib$:┌ [TypeName(name:r'SignIn'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:| [TypeName(name:r'SignIn'), TypeName(name:r'Mutation')][Mutation][ClassName(name:r'AuthPayload') ClassPropertyName(name:r'login')] -> SignIn$Mutation$AuthPayload [FINE] artemis:artemis on lib/$lib$:| -> Class [FINE] artemis:artemis on lib/$lib$:| ┌ [TypeName(name:r'SignIn'), TypeName(name:r'Mutation'), ClassName(name:r'AuthPayload')][AuthPayload][null null] () [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignIn'), TypeName(name:r'Mutation'), ClassName(name:r'AuthPayload')][AuthPayload][ClassName(name:r'String') ClassPropertyName(name:r'access_token')] -> String [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignIn'), TypeName(name:r'Mutation'), ClassName(name:r'AuthPayload')][AuthPayload][ClassName(name:r'String') ClassPropertyName(name:r'refresh_token')] -> String [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignIn'), TypeName(name:r'Mutation'), ClassName(name:r'AuthPayload')][AuthPayload][ClassName(name:r'Int') ClassPropertyName(name:r'expires_in')] -> int [FINE] artemis:artemis on lib/$lib$:| | [TypeName(name:r'SignIn'), TypeName(name:r'Mutation'), ClassName(name:r'AuthPayload')][AuthPayload][ClassName(name:r'String') ClassPropertyName(name:r'token_type')] -> String [FINE] artemis:artemis on lib/$lib$:| └ [TypeName(name:r'SignIn'), TypeName(name:r'Mutation'), ClassName(name:r'AuthPayload')][AuthPayload][null null] () [FINE] artemis:artemis on lib/$lib$:| <- Generated class SignIn$Mutation$AuthPayload. [FINE] artemis:artemis on lib/$lib$:└ [TypeName(name:r'SignIn'), TypeName(name:r'Mutation')][Mutation][null null] () [FINE] artemis:artemis on lib/$lib$:<- Generated class SignIn$Mutation. [INFO] build_resolvers:Generating SDK summary... [INFO] Heartbeat:6.1s elapsed, 1/3 actions completed. [INFO] build_resolvers:Generating SDK summary completed, took 5.4s [INFO] Heartbeat:7.2s elapsed, 1/3 actions completed. [FINE] json_serializable:json_serializable on lib/generatedql/auth/graphql_api.dart:Running JsonSerializableGenerator - 1 of 2 [FINE] json_serializable:json_serializable on lib/generatedql/auth/graphql_api.dart:Running JsonLiteralGenerator - 2 of 2 [FINE] json_serializable:json_serializable on lib/generatedql/auth/graphql_api.graphql.dart:Running JsonSerializableGenerator - 1 of 2 [FINE] json_serializable:json_serializable on lib/generatedql/auth/graphql_api.graphql.dart:Running JsonLiteralGenerator - 2 of 2 [INFO] Build:Running build completed, took 9.1s [INFO] Build:Caching finalized dependency graph... [INFO] Build:Caching finalized dependency graph completed, took 114ms [INFO] Build:Succeeded after 9.2s with 4 outputs (6 actions) [+58955 ms] "flutter run" took 59,192ms. [ +262 ms] ensureAnalyticsSent: 255ms [ +1 ms] Running shutdown hooks [ ] Shutdown hooks complete [ ] exiting with code 0 ```
GraphQL schema: ```graphql type Mutation { login(input: LoginInput!): AuthPayload! register(input: RegisterInput!): User! } input LoginInput { email: String! password: String! device_token: String! } type AuthPayload { token_type: String expires_in: Int access_token: String refresh_token: String } ```
GraphQL query: ```graphql mutation SignIn($email: String!, $password: String!,$deviceToken:String!){ login(input: {email: $email, password: $password, device_token:$deviceToken }){ access_token refresh_token expires_in token_type } } ```
vasilich6107 commented 3 years ago

First of all - update to the latest beta) There are a lot of bug fixes)

vasilich6107 commented 3 years ago

Could you clarify the use case? Why do you need the custom class name?

BeshoyMelika commented 3 years ago

I am very sorry for the late reply I want to change the names because sometimes it is too long Is there a way to custom the name of class

vasilich6107 commented 3 years ago

You can present the selection set with Fragment and you'll get a class with name [FragmentName]Mixin it will be much shorter.

BeshoyMelika commented 3 years ago

okay, I think this helps me a little, but now no way to custom class name, right?

vasilich6107 commented 3 years ago

Currently there is no way to customize class name. The “fragmentation” is the only way. As far as it ads only “Mixin” postfix overhead it works pretty good. Actually we didn’t wanted to make such lo$oo$ng names. But in complex query sets the chance of name duplication with different selection set is pretty high.

vasilich6107 commented 3 years ago

You can also try a simple naming schema... May be it will fit your needs even better.

msal4 commented 3 years ago

Hey @vasilich6107, I want to change the name of the class so I can set it as a type that my widget accepts but it's too long, not very readable, and too specific. I wanted to handle it myself by creating another general class that includes only the fields that I care about but dart apparently doesn't work the same as typescript :/ here is the generated class:

// ...
@JsonSerializable(explicitToJson: true)
class Home$Query$LatestProducts$Product with EquatableMixin {
  Home$Query$LatestProducts$Product();

  factory Home$Query$LatestProducts$Product.fromJson(
          Map<String, dynamic> json) =>
      _$Home$Query$LatestProducts$ProductFromJson(json);

  String id;

  String name;

  double price;

  String image;

  Home$Query$LatestProducts$Product$Author author;

  List<Home$Query$LatestProducts$Product$Category> categories;

  @override
  List<Object> get props => [id, name, price, image, author, categories];
  Map<String, dynamic> toJson() =>
      _$Home$Query$LatestProducts$ProductToJson(this);
}
// ...

and there are many duplicates of this exact class in the generated code:

// ...
@JsonSerializable(explicitToJson: true)
class Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$Product
    with EquatableMixin {
  Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$Product();

  factory Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$Product.fromJson(
          Map<String, dynamic> json) =>
      _$Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$ProductFromJson(
          json);

  String id;

  String name;

  double price;

  String image;

  Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$Product$Author
      author;

  List<Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$Product$Category>
      categories;

  @override
  List<Object> get props => [id, name, price, image, author, categories];
  Map<String, dynamic> toJson() =>
      _$Home$Query$PaginatedCategoryResponse$Category$PaginatedProductResponse$ProductToJson(
          this);
}
// ...

And all I want is to accept a simple list of products in my widget like so:

// ...
class ProductsRow extends StatelessWidget {
  const ProductsRow({Key key, @required this.title, @required this.items})
      : assert(title != null && items != null),
        super(key: key);

  final String title;
  final List<Product> items;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Text(title),
        ListView.builder(
          itemCount: items.length,
          itemBuilder: (context, index) {
            return Text(items[index].name);
          },
        ),
      ],
    );
  }
}

So I created this general-purpose abstract class with just the fields that I care about

abstract class Product {
  String id;
  String name;
}

but the issue is that this doesn't work as I get a type mismatch even though they're the same fields that are contained in the previous classes and i think its just how the language works but it would be great to change the generated class name or even extend some other class or something.

vasilich6107 commented 3 years ago

@msal4 split your query into fragments. Every fragment will get its own mixin FragmentNameMixin and you'll be able to use it in your class as type

formvoltron commented 3 years ago

@msal4 you must have solved this already, but you could also create a Product wrapper which forwards get / set calls to the generated classes.

But honestly that & the Fragment ideas seem unnatural. I like the idea of custom class types. That the artemis framework knows how to map into / out of.

OdysseyJ commented 3 years ago

@formvoltron i agree with your opinion. can i get some example for wrapping generated classes? thanks

msal4 commented 3 years ago

@formvoltron I split my query into fragments as @vasilich6107 suggested they worked pretty well but I'm curious about your idea it would be nice if you shared a code snippet or a link to get an idea of how it would be implemented

OdysseyJ commented 3 years ago

class Post extends GetPosts$Query$PostWithPagination$Post {}

this is the way i did. seems work?

formvoltron commented 3 years ago

I was thinking about using encapsulation. so:

class Post {
   GetPosts$Query$PostWithPagination$Post _genPost;

   String get post =>_getPost.post;
}

Like that... but that gets pretty boring writing those & so maybe this class could even be generated.

I'm going to skip all of this & just use json_serializable on my model classes & write some code to generate them based on responses from the server code.

vasilich6107 commented 3 years ago

@formvoltron @OdysseyJ @BeshoyMelika Dart 2.13 released support of type aliases. This possibly could help you in solving your issue