refactor: add prefix for graphql types

This commit is contained in:
Rongjian Zhang 2019-12-07 15:28:43 +08:00
parent 991d563b29
commit 88984e7164
7 changed files with 423 additions and 356 deletions

View File

@ -25,9 +25,10 @@ targets:
options: options:
schema_mapping: schema_mapping:
- schema: lib/github.schema.json - schema: lib/github.schema.json
output: lib/graphql/gh_user.dart output: lib/graphql/github_user.dart
queries_glob: lib/graphql/user.graphql queries_glob: lib/graphql/github_user.graphql
resolve_type_field: __typename resolve_type_field: __typename
add_query_prefix: true
scalar_mapping: scalar_mapping:
- graphql_type: URI - graphql_type: URI
dart_type: String dart_type: String

View File

@ -4,34 +4,35 @@ import 'package:artemis/artemis.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:gql/ast.dart'; import 'package:gql/ast.dart';
part 'gh_user.g.dart'; part 'github_user.g.dart';
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class GhUser with EquatableMixin { class GithubUser with EquatableMixin {
GhUser(); GithubUser();
factory GhUser.fromJson(Map<String, dynamic> json) => _$GhUserFromJson(json); factory GithubUser.fromJson(Map<String, dynamic> json) =>
_$GithubUserFromJson(json);
RepositoryOwner repositoryOwner; GithubUserRepositoryOwner repositoryOwner;
@override @override
List<Object> get props => [repositoryOwner]; List<Object> get props => [repositoryOwner];
Map<String, dynamic> toJson() => _$GhUserToJson(this); Map<String, dynamic> toJson() => _$GithubUserToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class RepositoryOwner with EquatableMixin { class GithubUserRepositoryOwner with EquatableMixin {
RepositoryOwner(); GithubUserRepositoryOwner();
factory RepositoryOwner.fromJson(Map<String, dynamic> json) { factory GithubUserRepositoryOwner.fromJson(Map<String, dynamic> json) {
switch (json['__typename'].toString()) { switch (json['__typename'].toString()) {
case 'User': case 'User':
return User.fromJson(json); return GithubUserUser.fromJson(json);
case 'Organization': case 'Organization':
return Organization.fromJson(json); return GithubUserOrganization.fromJson(json);
default: default:
} }
return _$RepositoryOwnerFromJson(json); return _$GithubUserRepositoryOwnerFromJson(json);
} }
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
@ -42,31 +43,32 @@ class RepositoryOwner with EquatableMixin {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
switch (resolveType) { switch (resolveType) {
case 'User': case 'User':
return (this as User).toJson(); return (this as GithubUserUser).toJson();
case 'Organization': case 'Organization':
return (this as Organization).toJson(); return (this as GithubUserOrganization).toJson();
default: default:
} }
return _$RepositoryOwnerToJson(this); return _$GithubUserRepositoryOwnerToJson(this);
} }
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class User extends AuditEntryActor class GithubUserUser extends GithubUserAuditEntryActor
with EquatableMixin with EquatableMixin
implements implements
Node, GithubUserNode,
Actor, GithubUserActor,
RegistryPackageOwner, GithubUserRegistryPackageOwner,
RegistryPackageSearch, GithubUserRegistryPackageSearch,
ProjectOwner, GithubUserProjectOwner,
RepositoryOwner, GithubUserRepositoryOwner,
UniformResourceLocatable, GithubUserUniformResourceLocatable,
ProfileOwner, GithubUserProfileOwner,
Sponsorable { GithubUserSponsorable {
User(); GithubUserUser();
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json); factory GithubUserUser.fromJson(Map<String, dynamic> json) =>
_$GithubUserUserFromJson(json);
String login; String login;
@ -84,15 +86,15 @@ class User extends AuditEntryActor
String websiteUrl; String websiteUrl;
StarredRepositoryConnection starredRepositories; GithubUserStarredRepositoryConnection starredRepositories;
FollowerConnection followers; GithubUserFollowerConnection followers;
FollowingConnection following; GithubUserFollowingConnection following;
RepositoryConnection repositories; GithubUserRepositoryConnection repositories;
PinnableItemConnection pinnedItems; GithubUserPinnableItemConnection pinnedItems;
bool viewerCanFollow; bool viewerCanFollow;
@ -124,86 +126,88 @@ class User extends AuditEntryActor
url, url,
resolveType resolveType
]; ];
Map<String, dynamic> toJson() => _$UserToJson(this); Map<String, dynamic> toJson() => _$GithubUserUserToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class StarredRepositoryConnection with EquatableMixin { class GithubUserStarredRepositoryConnection with EquatableMixin {
StarredRepositoryConnection(); GithubUserStarredRepositoryConnection();
factory StarredRepositoryConnection.fromJson(Map<String, dynamic> json) => factory GithubUserStarredRepositoryConnection.fromJson(
_$StarredRepositoryConnectionFromJson(json); Map<String, dynamic> json) =>
_$GithubUserStarredRepositoryConnectionFromJson(json);
int totalCount; int totalCount;
@override @override
List<Object> get props => [totalCount]; List<Object> get props => [totalCount];
Map<String, dynamic> toJson() => _$StarredRepositoryConnectionToJson(this); Map<String, dynamic> toJson() =>
_$GithubUserStarredRepositoryConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class FollowerConnection with EquatableMixin { class GithubUserFollowerConnection with EquatableMixin {
FollowerConnection(); GithubUserFollowerConnection();
factory FollowerConnection.fromJson(Map<String, dynamic> json) => factory GithubUserFollowerConnection.fromJson(Map<String, dynamic> json) =>
_$FollowerConnectionFromJson(json); _$GithubUserFollowerConnectionFromJson(json);
int totalCount; int totalCount;
@override @override
List<Object> get props => [totalCount]; List<Object> get props => [totalCount];
Map<String, dynamic> toJson() => _$FollowerConnectionToJson(this); Map<String, dynamic> toJson() => _$GithubUserFollowerConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class FollowingConnection with EquatableMixin { class GithubUserFollowingConnection with EquatableMixin {
FollowingConnection(); GithubUserFollowingConnection();
factory FollowingConnection.fromJson(Map<String, dynamic> json) => factory GithubUserFollowingConnection.fromJson(Map<String, dynamic> json) =>
_$FollowingConnectionFromJson(json); _$GithubUserFollowingConnectionFromJson(json);
int totalCount; int totalCount;
@override @override
List<Object> get props => [totalCount]; List<Object> get props => [totalCount];
Map<String, dynamic> toJson() => _$FollowingConnectionToJson(this); Map<String, dynamic> toJson() => _$GithubUserFollowingConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class RepositoryConnection with EquatableMixin { class GithubUserRepositoryConnection with EquatableMixin {
RepositoryConnection(); GithubUserRepositoryConnection();
factory RepositoryConnection.fromJson(Map<String, dynamic> json) => factory GithubUserRepositoryConnection.fromJson(Map<String, dynamic> json) =>
_$RepositoryConnectionFromJson(json); _$GithubUserRepositoryConnectionFromJson(json);
int totalCount; int totalCount;
List<Repository> nodes; List<GithubUserRepository> nodes;
@override @override
List<Object> get props => [totalCount, nodes]; List<Object> get props => [totalCount, nodes];
Map<String, dynamic> toJson() => _$RepositoryConnectionToJson(this); Map<String, dynamic> toJson() => _$GithubUserRepositoryConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Repository extends PinnableItem class GithubUserRepository extends GithubUserPinnableItem
with EquatableMixin with EquatableMixin
implements implements
Node, GithubUserNode,
ProjectOwner, GithubUserProjectOwner,
RegistryPackageOwner, GithubUserRegistryPackageOwner,
RegistryPackageSearch, GithubUserRegistryPackageSearch,
Subscribable, GithubUserSubscribable,
Starrable, GithubUserStarrable,
UniformResourceLocatable, GithubUserUniformResourceLocatable,
RepositoryInfo { GithubUserRepositoryInfo {
Repository(); GithubUserRepository();
factory Repository.fromJson(Map<String, dynamic> json) => factory GithubUserRepository.fromJson(Map<String, dynamic> json) =>
_$RepositoryFromJson(json); _$GithubUserRepositoryFromJson(json);
@override @override
RepositoryOwner owner; GithubUserRepositoryOwner owner;
@override @override
String name; String name;
@ -218,11 +222,11 @@ class Repository extends PinnableItem
bool isFork; bool isFork;
@override @override
StargazerConnection stargazers; GithubUserStargazerConnection stargazers;
RepositoryConnection forks; GithubUserRepositoryConnection forks;
Language primaryLanguage; GithubUserLanguage primaryLanguage;
@override @override
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
@ -240,29 +244,29 @@ class Repository extends PinnableItem
primaryLanguage, primaryLanguage,
resolveType resolveType
]; ];
Map<String, dynamic> toJson() => _$RepositoryToJson(this); Map<String, dynamic> toJson() => _$GithubUserRepositoryToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class StargazerConnection with EquatableMixin { class GithubUserStargazerConnection with EquatableMixin {
StargazerConnection(); GithubUserStargazerConnection();
factory StargazerConnection.fromJson(Map<String, dynamic> json) => factory GithubUserStargazerConnection.fromJson(Map<String, dynamic> json) =>
_$StargazerConnectionFromJson(json); _$GithubUserStargazerConnectionFromJson(json);
int totalCount; int totalCount;
@override @override
List<Object> get props => [totalCount]; List<Object> get props => [totalCount];
Map<String, dynamic> toJson() => _$StargazerConnectionToJson(this); Map<String, dynamic> toJson() => _$GithubUserStargazerConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Language with EquatableMixin implements Node { class GithubUserLanguage with EquatableMixin implements GithubUserNode {
Language(); GithubUserLanguage();
factory Language.fromJson(Map<String, dynamic> json) => factory GithubUserLanguage.fromJson(Map<String, dynamic> json) =>
_$LanguageFromJson(json); _$GithubUserLanguageFromJson(json);
String color; String color;
@ -274,135 +278,139 @@ class Language with EquatableMixin implements Node {
@override @override
List<Object> get props => [color, name, resolveType]; List<Object> get props => [color, name, resolveType];
Map<String, dynamic> toJson() => _$LanguageToJson(this); Map<String, dynamic> toJson() => _$GithubUserLanguageToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Node with EquatableMixin { class GithubUserNode with EquatableMixin {
Node(); GithubUserNode();
factory Node.fromJson(Map<String, dynamic> json) => _$NodeFromJson(json); factory GithubUserNode.fromJson(Map<String, dynamic> json) =>
_$GithubUserNodeFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$NodeToJson(this); Map<String, dynamic> toJson() => _$GithubUserNodeToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class PinnableItem with EquatableMixin { class GithubUserPinnableItem with EquatableMixin {
PinnableItem(); GithubUserPinnableItem();
factory PinnableItem.fromJson(Map<String, dynamic> json) => factory GithubUserPinnableItem.fromJson(Map<String, dynamic> json) =>
_$PinnableItemFromJson(json); _$GithubUserPinnableItemFromJson(json);
@override @override
List<Object> get props => []; List<Object> get props => [];
Map<String, dynamic> toJson() => _$PinnableItemToJson(this); Map<String, dynamic> toJson() => _$GithubUserPinnableItemToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class ProjectOwner with EquatableMixin { class GithubUserProjectOwner with EquatableMixin {
ProjectOwner(); GithubUserProjectOwner();
factory ProjectOwner.fromJson(Map<String, dynamic> json) => factory GithubUserProjectOwner.fromJson(Map<String, dynamic> json) =>
_$ProjectOwnerFromJson(json); _$GithubUserProjectOwnerFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$ProjectOwnerToJson(this); Map<String, dynamic> toJson() => _$GithubUserProjectOwnerToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class RegistryPackageOwner with EquatableMixin { class GithubUserRegistryPackageOwner with EquatableMixin {
RegistryPackageOwner(); GithubUserRegistryPackageOwner();
factory RegistryPackageOwner.fromJson(Map<String, dynamic> json) => factory GithubUserRegistryPackageOwner.fromJson(Map<String, dynamic> json) =>
_$RegistryPackageOwnerFromJson(json); _$GithubUserRegistryPackageOwnerFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$RegistryPackageOwnerToJson(this); Map<String, dynamic> toJson() => _$GithubUserRegistryPackageOwnerToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class RegistryPackageSearch with EquatableMixin { class GithubUserRegistryPackageSearch with EquatableMixin {
RegistryPackageSearch(); GithubUserRegistryPackageSearch();
factory RegistryPackageSearch.fromJson(Map<String, dynamic> json) => factory GithubUserRegistryPackageSearch.fromJson(Map<String, dynamic> json) =>
_$RegistryPackageSearchFromJson(json); _$GithubUserRegistryPackageSearchFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$RegistryPackageSearchToJson(this); Map<String, dynamic> toJson() =>
_$GithubUserRegistryPackageSearchToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Subscribable with EquatableMixin { class GithubUserSubscribable with EquatableMixin {
Subscribable(); GithubUserSubscribable();
factory Subscribable.fromJson(Map<String, dynamic> json) => factory GithubUserSubscribable.fromJson(Map<String, dynamic> json) =>
_$SubscribableFromJson(json); _$GithubUserSubscribableFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$SubscribableToJson(this); Map<String, dynamic> toJson() => _$GithubUserSubscribableToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Starrable with EquatableMixin { class GithubUserStarrable with EquatableMixin {
Starrable(); GithubUserStarrable();
factory Starrable.fromJson(Map<String, dynamic> json) => factory GithubUserStarrable.fromJson(Map<String, dynamic> json) =>
_$StarrableFromJson(json); _$GithubUserStarrableFromJson(json);
StargazerConnection stargazers; GithubUserStargazerConnection stargazers;
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [stargazers, resolveType]; List<Object> get props => [stargazers, resolveType];
Map<String, dynamic> toJson() => _$StarrableToJson(this); Map<String, dynamic> toJson() => _$GithubUserStarrableToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class UniformResourceLocatable with EquatableMixin { class GithubUserUniformResourceLocatable with EquatableMixin {
UniformResourceLocatable(); GithubUserUniformResourceLocatable();
factory UniformResourceLocatable.fromJson(Map<String, dynamic> json) => factory GithubUserUniformResourceLocatable.fromJson(
_$UniformResourceLocatableFromJson(json); Map<String, dynamic> json) =>
_$GithubUserUniformResourceLocatableFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$UniformResourceLocatableToJson(this); Map<String, dynamic> toJson() =>
_$GithubUserUniformResourceLocatableToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class RepositoryInfo with EquatableMixin { class GithubUserRepositoryInfo with EquatableMixin {
RepositoryInfo(); GithubUserRepositoryInfo();
factory RepositoryInfo.fromJson(Map<String, dynamic> json) => factory GithubUserRepositoryInfo.fromJson(Map<String, dynamic> json) =>
_$RepositoryInfoFromJson(json); _$GithubUserRepositoryInfoFromJson(json);
RepositoryOwner owner; GithubUserRepositoryOwner owner;
String name; String name;
@ -418,42 +426,45 @@ class RepositoryInfo with EquatableMixin {
@override @override
List<Object> get props => List<Object> get props =>
[owner, name, description, isPrivate, isFork, resolveType]; [owner, name, description, isPrivate, isFork, resolveType];
Map<String, dynamic> toJson() => _$RepositoryInfoToJson(this); Map<String, dynamic> toJson() => _$GithubUserRepositoryInfoToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class PinnableItemConnection with EquatableMixin { class GithubUserPinnableItemConnection with EquatableMixin {
PinnableItemConnection(); GithubUserPinnableItemConnection();
factory PinnableItemConnection.fromJson(Map<String, dynamic> json) => factory GithubUserPinnableItemConnection.fromJson(
_$PinnableItemConnectionFromJson(json); Map<String, dynamic> json) =>
_$GithubUserPinnableItemConnectionFromJson(json);
int totalCount; int totalCount;
List<PinnableItem> nodes; List<GithubUserPinnableItem> nodes;
@override @override
List<Object> get props => [totalCount, nodes]; List<Object> get props => [totalCount, nodes];
Map<String, dynamic> toJson() => _$PinnableItemConnectionToJson(this); Map<String, dynamic> toJson() =>
_$GithubUserPinnableItemConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class AuditEntryActor with EquatableMixin { class GithubUserAuditEntryActor with EquatableMixin {
AuditEntryActor(); GithubUserAuditEntryActor();
factory AuditEntryActor.fromJson(Map<String, dynamic> json) => factory GithubUserAuditEntryActor.fromJson(Map<String, dynamic> json) =>
_$AuditEntryActorFromJson(json); _$GithubUserAuditEntryActorFromJson(json);
@override @override
List<Object> get props => []; List<Object> get props => [];
Map<String, dynamic> toJson() => _$AuditEntryActorToJson(this); Map<String, dynamic> toJson() => _$GithubUserAuditEntryActorToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Actor with EquatableMixin { class GithubUserActor with EquatableMixin {
Actor(); GithubUserActor();
factory Actor.fromJson(Map<String, dynamic> json) => _$ActorFromJson(json); factory GithubUserActor.fromJson(Map<String, dynamic> json) =>
_$GithubUserActorFromJson(json);
String login; String login;
@ -466,15 +477,15 @@ class Actor with EquatableMixin {
@override @override
List<Object> get props => [login, avatarUrl, url, resolveType]; List<Object> get props => [login, avatarUrl, url, resolveType];
Map<String, dynamic> toJson() => _$ActorToJson(this); Map<String, dynamic> toJson() => _$GithubUserActorToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class ProfileOwner with EquatableMixin { class GithubUserProfileOwner with EquatableMixin {
ProfileOwner(); GithubUserProfileOwner();
factory ProfileOwner.fromJson(Map<String, dynamic> json) => factory GithubUserProfileOwner.fromJson(Map<String, dynamic> json) =>
_$ProfileOwnerFromJson(json); _$GithubUserProfileOwnerFromJson(json);
String login; String login;
@ -486,7 +497,7 @@ class ProfileOwner with EquatableMixin {
String websiteUrl; String websiteUrl;
PinnableItemConnection pinnedItems; GithubUserPinnableItemConnection pinnedItems;
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@ -494,42 +505,42 @@ class ProfileOwner with EquatableMixin {
@override @override
List<Object> get props => List<Object> get props =>
[login, name, location, email, websiteUrl, pinnedItems, resolveType]; [login, name, location, email, websiteUrl, pinnedItems, resolveType];
Map<String, dynamic> toJson() => _$ProfileOwnerToJson(this); Map<String, dynamic> toJson() => _$GithubUserProfileOwnerToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Sponsorable with EquatableMixin { class GithubUserSponsorable with EquatableMixin {
Sponsorable(); GithubUserSponsorable();
factory Sponsorable.fromJson(Map<String, dynamic> json) => factory GithubUserSponsorable.fromJson(Map<String, dynamic> json) =>
_$SponsorableFromJson(json); _$GithubUserSponsorableFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$SponsorableToJson(this); Map<String, dynamic> toJson() => _$GithubUserSponsorableToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class Organization extends AuditEntryActor class GithubUserOrganization extends GithubUserAuditEntryActor
with EquatableMixin with EquatableMixin
implements implements
Node, GithubUserNode,
Actor, GithubUserActor,
RegistryPackageOwner, GithubUserRegistryPackageOwner,
RegistryPackageSearch, GithubUserRegistryPackageSearch,
ProjectOwner, GithubUserProjectOwner,
RepositoryOwner, GithubUserRepositoryOwner,
UniformResourceLocatable, GithubUserUniformResourceLocatable,
MemberStatusable, GithubUserMemberStatusable,
ProfileOwner, GithubUserProfileOwner,
Sponsorable { GithubUserSponsorable {
Organization(); GithubUserOrganization();
factory Organization.fromJson(Map<String, dynamic> json) => factory GithubUserOrganization.fromJson(Map<String, dynamic> json) =>
_$OrganizationFromJson(json); _$GithubUserOrganizationFromJson(json);
String login; String login;
@ -547,11 +558,11 @@ class Organization extends AuditEntryActor
String url; String url;
PinnableItemConnection pinnedItems; GithubUserPinnableItemConnection pinnedItems;
PinnableItemConnection pinnableItems; GithubUserPinnableItemConnection pinnableItems;
OrganizationMemberConnection membersWithRole; GithubUserOrganizationMemberConnection membersWithRole;
@override @override
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
@ -572,54 +583,56 @@ class Organization extends AuditEntryActor
membersWithRole, membersWithRole,
resolveType resolveType
]; ];
Map<String, dynamic> toJson() => _$OrganizationToJson(this); Map<String, dynamic> toJson() => _$GithubUserOrganizationToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class OrganizationMemberConnection with EquatableMixin { class GithubUserOrganizationMemberConnection with EquatableMixin {
OrganizationMemberConnection(); GithubUserOrganizationMemberConnection();
factory OrganizationMemberConnection.fromJson(Map<String, dynamic> json) => factory GithubUserOrganizationMemberConnection.fromJson(
_$OrganizationMemberConnectionFromJson(json); Map<String, dynamic> json) =>
_$GithubUserOrganizationMemberConnectionFromJson(json);
int totalCount; int totalCount;
@override @override
List<Object> get props => [totalCount]; List<Object> get props => [totalCount];
Map<String, dynamic> toJson() => _$OrganizationMemberConnectionToJson(this); Map<String, dynamic> toJson() =>
_$GithubUserOrganizationMemberConnectionToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class MemberStatusable with EquatableMixin { class GithubUserMemberStatusable with EquatableMixin {
MemberStatusable(); GithubUserMemberStatusable();
factory MemberStatusable.fromJson(Map<String, dynamic> json) => factory GithubUserMemberStatusable.fromJson(Map<String, dynamic> json) =>
_$MemberStatusableFromJson(json); _$GithubUserMemberStatusableFromJson(json);
@JsonKey(name: '__typename') @JsonKey(name: '__typename')
String resolveType; String resolveType;
@override @override
List<Object> get props => [resolveType]; List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$MemberStatusableToJson(this); Map<String, dynamic> toJson() => _$GithubUserMemberStatusableToJson(this);
} }
@JsonSerializable(explicitToJson: true) @JsonSerializable(explicitToJson: true)
class GhUserArguments extends JsonSerializable with EquatableMixin { class GithubUserArguments extends JsonSerializable with EquatableMixin {
GhUserArguments({this.login}); GithubUserArguments({this.login});
factory GhUserArguments.fromJson(Map<String, dynamic> json) => factory GithubUserArguments.fromJson(Map<String, dynamic> json) =>
_$GhUserArgumentsFromJson(json); _$GithubUserArgumentsFromJson(json);
final String login; final String login;
@override @override
List<Object> get props => [login]; List<Object> get props => [login];
Map<String, dynamic> toJson() => _$GhUserArgumentsToJson(this); Map<String, dynamic> toJson() => _$GithubUserArgumentsToJson(this);
} }
class GhUserQuery extends GraphQLQuery<GhUser, GhUserArguments> { class GithubUserQuery extends GraphQLQuery<GithubUser, GithubUserArguments> {
GhUserQuery({this.variables}); GithubUserQuery({this.variables});
@override @override
final DocumentNode document = DocumentNode(definitions: [ final DocumentNode document = DocumentNode(definitions: [
@ -1414,13 +1427,13 @@ class GhUserQuery extends GraphQLQuery<GhUser, GhUserArguments> {
]); ]);
@override @override
final String operationName = 'gh_user'; final String operationName = 'github_user';
@override @override
final GhUserArguments variables; final GithubUserArguments variables;
@override @override
List<Object> get props => [document, operationName, variables]; List<Object> get props => [document, operationName, variables];
@override @override
GhUser parse(Map<String, dynamic> json) => GhUser.fromJson(json); GithubUser parse(Map<String, dynamic> json) => GithubUser.fromJson(json);
} }

View File

@ -1,34 +1,38 @@
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
part of 'gh_user.dart'; part of 'github_user.dart';
// ************************************************************************** // **************************************************************************
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
GhUser _$GhUserFromJson(Map<String, dynamic> json) { GithubUser _$GithubUserFromJson(Map<String, dynamic> json) {
return GhUser() return GithubUser()
..repositoryOwner = json['repositoryOwner'] == null ..repositoryOwner = json['repositoryOwner'] == null
? null ? null
: RepositoryOwner.fromJson( : GithubUserRepositoryOwner.fromJson(
json['repositoryOwner'] as Map<String, dynamic>); json['repositoryOwner'] as Map<String, dynamic>);
} }
Map<String, dynamic> _$GhUserToJson(GhUser instance) => <String, dynamic>{ Map<String, dynamic> _$GithubUserToJson(GithubUser instance) =>
<String, dynamic>{
'repositoryOwner': instance.repositoryOwner?.toJson(), 'repositoryOwner': instance.repositoryOwner?.toJson(),
}; };
RepositoryOwner _$RepositoryOwnerFromJson(Map<String, dynamic> json) { GithubUserRepositoryOwner _$GithubUserRepositoryOwnerFromJson(
return RepositoryOwner()..resolveType = json['__typename'] as String; Map<String, dynamic> json) {
return GithubUserRepositoryOwner()
..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$RepositoryOwnerToJson(RepositoryOwner instance) => Map<String, dynamic> _$GithubUserRepositoryOwnerToJson(
GithubUserRepositoryOwner instance) =>
<String, dynamic>{ <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
User _$UserFromJson(Map<String, dynamic> json) { GithubUserUser _$GithubUserUserFromJson(Map<String, dynamic> json) {
return User() return GithubUserUser()
..login = json['login'] as String ..login = json['login'] as String
..name = json['name'] as String ..name = json['name'] as String
..avatarUrl = json['avatarUrl'] as String ..avatarUrl = json['avatarUrl'] as String
@ -39,22 +43,23 @@ User _$UserFromJson(Map<String, dynamic> json) {
..websiteUrl = json['websiteUrl'] as String ..websiteUrl = json['websiteUrl'] as String
..starredRepositories = json['starredRepositories'] == null ..starredRepositories = json['starredRepositories'] == null
? null ? null
: StarredRepositoryConnection.fromJson( : GithubUserStarredRepositoryConnection.fromJson(
json['starredRepositories'] as Map<String, dynamic>) json['starredRepositories'] as Map<String, dynamic>)
..followers = json['followers'] == null ..followers = json['followers'] == null
? null ? null
: FollowerConnection.fromJson(json['followers'] as Map<String, dynamic>) : GithubUserFollowerConnection.fromJson(
json['followers'] as Map<String, dynamic>)
..following = json['following'] == null ..following = json['following'] == null
? null ? null
: FollowingConnection.fromJson( : GithubUserFollowingConnection.fromJson(
json['following'] as Map<String, dynamic>) json['following'] as Map<String, dynamic>)
..repositories = json['repositories'] == null ..repositories = json['repositories'] == null
? null ? null
: RepositoryConnection.fromJson( : GithubUserRepositoryConnection.fromJson(
json['repositories'] as Map<String, dynamic>) json['repositories'] as Map<String, dynamic>)
..pinnedItems = json['pinnedItems'] == null ..pinnedItems = json['pinnedItems'] == null
? null ? null
: PinnableItemConnection.fromJson( : GithubUserPinnableItemConnection.fromJson(
json['pinnedItems'] as Map<String, dynamic>) json['pinnedItems'] as Map<String, dynamic>)
..viewerCanFollow = json['viewerCanFollow'] as bool ..viewerCanFollow = json['viewerCanFollow'] as bool
..viewerIsFollowing = json['viewerIsFollowing'] as bool ..viewerIsFollowing = json['viewerIsFollowing'] as bool
@ -62,7 +67,8 @@ User _$UserFromJson(Map<String, dynamic> json) {
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{ Map<String, dynamic> _$GithubUserUserToJson(GithubUserUser instance) =>
<String, dynamic>{
'login': instance.login, 'login': instance.login,
'name': instance.name, 'name': instance.name,
'avatarUrl': instance.avatarUrl, 'avatarUrl': instance.avatarUrl,
@ -82,75 +88,86 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
StarredRepositoryConnection _$StarredRepositoryConnectionFromJson( GithubUserStarredRepositoryConnection
_$GithubUserStarredRepositoryConnectionFromJson(Map<String, dynamic> json) {
return GithubUserStarredRepositoryConnection()
..totalCount = json['totalCount'] as int;
}
Map<String, dynamic> _$GithubUserStarredRepositoryConnectionToJson(
GithubUserStarredRepositoryConnection instance) =>
<String, dynamic>{
'totalCount': instance.totalCount,
};
GithubUserFollowerConnection _$GithubUserFollowerConnectionFromJson(
Map<String, dynamic> json) { Map<String, dynamic> json) {
return StarredRepositoryConnection()..totalCount = json['totalCount'] as int; return GithubUserFollowerConnection()..totalCount = json['totalCount'] as int;
} }
Map<String, dynamic> _$StarredRepositoryConnectionToJson( Map<String, dynamic> _$GithubUserFollowerConnectionToJson(
StarredRepositoryConnection instance) => GithubUserFollowerConnection instance) =>
<String, dynamic>{ <String, dynamic>{
'totalCount': instance.totalCount, 'totalCount': instance.totalCount,
}; };
FollowerConnection _$FollowerConnectionFromJson(Map<String, dynamic> json) { GithubUserFollowingConnection _$GithubUserFollowingConnectionFromJson(
return FollowerConnection()..totalCount = json['totalCount'] as int; Map<String, dynamic> json) {
return GithubUserFollowingConnection()
..totalCount = json['totalCount'] as int;
} }
Map<String, dynamic> _$FollowerConnectionToJson(FollowerConnection instance) => Map<String, dynamic> _$GithubUserFollowingConnectionToJson(
GithubUserFollowingConnection instance) =>
<String, dynamic>{ <String, dynamic>{
'totalCount': instance.totalCount, 'totalCount': instance.totalCount,
}; };
FollowingConnection _$FollowingConnectionFromJson(Map<String, dynamic> json) { GithubUserRepositoryConnection _$GithubUserRepositoryConnectionFromJson(
return FollowingConnection()..totalCount = json['totalCount'] as int; Map<String, dynamic> json) {
} return GithubUserRepositoryConnection()
Map<String, dynamic> _$FollowingConnectionToJson(
FollowingConnection instance) =>
<String, dynamic>{
'totalCount': instance.totalCount,
};
RepositoryConnection _$RepositoryConnectionFromJson(Map<String, dynamic> json) {
return RepositoryConnection()
..totalCount = json['totalCount'] as int ..totalCount = json['totalCount'] as int
..nodes = (json['nodes'] as List) ..nodes = (json['nodes'] as List)
?.map((e) => ?.map((e) => e == null
e == null ? null : Repository.fromJson(e as Map<String, dynamic>)) ? null
: GithubUserRepository.fromJson(e as Map<String, dynamic>))
?.toList(); ?.toList();
} }
Map<String, dynamic> _$RepositoryConnectionToJson( Map<String, dynamic> _$GithubUserRepositoryConnectionToJson(
RepositoryConnection instance) => GithubUserRepositoryConnection instance) =>
<String, dynamic>{ <String, dynamic>{
'totalCount': instance.totalCount, 'totalCount': instance.totalCount,
'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(), 'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(),
}; };
Repository _$RepositoryFromJson(Map<String, dynamic> json) { GithubUserRepository _$GithubUserRepositoryFromJson(Map<String, dynamic> json) {
return Repository() return GithubUserRepository()
..owner = json['owner'] == null ..owner = json['owner'] == null
? null ? null
: RepositoryOwner.fromJson(json['owner'] as Map<String, dynamic>) : GithubUserRepositoryOwner.fromJson(
json['owner'] as Map<String, dynamic>)
..name = json['name'] as String ..name = json['name'] as String
..description = json['description'] as String ..description = json['description'] as String
..isPrivate = json['isPrivate'] as bool ..isPrivate = json['isPrivate'] as bool
..isFork = json['isFork'] as bool ..isFork = json['isFork'] as bool
..stargazers = json['stargazers'] == null ..stargazers = json['stargazers'] == null
? null ? null
: StargazerConnection.fromJson( : GithubUserStargazerConnection.fromJson(
json['stargazers'] as Map<String, dynamic>) json['stargazers'] as Map<String, dynamic>)
..forks = json['forks'] == null ..forks = json['forks'] == null
? null ? null
: RepositoryConnection.fromJson(json['forks'] as Map<String, dynamic>) : GithubUserRepositoryConnection.fromJson(
json['forks'] as Map<String, dynamic>)
..primaryLanguage = json['primaryLanguage'] == null ..primaryLanguage = json['primaryLanguage'] == null
? null ? null
: Language.fromJson(json['primaryLanguage'] as Map<String, dynamic>) : GithubUserLanguage.fromJson(
json['primaryLanguage'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$RepositoryToJson(Repository instance) => Map<String, dynamic> _$GithubUserRepositoryToJson(
GithubUserRepository instance) =>
<String, dynamic>{ <String, dynamic>{
'owner': instance.owner?.toJson(), 'owner': instance.owner?.toJson(),
'name': instance.name, 'name': instance.name,
@ -163,113 +180,131 @@ Map<String, dynamic> _$RepositoryToJson(Repository instance) =>
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
StargazerConnection _$StargazerConnectionFromJson(Map<String, dynamic> json) { GithubUserStargazerConnection _$GithubUserStargazerConnectionFromJson(
return StargazerConnection()..totalCount = json['totalCount'] as int; Map<String, dynamic> json) {
return GithubUserStargazerConnection()
..totalCount = json['totalCount'] as int;
} }
Map<String, dynamic> _$StargazerConnectionToJson( Map<String, dynamic> _$GithubUserStargazerConnectionToJson(
StargazerConnection instance) => GithubUserStargazerConnection instance) =>
<String, dynamic>{ <String, dynamic>{
'totalCount': instance.totalCount, 'totalCount': instance.totalCount,
}; };
Language _$LanguageFromJson(Map<String, dynamic> json) { GithubUserLanguage _$GithubUserLanguageFromJson(Map<String, dynamic> json) {
return Language() return GithubUserLanguage()
..color = json['color'] as String ..color = json['color'] as String
..name = json['name'] as String ..name = json['name'] as String
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$LanguageToJson(Language instance) => <String, dynamic>{ Map<String, dynamic> _$GithubUserLanguageToJson(GithubUserLanguage instance) =>
<String, dynamic>{
'color': instance.color, 'color': instance.color,
'name': instance.name, 'name': instance.name,
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
Node _$NodeFromJson(Map<String, dynamic> json) { GithubUserNode _$GithubUserNodeFromJson(Map<String, dynamic> json) {
return Node()..resolveType = json['__typename'] as String; return GithubUserNode()..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$NodeToJson(Node instance) => <String, dynamic>{ Map<String, dynamic> _$GithubUserNodeToJson(GithubUserNode instance) =>
<String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
PinnableItem _$PinnableItemFromJson(Map<String, dynamic> json) { GithubUserPinnableItem _$GithubUserPinnableItemFromJson(
return PinnableItem(); Map<String, dynamic> json) {
return GithubUserPinnableItem();
} }
Map<String, dynamic> _$PinnableItemToJson(PinnableItem instance) => Map<String, dynamic> _$GithubUserPinnableItemToJson(
GithubUserPinnableItem instance) =>
<String, dynamic>{}; <String, dynamic>{};
ProjectOwner _$ProjectOwnerFromJson(Map<String, dynamic> json) { GithubUserProjectOwner _$GithubUserProjectOwnerFromJson(
return ProjectOwner()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$ProjectOwnerToJson(ProjectOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
RegistryPackageOwner _$RegistryPackageOwnerFromJson(Map<String, dynamic> json) {
return RegistryPackageOwner()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$RegistryPackageOwnerToJson(
RegistryPackageOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
RegistryPackageSearch _$RegistryPackageSearchFromJson(
Map<String, dynamic> json) { Map<String, dynamic> json) {
return RegistryPackageSearch()..resolveType = json['__typename'] as String; return GithubUserProjectOwner()..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$RegistryPackageSearchToJson( Map<String, dynamic> _$GithubUserProjectOwnerToJson(
RegistryPackageSearch instance) => GithubUserProjectOwner instance) =>
<String, dynamic>{ <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
Subscribable _$SubscribableFromJson(Map<String, dynamic> json) { GithubUserRegistryPackageOwner _$GithubUserRegistryPackageOwnerFromJson(
return Subscribable()..resolveType = json['__typename'] as String; Map<String, dynamic> json) {
return GithubUserRegistryPackageOwner()
..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$SubscribableToJson(Subscribable instance) => Map<String, dynamic> _$GithubUserRegistryPackageOwnerToJson(
GithubUserRegistryPackageOwner instance) =>
<String, dynamic>{ <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
Starrable _$StarrableFromJson(Map<String, dynamic> json) { GithubUserRegistryPackageSearch _$GithubUserRegistryPackageSearchFromJson(
return Starrable() Map<String, dynamic> json) {
return GithubUserRegistryPackageSearch()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubUserRegistryPackageSearchToJson(
GithubUserRegistryPackageSearch instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubUserSubscribable _$GithubUserSubscribableFromJson(
Map<String, dynamic> json) {
return GithubUserSubscribable()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubUserSubscribableToJson(
GithubUserSubscribable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubUserStarrable _$GithubUserStarrableFromJson(Map<String, dynamic> json) {
return GithubUserStarrable()
..stargazers = json['stargazers'] == null ..stargazers = json['stargazers'] == null
? null ? null
: StargazerConnection.fromJson( : GithubUserStargazerConnection.fromJson(
json['stargazers'] as Map<String, dynamic>) json['stargazers'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$StarrableToJson(Starrable instance) => <String, dynamic>{ Map<String, dynamic> _$GithubUserStarrableToJson(
GithubUserStarrable instance) =>
<String, dynamic>{
'stargazers': instance.stargazers?.toJson(), 'stargazers': instance.stargazers?.toJson(),
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
UniformResourceLocatable _$UniformResourceLocatableFromJson( GithubUserUniformResourceLocatable _$GithubUserUniformResourceLocatableFromJson(
Map<String, dynamic> json) { Map<String, dynamic> json) {
return UniformResourceLocatable()..resolveType = json['__typename'] as String; return GithubUserUniformResourceLocatable()
..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$UniformResourceLocatableToJson( Map<String, dynamic> _$GithubUserUniformResourceLocatableToJson(
UniformResourceLocatable instance) => GithubUserUniformResourceLocatable instance) =>
<String, dynamic>{ <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
RepositoryInfo _$RepositoryInfoFromJson(Map<String, dynamic> json) { GithubUserRepositoryInfo _$GithubUserRepositoryInfoFromJson(
return RepositoryInfo() Map<String, dynamic> json) {
return GithubUserRepositoryInfo()
..owner = json['owner'] == null ..owner = json['owner'] == null
? null ? null
: RepositoryOwner.fromJson(json['owner'] as Map<String, dynamic>) : GithubUserRepositoryOwner.fromJson(
json['owner'] as Map<String, dynamic>)
..name = json['name'] as String ..name = json['name'] as String
..description = json['description'] as String ..description = json['description'] as String
..isPrivate = json['isPrivate'] as bool ..isPrivate = json['isPrivate'] as bool
@ -277,7 +312,8 @@ RepositoryInfo _$RepositoryInfoFromJson(Map<String, dynamic> json) {
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$RepositoryInfoToJson(RepositoryInfo instance) => Map<String, dynamic> _$GithubUserRepositoryInfoToJson(
GithubUserRepositoryInfo instance) =>
<String, dynamic>{ <String, dynamic>{
'owner': instance.owner?.toJson(), 'owner': instance.owner?.toJson(),
'name': instance.name, 'name': instance.name,
@ -287,47 +323,52 @@ Map<String, dynamic> _$RepositoryInfoToJson(RepositoryInfo instance) =>
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
PinnableItemConnection _$PinnableItemConnectionFromJson( GithubUserPinnableItemConnection _$GithubUserPinnableItemConnectionFromJson(
Map<String, dynamic> json) { Map<String, dynamic> json) {
return PinnableItemConnection() return GithubUserPinnableItemConnection()
..totalCount = json['totalCount'] as int ..totalCount = json['totalCount'] as int
..nodes = (json['nodes'] as List) ..nodes = (json['nodes'] as List)
?.map((e) => ?.map((e) => e == null
e == null ? null : PinnableItem.fromJson(e as Map<String, dynamic>)) ? null
: GithubUserPinnableItem.fromJson(e as Map<String, dynamic>))
?.toList(); ?.toList();
} }
Map<String, dynamic> _$PinnableItemConnectionToJson( Map<String, dynamic> _$GithubUserPinnableItemConnectionToJson(
PinnableItemConnection instance) => GithubUserPinnableItemConnection instance) =>
<String, dynamic>{ <String, dynamic>{
'totalCount': instance.totalCount, 'totalCount': instance.totalCount,
'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(), 'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(),
}; };
AuditEntryActor _$AuditEntryActorFromJson(Map<String, dynamic> json) { GithubUserAuditEntryActor _$GithubUserAuditEntryActorFromJson(
return AuditEntryActor(); Map<String, dynamic> json) {
return GithubUserAuditEntryActor();
} }
Map<String, dynamic> _$AuditEntryActorToJson(AuditEntryActor instance) => Map<String, dynamic> _$GithubUserAuditEntryActorToJson(
GithubUserAuditEntryActor instance) =>
<String, dynamic>{}; <String, dynamic>{};
Actor _$ActorFromJson(Map<String, dynamic> json) { GithubUserActor _$GithubUserActorFromJson(Map<String, dynamic> json) {
return Actor() return GithubUserActor()
..login = json['login'] as String ..login = json['login'] as String
..avatarUrl = json['avatarUrl'] as String ..avatarUrl = json['avatarUrl'] as String
..url = json['url'] as String ..url = json['url'] as String
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$ActorToJson(Actor instance) => <String, dynamic>{ Map<String, dynamic> _$GithubUserActorToJson(GithubUserActor instance) =>
<String, dynamic>{
'login': instance.login, 'login': instance.login,
'avatarUrl': instance.avatarUrl, 'avatarUrl': instance.avatarUrl,
'url': instance.url, 'url': instance.url,
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
ProfileOwner _$ProfileOwnerFromJson(Map<String, dynamic> json) { GithubUserProfileOwner _$GithubUserProfileOwnerFromJson(
return ProfileOwner() Map<String, dynamic> json) {
return GithubUserProfileOwner()
..login = json['login'] as String ..login = json['login'] as String
..name = json['name'] as String ..name = json['name'] as String
..location = json['location'] as String ..location = json['location'] as String
@ -335,12 +376,13 @@ ProfileOwner _$ProfileOwnerFromJson(Map<String, dynamic> json) {
..websiteUrl = json['websiteUrl'] as String ..websiteUrl = json['websiteUrl'] as String
..pinnedItems = json['pinnedItems'] == null ..pinnedItems = json['pinnedItems'] == null
? null ? null
: PinnableItemConnection.fromJson( : GithubUserPinnableItemConnection.fromJson(
json['pinnedItems'] as Map<String, dynamic>) json['pinnedItems'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$ProfileOwnerToJson(ProfileOwner instance) => Map<String, dynamic> _$GithubUserProfileOwnerToJson(
GithubUserProfileOwner instance) =>
<String, dynamic>{ <String, dynamic>{
'login': instance.login, 'login': instance.login,
'name': instance.name, 'name': instance.name,
@ -351,17 +393,20 @@ Map<String, dynamic> _$ProfileOwnerToJson(ProfileOwner instance) =>
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
Sponsorable _$SponsorableFromJson(Map<String, dynamic> json) { GithubUserSponsorable _$GithubUserSponsorableFromJson(
return Sponsorable()..resolveType = json['__typename'] as String; Map<String, dynamic> json) {
return GithubUserSponsorable()..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$SponsorableToJson(Sponsorable instance) => Map<String, dynamic> _$GithubUserSponsorableToJson(
GithubUserSponsorable instance) =>
<String, dynamic>{ <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
Organization _$OrganizationFromJson(Map<String, dynamic> json) { GithubUserOrganization _$GithubUserOrganizationFromJson(
return Organization() Map<String, dynamic> json) {
return GithubUserOrganization()
..login = json['login'] as String ..login = json['login'] as String
..name = json['name'] as String ..name = json['name'] as String
..avatarUrl = json['avatarUrl'] as String ..avatarUrl = json['avatarUrl'] as String
@ -372,20 +417,21 @@ Organization _$OrganizationFromJson(Map<String, dynamic> json) {
..url = json['url'] as String ..url = json['url'] as String
..pinnedItems = json['pinnedItems'] == null ..pinnedItems = json['pinnedItems'] == null
? null ? null
: PinnableItemConnection.fromJson( : GithubUserPinnableItemConnection.fromJson(
json['pinnedItems'] as Map<String, dynamic>) json['pinnedItems'] as Map<String, dynamic>)
..pinnableItems = json['pinnableItems'] == null ..pinnableItems = json['pinnableItems'] == null
? null ? null
: PinnableItemConnection.fromJson( : GithubUserPinnableItemConnection.fromJson(
json['pinnableItems'] as Map<String, dynamic>) json['pinnableItems'] as Map<String, dynamic>)
..membersWithRole = json['membersWithRole'] == null ..membersWithRole = json['membersWithRole'] == null
? null ? null
: OrganizationMemberConnection.fromJson( : GithubUserOrganizationMemberConnection.fromJson(
json['membersWithRole'] as Map<String, dynamic>) json['membersWithRole'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String; ..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$OrganizationToJson(Organization instance) => Map<String, dynamic> _$GithubUserOrganizationToJson(
GithubUserOrganization instance) =>
<String, dynamic>{ <String, dynamic>{
'login': instance.login, 'login': instance.login,
'name': instance.name, 'name': instance.name,
@ -401,33 +447,39 @@ Map<String, dynamic> _$OrganizationToJson(Organization instance) =>
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
OrganizationMemberConnection _$OrganizationMemberConnectionFromJson( GithubUserOrganizationMemberConnection
_$GithubUserOrganizationMemberConnectionFromJson(
Map<String, dynamic> json) { Map<String, dynamic> json) {
return OrganizationMemberConnection()..totalCount = json['totalCount'] as int; return GithubUserOrganizationMemberConnection()
..totalCount = json['totalCount'] as int;
} }
Map<String, dynamic> _$OrganizationMemberConnectionToJson( Map<String, dynamic> _$GithubUserOrganizationMemberConnectionToJson(
OrganizationMemberConnection instance) => GithubUserOrganizationMemberConnection instance) =>
<String, dynamic>{ <String, dynamic>{
'totalCount': instance.totalCount, 'totalCount': instance.totalCount,
}; };
MemberStatusable _$MemberStatusableFromJson(Map<String, dynamic> json) { GithubUserMemberStatusable _$GithubUserMemberStatusableFromJson(
return MemberStatusable()..resolveType = json['__typename'] as String; Map<String, dynamic> json) {
return GithubUserMemberStatusable()
..resolveType = json['__typename'] as String;
} }
Map<String, dynamic> _$MemberStatusableToJson(MemberStatusable instance) => Map<String, dynamic> _$GithubUserMemberStatusableToJson(
GithubUserMemberStatusable instance) =>
<String, dynamic>{ <String, dynamic>{
'__typename': instance.resolveType, '__typename': instance.resolveType,
}; };
GhUserArguments _$GhUserArgumentsFromJson(Map<String, dynamic> json) { GithubUserArguments _$GithubUserArgumentsFromJson(Map<String, dynamic> json) {
return GhUserArguments( return GithubUserArguments(
login: json['login'] as String, login: json['login'] as String,
); );
} }
Map<String, dynamic> _$GhUserArgumentsToJson(GhUserArguments instance) => Map<String, dynamic> _$GithubUserArgumentsToJson(
GithubUserArguments instance) =>
<String, dynamic>{ <String, dynamic>{
'login': instance.login, 'login': instance.login,
}; };

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:git_touch/graphql/gh_user.dart'; import 'package:git_touch/graphql/github_user.dart';
import 'package:git_touch/models/theme.dart'; import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart'; import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/screens/settings.dart'; import 'package:git_touch/screens/settings.dart';
@ -26,10 +26,10 @@ class UserScreen extends StatelessWidget {
UserScreen(this.login); UserScreen(this.login);
Future<RepositoryOwner> _query(BuildContext context) async { Future<GithubUserRepositoryOwner> _query(BuildContext context) async {
final data = await Provider.of<AuthModel>(context) final data = await Provider.of<AuthModel>(context)
.gqlClient .gqlClient
.execute(GhUserQuery(variables: GhUserArguments(login: login))); .execute(GithubUserQuery(variables: GithubUserArguments(login: login)));
return data.data.repositoryOwner; return data.data.repositoryOwner;
} }
@ -48,10 +48,10 @@ class UserScreen extends StatelessWidget {
} }
} }
Iterable<Widget> _buildPinnedItems( Iterable<Widget> _buildPinnedItems(Iterable<GithubUserRepository> pinnedItems,
Iterable<Repository> pinnedItems, Iterable<Repository> repositories) { Iterable<GithubUserRepository> repositories) {
String title; String title;
Iterable<Repository> items = []; Iterable<GithubUserRepository> items = [];
if (pinnedItems.isNotEmpty) { if (pinnedItems.isNotEmpty) {
title = 'pinned repositories'; title = 'pinned repositories';
@ -74,8 +74,8 @@ class UserScreen extends StatelessWidget {
]; ];
} }
Widget _buildUser( Widget _buildUser(BuildContext context, GithubUserUser user,
BuildContext context, User user, List<ContributionsInfo> contributions) { List<ContributionsInfo> contributions) {
final theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -158,15 +158,16 @@ class UserScreen extends StatelessWidget {
), ),
..._buildPinnedItems( ..._buildPinnedItems(
user.pinnedItems.nodes user.pinnedItems.nodes
.where((n) => n is Repository) .where((n) => n is GithubUserRepository)
.cast<Repository>(), .cast<GithubUserRepository>(),
user.repositories.nodes), user.repositories.nodes),
CommonStyle.verticalGap, CommonStyle.verticalGap,
], ],
); );
} }
Widget _buildOrganization(BuildContext context, Organization payload) { Widget _buildOrganization(
BuildContext context, GithubUserOrganization payload) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
@ -228,11 +229,11 @@ class UserScreen extends StatelessWidget {
), ),
..._buildPinnedItems( ..._buildPinnedItems(
payload.pinnedItems.nodes payload.pinnedItems.nodes
.where((n) => n is Repository) .where((n) => n is GithubUserRepository)
.cast<Repository>(), .cast<GithubUserRepository>(),
payload.pinnableItems.nodes payload.pinnableItems.nodes
.where((n) => n is Repository) .where((n) => n is GithubUserRepository)
.cast<Repository>(), .cast<GithubUserRepository>(),
), ),
CommonStyle.verticalGap, CommonStyle.verticalGap,
], ],
@ -242,14 +243,14 @@ class UserScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RefreshStatefulScaffold< return RefreshStatefulScaffold<
Tuple2<RepositoryOwner, List<ContributionsInfo>>>( Tuple2<GithubUserRepositoryOwner, List<ContributionsInfo>>>(
fetchData: () async { fetchData: () async {
final vs = await Future.wait([ final vs = await Future.wait([
_query(context), _query(context),
_fetchContributions(context), _fetchContributions(context),
]); ]);
return Tuple2( return Tuple2(vs[0] as GithubUserRepositoryOwner,
vs[0] as RepositoryOwner, vs[1] as List<ContributionsInfo>); vs[1] as List<ContributionsInfo>);
}, },
title: AppBarTitle('User'), // TODO: title: AppBarTitle('User'), // TODO:
actionBuilder: (data, _) { actionBuilder: (data, _) {
@ -262,7 +263,7 @@ class UserScreen extends StatelessWidget {
final payload = data.item1; final payload = data.item1;
switch (payload.resolveType) { switch (payload.resolveType) {
case 'User': case 'User':
final user = payload as User; final user = payload as GithubUserUser;
if (login == null) { if (login == null) {
return ActionEntry( return ActionEntry(
iconData: Icons.settings, iconData: Icons.settings,
@ -300,7 +301,7 @@ class UserScreen extends StatelessWidget {
} }
break; break;
case 'Organization': case 'Organization':
final organization = payload as Organization; final organization = payload as GithubUserOrganization;
return ActionButton( return ActionButton(
title: 'Organization Actions', title: 'Organization Actions',
items: [ items: [
@ -318,9 +319,10 @@ class UserScreen extends StatelessWidget {
final payload = data.item1; final payload = data.item1;
switch (payload.resolveType) { switch (payload.resolveType) {
case 'User': case 'User':
return _buildUser(context, payload as User, data.item2); return _buildUser(context, payload as GithubUserUser, data.item2);
case 'Organization': case 'Organization':
return _buildOrganization(context, payload as Organization); return _buildOrganization(
context, payload as GithubUserOrganization);
default: default:
return null; return null;
} }

View File

@ -5,8 +5,6 @@ import 'package:flutter/gestures.dart';
import 'package:git_touch/models/theme.dart'; import 'package:git_touch/models/theme.dart';
import 'package:git_touch/screens/user.dart'; import 'package:git_touch/screens/user.dart';
import 'package:git_touch/widgets/border_view.dart'; import 'package:git_touch/widgets/border_view.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/table_view.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:primer/primer.dart'; import 'package:primer/primer.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:git_touch/graphql/gh_user.dart'; import 'package:git_touch/graphql/github_user.dart';
import 'package:git_touch/models/gitea.dart'; import 'package:git_touch/models/gitea.dart';
import 'package:git_touch/models/gitlab.dart'; import 'package:git_touch/models/gitlab.dart';
import 'package:git_touch/models/theme.dart'; import 'package:git_touch/models/theme.dart';
@ -82,9 +82,10 @@ class RepositoryItem extends StatelessWidget {
? [] ? []
: payload['repositoryTopics']['nodes']; : payload['repositoryTopics']['nodes'];
RepositoryItem.github(Repository payload, {this.inRepoScreen = false}) RepositoryItem.github(GithubUserRepository payload,
: this.owner = (payload.owner as User).login, {this.inRepoScreen = false})
this.avatarUrl = (payload.owner as User).avatarUrl, : this.owner = (payload.owner as GithubUserUser).login,
this.avatarUrl = (payload.owner as GithubUserUser).avatarUrl,
this.name = payload.name, this.name = payload.name,
this.description = payload.description, this.description = payload.description,
this.iconData = Octicons.repo, // TODO: this.iconData = Octicons.repo, // TODO:
@ -92,8 +93,8 @@ class RepositoryItem extends StatelessWidget {
this.forkCount = payload.forks.totalCount, this.forkCount = payload.forks.totalCount,
this.primaryLanguageName = payload.primaryLanguage?.name, this.primaryLanguageName = payload.primaryLanguage?.name,
this.primaryLanguageColor = payload.primaryLanguage?.color, this.primaryLanguageColor = payload.primaryLanguage?.color,
this.screenBuilder = ((_) => this.screenBuilder = ((_) => RepositoryScreen(
RepositoryScreen((payload.owner as User).login, payload.name)), (payload.owner as GithubUserUser).login, payload.name)),
this.topics = []; // TODO: this.topics = []; // TODO:
// this.topics = payload['repositoryTopics'] == null // this.topics = payload['repositoryTopics'] == null
// ? [] // ? []