1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-18 19:22:54 +01:00

refactor: use graphql mutation instead of restful api

This commit is contained in:
Rongjian Zhang 2020-01-07 15:32:48 +08:00
parent c5a4721c5d
commit d9fad06570
9 changed files with 1325 additions and 20 deletions

View File

@ -3481,6 +3481,8 @@ class GhUserRepositoryOwner with EquatableMixin {
return _$GhUserRepositoryOwnerFromJson(json);
}
String id;
String login;
String avatarUrl;
@ -3491,7 +3493,7 @@ class GhUserRepositoryOwner with EquatableMixin {
String resolveType;
@override
List<Object> get props => [login, avatarUrl, url, resolveType];
List<Object> get props => [id, login, avatarUrl, url, resolveType];
Map<String, dynamic> toJson() {
switch (resolveType) {
case 'User':
@ -3556,6 +3558,9 @@ class GhUserUser extends GhUserAuditEntryActor
@JsonKey(name: '__typename')
String resolveType;
@override
String id;
@override
String login;
@ -3583,6 +3588,7 @@ class GhUserUser extends GhUserAuditEntryActor
viewerCanFollow,
viewerIsFollowing,
resolveType,
id,
login,
avatarUrl,
url
@ -4068,6 +4074,9 @@ class GhUserOrganization extends GhUserAuditEntryActor
@JsonKey(name: '__typename')
String resolveType;
@override
String id;
@override
String login;
@ -4089,6 +4098,7 @@ class GhUserOrganization extends GhUserAuditEntryActor
pinnableItems,
membersWithRole,
resolveType,
id,
login,
avatarUrl,
url
@ -4189,6 +4199,12 @@ class GhUserQuery extends GraphQLQuery<GhUser, GhUserArguments> {
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'id'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'login'),
alias: null,
@ -6339,3 +6355,815 @@ class GhCommitsQuery extends GraphQLQuery<GhCommits, GhCommitsArguments> {
@override
GhCommits parse(Map<String, dynamic> json) => GhCommits.fromJson(json);
}
@JsonSerializable(explicitToJson: true)
class GhAddStar with EquatableMixin {
GhAddStar();
factory GhAddStar.fromJson(Map<String, dynamic> json) =>
_$GhAddStarFromJson(json);
GhAddStarAddStarPayload addStar;
@override
List<Object> get props => [addStar];
Map<String, dynamic> toJson() => _$GhAddStarToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhAddStarAddStarPayload with EquatableMixin {
GhAddStarAddStarPayload();
factory GhAddStarAddStarPayload.fromJson(Map<String, dynamic> json) =>
_$GhAddStarAddStarPayloadFromJson(json);
GhAddStarStarrable starrable;
@override
List<Object> get props => [starrable];
Map<String, dynamic> toJson() => _$GhAddStarAddStarPayloadToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhAddStarStarrable with EquatableMixin {
GhAddStarStarrable();
factory GhAddStarStarrable.fromJson(Map<String, dynamic> json) =>
_$GhAddStarStarrableFromJson(json);
bool viewerHasStarred;
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [viewerHasStarred, resolveType];
Map<String, dynamic> toJson() => _$GhAddStarStarrableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhAddStarArguments extends JsonSerializable with EquatableMixin {
GhAddStarArguments({this.id});
factory GhAddStarArguments.fromJson(Map<String, dynamic> json) =>
_$GhAddStarArgumentsFromJson(json);
final String id;
@override
List<Object> get props => [id];
Map<String, dynamic> toJson() => _$GhAddStarArgumentsToJson(this);
}
class GhAddStarQuery extends GraphQLQuery<GhAddStar, GhAddStarArguments> {
GhAddStarQuery({this.variables});
@override
final DocumentNode document = DocumentNode(definitions: [
OperationDefinitionNode(
type: OperationType.mutation,
name: NameNode(value: 'GhAddStar'),
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'id')),
type: NamedTypeNode(name: NameNode(value: 'ID'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'addStar'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'input'),
value: ObjectValueNode(fields: [
ObjectFieldNode(
name: NameNode(value: 'starrableId'),
value: VariableNode(name: NameNode(value: 'id')))
]))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'starrable'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'viewerHasStarred'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
]))
]))
]);
@override
final String operationName = 'GhAddStar';
@override
final GhAddStarArguments variables;
@override
List<Object> get props => [document, operationName, variables];
@override
GhAddStar parse(Map<String, dynamic> json) => GhAddStar.fromJson(json);
}
@JsonSerializable(explicitToJson: true)
class GhRemoveStar with EquatableMixin {
GhRemoveStar();
factory GhRemoveStar.fromJson(Map<String, dynamic> json) =>
_$GhRemoveStarFromJson(json);
GhRemoveStarRemoveStarPayload removeStar;
@override
List<Object> get props => [removeStar];
Map<String, dynamic> toJson() => _$GhRemoveStarToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhRemoveStarRemoveStarPayload with EquatableMixin {
GhRemoveStarRemoveStarPayload();
factory GhRemoveStarRemoveStarPayload.fromJson(Map<String, dynamic> json) =>
_$GhRemoveStarRemoveStarPayloadFromJson(json);
GhRemoveStarStarrable starrable;
@override
List<Object> get props => [starrable];
Map<String, dynamic> toJson() => _$GhRemoveStarRemoveStarPayloadToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhRemoveStarStarrable with EquatableMixin {
GhRemoveStarStarrable();
factory GhRemoveStarStarrable.fromJson(Map<String, dynamic> json) =>
_$GhRemoveStarStarrableFromJson(json);
bool viewerHasStarred;
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [viewerHasStarred, resolveType];
Map<String, dynamic> toJson() => _$GhRemoveStarStarrableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhRemoveStarArguments extends JsonSerializable with EquatableMixin {
GhRemoveStarArguments({this.id});
factory GhRemoveStarArguments.fromJson(Map<String, dynamic> json) =>
_$GhRemoveStarArgumentsFromJson(json);
final String id;
@override
List<Object> get props => [id];
Map<String, dynamic> toJson() => _$GhRemoveStarArgumentsToJson(this);
}
class GhRemoveStarQuery
extends GraphQLQuery<GhRemoveStar, GhRemoveStarArguments> {
GhRemoveStarQuery({this.variables});
@override
final DocumentNode document = DocumentNode(definitions: [
OperationDefinitionNode(
type: OperationType.mutation,
name: NameNode(value: 'GhRemoveStar'),
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'id')),
type: NamedTypeNode(name: NameNode(value: 'ID'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'removeStar'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'input'),
value: ObjectValueNode(fields: [
ObjectFieldNode(
name: NameNode(value: 'starrableId'),
value: VariableNode(name: NameNode(value: 'id')))
]))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'starrable'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'viewerHasStarred'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
]))
]))
]);
@override
final String operationName = 'GhRemoveStar';
@override
final GhRemoveStarArguments variables;
@override
List<Object> get props => [document, operationName, variables];
@override
GhRemoveStar parse(Map<String, dynamic> json) => GhRemoveStar.fromJson(json);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUser with EquatableMixin {
GhFollowUser();
factory GhFollowUser.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserFromJson(json);
GhFollowUserFollowUserPayload followUser;
@override
List<Object> get props => [followUser];
Map<String, dynamic> toJson() => _$GhFollowUserToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserFollowUserPayload with EquatableMixin {
GhFollowUserFollowUserPayload();
factory GhFollowUserFollowUserPayload.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserFollowUserPayloadFromJson(json);
GhFollowUserUser user;
@override
List<Object> get props => [user];
Map<String, dynamic> toJson() => _$GhFollowUserFollowUserPayloadToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserUser extends GhFollowUserAuditEntryActor
with EquatableMixin
implements
GhFollowUserNode,
GhFollowUserActor,
GhFollowUserRegistryPackageOwner,
GhFollowUserRegistryPackageSearch,
GhFollowUserProjectOwner,
GhFollowUserRepositoryOwner,
GhFollowUserUniformResourceLocatable,
GhFollowUserProfileOwner,
GhFollowUserSponsorable {
GhFollowUserUser();
factory GhFollowUserUser.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserUserFromJson(json);
bool viewerIsFollowing;
@override
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [viewerIsFollowing, resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserUserToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserAuditEntryActor with EquatableMixin {
GhFollowUserAuditEntryActor();
factory GhFollowUserAuditEntryActor.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserAuditEntryActorFromJson(json);
@override
List<Object> get props => [];
Map<String, dynamic> toJson() => _$GhFollowUserAuditEntryActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserNode with EquatableMixin {
GhFollowUserNode();
factory GhFollowUserNode.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserNodeFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserNodeToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserActor with EquatableMixin {
GhFollowUserActor();
factory GhFollowUserActor.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserActorFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserRegistryPackageOwner with EquatableMixin {
GhFollowUserRegistryPackageOwner();
factory GhFollowUserRegistryPackageOwner.fromJson(
Map<String, dynamic> json) =>
_$GhFollowUserRegistryPackageOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GhFollowUserRegistryPackageOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserRegistryPackageSearch with EquatableMixin {
GhFollowUserRegistryPackageSearch();
factory GhFollowUserRegistryPackageSearch.fromJson(
Map<String, dynamic> json) =>
_$GhFollowUserRegistryPackageSearchFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GhFollowUserRegistryPackageSearchToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserProjectOwner with EquatableMixin {
GhFollowUserProjectOwner();
factory GhFollowUserProjectOwner.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserProjectOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserProjectOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserRepositoryOwner with EquatableMixin {
GhFollowUserRepositoryOwner();
factory GhFollowUserRepositoryOwner.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserRepositoryOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserRepositoryOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserUniformResourceLocatable with EquatableMixin {
GhFollowUserUniformResourceLocatable();
factory GhFollowUserUniformResourceLocatable.fromJson(
Map<String, dynamic> json) =>
_$GhFollowUserUniformResourceLocatableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GhFollowUserUniformResourceLocatableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserProfileOwner with EquatableMixin {
GhFollowUserProfileOwner();
factory GhFollowUserProfileOwner.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserProfileOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserProfileOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserSponsorable with EquatableMixin {
GhFollowUserSponsorable();
factory GhFollowUserSponsorable.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserSponsorableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhFollowUserSponsorableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhFollowUserArguments extends JsonSerializable with EquatableMixin {
GhFollowUserArguments({this.id});
factory GhFollowUserArguments.fromJson(Map<String, dynamic> json) =>
_$GhFollowUserArgumentsFromJson(json);
final String id;
@override
List<Object> get props => [id];
Map<String, dynamic> toJson() => _$GhFollowUserArgumentsToJson(this);
}
class GhFollowUserQuery
extends GraphQLQuery<GhFollowUser, GhFollowUserArguments> {
GhFollowUserQuery({this.variables});
@override
final DocumentNode document = DocumentNode(definitions: [
OperationDefinitionNode(
type: OperationType.mutation,
name: NameNode(value: 'GhFollowUser'),
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'id')),
type: NamedTypeNode(name: NameNode(value: 'ID'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'followUser'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'input'),
value: ObjectValueNode(fields: [
ObjectFieldNode(
name: NameNode(value: 'userId'),
value: VariableNode(name: NameNode(value: 'id')))
]))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'user'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'viewerIsFollowing'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
]))
]))
]);
@override
final String operationName = 'GhFollowUser';
@override
final GhFollowUserArguments variables;
@override
List<Object> get props => [document, operationName, variables];
@override
GhFollowUser parse(Map<String, dynamic> json) => GhFollowUser.fromJson(json);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUser with EquatableMixin {
GhUnfollowUser();
factory GhUnfollowUser.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserFromJson(json);
GhUnfollowUserUnfollowUserPayload unfollowUser;
@override
List<Object> get props => [unfollowUser];
Map<String, dynamic> toJson() => _$GhUnfollowUserToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserUnfollowUserPayload with EquatableMixin {
GhUnfollowUserUnfollowUserPayload();
factory GhUnfollowUserUnfollowUserPayload.fromJson(
Map<String, dynamic> json) =>
_$GhUnfollowUserUnfollowUserPayloadFromJson(json);
GhUnfollowUserUser user;
@override
List<Object> get props => [user];
Map<String, dynamic> toJson() =>
_$GhUnfollowUserUnfollowUserPayloadToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserUser extends GhUnfollowUserAuditEntryActor
with EquatableMixin
implements
GhUnfollowUserNode,
GhUnfollowUserActor,
GhUnfollowUserRegistryPackageOwner,
GhUnfollowUserRegistryPackageSearch,
GhUnfollowUserProjectOwner,
GhUnfollowUserRepositoryOwner,
GhUnfollowUserUniformResourceLocatable,
GhUnfollowUserProfileOwner,
GhUnfollowUserSponsorable {
GhUnfollowUserUser();
factory GhUnfollowUserUser.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserUserFromJson(json);
bool viewerIsFollowing;
@override
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [viewerIsFollowing, resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserUserToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserAuditEntryActor with EquatableMixin {
GhUnfollowUserAuditEntryActor();
factory GhUnfollowUserAuditEntryActor.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserAuditEntryActorFromJson(json);
@override
List<Object> get props => [];
Map<String, dynamic> toJson() => _$GhUnfollowUserAuditEntryActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserNode with EquatableMixin {
GhUnfollowUserNode();
factory GhUnfollowUserNode.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserNodeFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserNodeToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserActor with EquatableMixin {
GhUnfollowUserActor();
factory GhUnfollowUserActor.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserActorFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserRegistryPackageOwner with EquatableMixin {
GhUnfollowUserRegistryPackageOwner();
factory GhUnfollowUserRegistryPackageOwner.fromJson(
Map<String, dynamic> json) =>
_$GhUnfollowUserRegistryPackageOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GhUnfollowUserRegistryPackageOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserRegistryPackageSearch with EquatableMixin {
GhUnfollowUserRegistryPackageSearch();
factory GhUnfollowUserRegistryPackageSearch.fromJson(
Map<String, dynamic> json) =>
_$GhUnfollowUserRegistryPackageSearchFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GhUnfollowUserRegistryPackageSearchToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserProjectOwner with EquatableMixin {
GhUnfollowUserProjectOwner();
factory GhUnfollowUserProjectOwner.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserProjectOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserProjectOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserRepositoryOwner with EquatableMixin {
GhUnfollowUserRepositoryOwner();
factory GhUnfollowUserRepositoryOwner.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserRepositoryOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserRepositoryOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserUniformResourceLocatable with EquatableMixin {
GhUnfollowUserUniformResourceLocatable();
factory GhUnfollowUserUniformResourceLocatable.fromJson(
Map<String, dynamic> json) =>
_$GhUnfollowUserUniformResourceLocatableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GhUnfollowUserUniformResourceLocatableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserProfileOwner with EquatableMixin {
GhUnfollowUserProfileOwner();
factory GhUnfollowUserProfileOwner.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserProfileOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserProfileOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserSponsorable with EquatableMixin {
GhUnfollowUserSponsorable();
factory GhUnfollowUserSponsorable.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserSponsorableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GhUnfollowUserSponsorableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GhUnfollowUserArguments extends JsonSerializable with EquatableMixin {
GhUnfollowUserArguments({this.id});
factory GhUnfollowUserArguments.fromJson(Map<String, dynamic> json) =>
_$GhUnfollowUserArgumentsFromJson(json);
final String id;
@override
List<Object> get props => [id];
Map<String, dynamic> toJson() => _$GhUnfollowUserArgumentsToJson(this);
}
class GhUnfollowUserQuery
extends GraphQLQuery<GhUnfollowUser, GhUnfollowUserArguments> {
GhUnfollowUserQuery({this.variables});
@override
final DocumentNode document = DocumentNode(definitions: [
OperationDefinitionNode(
type: OperationType.mutation,
name: NameNode(value: 'GhUnfollowUser'),
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'id')),
type: NamedTypeNode(name: NameNode(value: 'ID'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'unfollowUser'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'input'),
value: ObjectValueNode(fields: [
ObjectFieldNode(
name: NameNode(value: 'userId'),
value: VariableNode(name: NameNode(value: 'id')))
]))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'user'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'viewerIsFollowing'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
]))
]))
]);
@override
final String operationName = 'GhUnfollowUser';
@override
final GhUnfollowUserArguments variables;
@override
List<Object> get props => [document, operationName, variables];
@override
GhUnfollowUser parse(Map<String, dynamic> json) =>
GhUnfollowUser.fromJson(json);
}

View File

@ -1342,6 +1342,7 @@ Map<String, dynamic> _$GhUserToJson(GhUser instance) => <String, dynamic>{
GhUserRepositoryOwner _$GhUserRepositoryOwnerFromJson(
Map<String, dynamic> json) {
return GhUserRepositoryOwner()
..id = json['id'] as String
..login = json['login'] as String
..avatarUrl = json['avatarUrl'] as String
..url = json['url'] as String
@ -1351,6 +1352,7 @@ GhUserRepositoryOwner _$GhUserRepositoryOwnerFromJson(
Map<String, dynamic> _$GhUserRepositoryOwnerToJson(
GhUserRepositoryOwner instance) =>
<String, dynamic>{
'id': instance.id,
'login': instance.login,
'avatarUrl': instance.avatarUrl,
'url': instance.url,
@ -1395,6 +1397,7 @@ GhUserUser _$GhUserUserFromJson(Map<String, dynamic> json) {
..viewerCanFollow = json['viewerCanFollow'] as bool
..viewerIsFollowing = json['viewerIsFollowing'] as bool
..resolveType = json['__typename'] as String
..id = json['id'] as String
..login = json['login'] as String
..avatarUrl = json['avatarUrl'] as String
..url = json['url'] as String;
@ -1418,6 +1421,7 @@ Map<String, dynamic> _$GhUserUserToJson(GhUserUser instance) =>
'viewerCanFollow': instance.viewerCanFollow,
'viewerIsFollowing': instance.viewerIsFollowing,
'__typename': instance.resolveType,
'id': instance.id,
'login': instance.login,
'avatarUrl': instance.avatarUrl,
'url': instance.url,
@ -1796,6 +1800,7 @@ GhUserOrganization _$GhUserOrganizationFromJson(Map<String, dynamic> json) {
: GhUserOrganizationMemberConnection.fromJson(
json['membersWithRole'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String
..id = json['id'] as String
..login = json['login'] as String
..avatarUrl = json['avatarUrl'] as String
..url = json['url'] as String;
@ -1813,6 +1818,7 @@ Map<String, dynamic> _$GhUserOrganizationToJson(GhUserOrganization instance) =>
'pinnableItems': instance.pinnableItems?.toJson(),
'membersWithRole': instance.membersWithRole?.toJson(),
'__typename': instance.resolveType,
'id': instance.id,
'login': instance.login,
'avatarUrl': instance.avatarUrl,
'url': instance.url,
@ -2419,3 +2425,433 @@ Map<String, dynamic> _$GhCommitsArgumentsToJson(GhCommitsArguments instance) =>
'hasRef': instance.hasRef,
'after': instance.after,
};
GhAddStar _$GhAddStarFromJson(Map<String, dynamic> json) {
return GhAddStar()
..addStar = json['addStar'] == null
? null
: GhAddStarAddStarPayload.fromJson(
json['addStar'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhAddStarToJson(GhAddStar instance) => <String, dynamic>{
'addStar': instance.addStar?.toJson(),
};
GhAddStarAddStarPayload _$GhAddStarAddStarPayloadFromJson(
Map<String, dynamic> json) {
return GhAddStarAddStarPayload()
..starrable = json['starrable'] == null
? null
: GhAddStarStarrable.fromJson(
json['starrable'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhAddStarAddStarPayloadToJson(
GhAddStarAddStarPayload instance) =>
<String, dynamic>{
'starrable': instance.starrable?.toJson(),
};
GhAddStarStarrable _$GhAddStarStarrableFromJson(Map<String, dynamic> json) {
return GhAddStarStarrable()
..viewerHasStarred = json['viewerHasStarred'] as bool
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhAddStarStarrableToJson(GhAddStarStarrable instance) =>
<String, dynamic>{
'viewerHasStarred': instance.viewerHasStarred,
'__typename': instance.resolveType,
};
GhAddStarArguments _$GhAddStarArgumentsFromJson(Map<String, dynamic> json) {
return GhAddStarArguments(
id: json['id'] as String,
);
}
Map<String, dynamic> _$GhAddStarArgumentsToJson(GhAddStarArguments instance) =>
<String, dynamic>{
'id': instance.id,
};
GhRemoveStar _$GhRemoveStarFromJson(Map<String, dynamic> json) {
return GhRemoveStar()
..removeStar = json['removeStar'] == null
? null
: GhRemoveStarRemoveStarPayload.fromJson(
json['removeStar'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhRemoveStarToJson(GhRemoveStar instance) =>
<String, dynamic>{
'removeStar': instance.removeStar?.toJson(),
};
GhRemoveStarRemoveStarPayload _$GhRemoveStarRemoveStarPayloadFromJson(
Map<String, dynamic> json) {
return GhRemoveStarRemoveStarPayload()
..starrable = json['starrable'] == null
? null
: GhRemoveStarStarrable.fromJson(
json['starrable'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhRemoveStarRemoveStarPayloadToJson(
GhRemoveStarRemoveStarPayload instance) =>
<String, dynamic>{
'starrable': instance.starrable?.toJson(),
};
GhRemoveStarStarrable _$GhRemoveStarStarrableFromJson(
Map<String, dynamic> json) {
return GhRemoveStarStarrable()
..viewerHasStarred = json['viewerHasStarred'] as bool
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhRemoveStarStarrableToJson(
GhRemoveStarStarrable instance) =>
<String, dynamic>{
'viewerHasStarred': instance.viewerHasStarred,
'__typename': instance.resolveType,
};
GhRemoveStarArguments _$GhRemoveStarArgumentsFromJson(
Map<String, dynamic> json) {
return GhRemoveStarArguments(
id: json['id'] as String,
);
}
Map<String, dynamic> _$GhRemoveStarArgumentsToJson(
GhRemoveStarArguments instance) =>
<String, dynamic>{
'id': instance.id,
};
GhFollowUser _$GhFollowUserFromJson(Map<String, dynamic> json) {
return GhFollowUser()
..followUser = json['followUser'] == null
? null
: GhFollowUserFollowUserPayload.fromJson(
json['followUser'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhFollowUserToJson(GhFollowUser instance) =>
<String, dynamic>{
'followUser': instance.followUser?.toJson(),
};
GhFollowUserFollowUserPayload _$GhFollowUserFollowUserPayloadFromJson(
Map<String, dynamic> json) {
return GhFollowUserFollowUserPayload()
..user = json['user'] == null
? null
: GhFollowUserUser.fromJson(json['user'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhFollowUserFollowUserPayloadToJson(
GhFollowUserFollowUserPayload instance) =>
<String, dynamic>{
'user': instance.user?.toJson(),
};
GhFollowUserUser _$GhFollowUserUserFromJson(Map<String, dynamic> json) {
return GhFollowUserUser()
..viewerIsFollowing = json['viewerIsFollowing'] as bool
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserUserToJson(GhFollowUserUser instance) =>
<String, dynamic>{
'viewerIsFollowing': instance.viewerIsFollowing,
'__typename': instance.resolveType,
};
GhFollowUserAuditEntryActor _$GhFollowUserAuditEntryActorFromJson(
Map<String, dynamic> json) {
return GhFollowUserAuditEntryActor();
}
Map<String, dynamic> _$GhFollowUserAuditEntryActorToJson(
GhFollowUserAuditEntryActor instance) =>
<String, dynamic>{};
GhFollowUserNode _$GhFollowUserNodeFromJson(Map<String, dynamic> json) {
return GhFollowUserNode()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserNodeToJson(GhFollowUserNode instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserActor _$GhFollowUserActorFromJson(Map<String, dynamic> json) {
return GhFollowUserActor()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserActorToJson(GhFollowUserActor instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserRegistryPackageOwner _$GhFollowUserRegistryPackageOwnerFromJson(
Map<String, dynamic> json) {
return GhFollowUserRegistryPackageOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserRegistryPackageOwnerToJson(
GhFollowUserRegistryPackageOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserRegistryPackageSearch _$GhFollowUserRegistryPackageSearchFromJson(
Map<String, dynamic> json) {
return GhFollowUserRegistryPackageSearch()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserRegistryPackageSearchToJson(
GhFollowUserRegistryPackageSearch instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserProjectOwner _$GhFollowUserProjectOwnerFromJson(
Map<String, dynamic> json) {
return GhFollowUserProjectOwner()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserProjectOwnerToJson(
GhFollowUserProjectOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserRepositoryOwner _$GhFollowUserRepositoryOwnerFromJson(
Map<String, dynamic> json) {
return GhFollowUserRepositoryOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserRepositoryOwnerToJson(
GhFollowUserRepositoryOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserUniformResourceLocatable
_$GhFollowUserUniformResourceLocatableFromJson(Map<String, dynamic> json) {
return GhFollowUserUniformResourceLocatable()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserUniformResourceLocatableToJson(
GhFollowUserUniformResourceLocatable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserProfileOwner _$GhFollowUserProfileOwnerFromJson(
Map<String, dynamic> json) {
return GhFollowUserProfileOwner()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserProfileOwnerToJson(
GhFollowUserProfileOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserSponsorable _$GhFollowUserSponsorableFromJson(
Map<String, dynamic> json) {
return GhFollowUserSponsorable()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhFollowUserSponsorableToJson(
GhFollowUserSponsorable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhFollowUserArguments _$GhFollowUserArgumentsFromJson(
Map<String, dynamic> json) {
return GhFollowUserArguments(
id: json['id'] as String,
);
}
Map<String, dynamic> _$GhFollowUserArgumentsToJson(
GhFollowUserArguments instance) =>
<String, dynamic>{
'id': instance.id,
};
GhUnfollowUser _$GhUnfollowUserFromJson(Map<String, dynamic> json) {
return GhUnfollowUser()
..unfollowUser = json['unfollowUser'] == null
? null
: GhUnfollowUserUnfollowUserPayload.fromJson(
json['unfollowUser'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhUnfollowUserToJson(GhUnfollowUser instance) =>
<String, dynamic>{
'unfollowUser': instance.unfollowUser?.toJson(),
};
GhUnfollowUserUnfollowUserPayload _$GhUnfollowUserUnfollowUserPayloadFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserUnfollowUserPayload()
..user = json['user'] == null
? null
: GhUnfollowUserUser.fromJson(json['user'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GhUnfollowUserUnfollowUserPayloadToJson(
GhUnfollowUserUnfollowUserPayload instance) =>
<String, dynamic>{
'user': instance.user?.toJson(),
};
GhUnfollowUserUser _$GhUnfollowUserUserFromJson(Map<String, dynamic> json) {
return GhUnfollowUserUser()
..viewerIsFollowing = json['viewerIsFollowing'] as bool
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserUserToJson(GhUnfollowUserUser instance) =>
<String, dynamic>{
'viewerIsFollowing': instance.viewerIsFollowing,
'__typename': instance.resolveType,
};
GhUnfollowUserAuditEntryActor _$GhUnfollowUserAuditEntryActorFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserAuditEntryActor();
}
Map<String, dynamic> _$GhUnfollowUserAuditEntryActorToJson(
GhUnfollowUserAuditEntryActor instance) =>
<String, dynamic>{};
GhUnfollowUserNode _$GhUnfollowUserNodeFromJson(Map<String, dynamic> json) {
return GhUnfollowUserNode()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserNodeToJson(GhUnfollowUserNode instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserActor _$GhUnfollowUserActorFromJson(Map<String, dynamic> json) {
return GhUnfollowUserActor()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserActorToJson(
GhUnfollowUserActor instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserRegistryPackageOwner _$GhUnfollowUserRegistryPackageOwnerFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserRegistryPackageOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserRegistryPackageOwnerToJson(
GhUnfollowUserRegistryPackageOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserRegistryPackageSearch
_$GhUnfollowUserRegistryPackageSearchFromJson(Map<String, dynamic> json) {
return GhUnfollowUserRegistryPackageSearch()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserRegistryPackageSearchToJson(
GhUnfollowUserRegistryPackageSearch instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserProjectOwner _$GhUnfollowUserProjectOwnerFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserProjectOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserProjectOwnerToJson(
GhUnfollowUserProjectOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserRepositoryOwner _$GhUnfollowUserRepositoryOwnerFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserRepositoryOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserRepositoryOwnerToJson(
GhUnfollowUserRepositoryOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserUniformResourceLocatable
_$GhUnfollowUserUniformResourceLocatableFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserUniformResourceLocatable()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserUniformResourceLocatableToJson(
GhUnfollowUserUniformResourceLocatable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserProfileOwner _$GhUnfollowUserProfileOwnerFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserProfileOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserProfileOwnerToJson(
GhUnfollowUserProfileOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserSponsorable _$GhUnfollowUserSponsorableFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserSponsorable()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GhUnfollowUserSponsorableToJson(
GhUnfollowUserSponsorable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GhUnfollowUserArguments _$GhUnfollowUserArgumentsFromJson(
Map<String, dynamic> json) {
return GhUnfollowUserArguments(
id: json['id'] as String,
);
}
Map<String, dynamic> _$GhUnfollowUserArgumentsToJson(
GhUnfollowUserArguments instance) =>
<String, dynamic>{
'id': instance.id,
};

View File

@ -0,0 +1,7 @@
mutation GhAddStar($id: ID!) {
addStar(input: { starrableId: $id }) {
starrable {
viewerHasStarred
}
}
}

View File

@ -0,0 +1,7 @@
mutation GhFollowUser($id: ID!) {
followUser(input: { userId: $id }) {
user {
viewerIsFollowing
}
}
}

View File

@ -0,0 +1,7 @@
mutation GhRemoveStar($id: ID!) {
removeStar(input: { starrableId: $id }) {
starrable {
viewerHasStarred
}
}
}

View File

@ -0,0 +1,7 @@
mutation GhUnfollowUser($id: ID!) {
unfollowUser(input: { userId: $id }) {
user {
viewerIsFollowing
}
}
}

View File

@ -1,6 +1,7 @@
query GhUser($login: String!, $isViewer: Boolean!) {
repositoryOwner(login: $login) @skip(if: $isViewer) {
__typename
id
login
avatarUrl
url

View File

@ -118,6 +118,7 @@ class RepositoryScreen extends StatelessWidget {
1;
final theme = Provider.of<ThemeModel>(context);
final auth = Provider.of<AuthModel>(context);
final license = repo.licenseInfo?.spdxId ?? repo.licenseInfo?.name;
return Column(
@ -147,15 +148,21 @@ class RepositoryScreen extends StatelessWidget {
CupertinoButton(
onPressed: () async {
if (repo.viewerHasStarred) {
await Provider.of<AuthModel>(context)
.deleteWithCredentials(
'/user/starred/$owner/$name');
repo.viewerHasStarred = false;
final res = await auth.gqlClient.execute(
GhRemoveStarQuery(
variables: GhRemoveStarArguments(id: repo.id),
),
);
repo.viewerHasStarred =
res.data.removeStar.starrable.viewerHasStarred;
} else {
await Provider.of<AuthModel>(context)
.putWithCredentials(
'/user/starred/$owner/$name');
repo.viewerHasStarred = true;
final res = await auth.gqlClient.execute(
GhAddStarQuery(
variables: GhAddStarArguments(id: repo.id),
),
);
repo.viewerHasStarred =
res.data.addStar.starrable.viewerHasStarred;
}
setState(() {});
},

View File

@ -358,15 +358,15 @@ class UserScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final auth = Provider.of<AuthModel>(context);
return RefreshStatefulScaffold<GhUserRepositoryOwner>(
fetchData: () async {
final data = await Provider.of<AuthModel>(context).gqlClient.execute(
GhUserQuery(
variables: GhUserArguments(login: login, isViewer: isViewer)));
final data = await auth.gqlClient.execute(GhUserQuery(
variables: GhUserArguments(login: login, isViewer: isViewer)));
return isViewer ? data.data.viewer : data.data.repositoryOwner;
},
title: AppBarTitle(isViewer ? 'Me' : login),
actionBuilder: (payload, _) {
actionBuilder: (payload, setState) {
switch (payload.resolveType) {
case 'User':
final user = payload as GhUserUser;
@ -378,15 +378,20 @@ class UserScreen extends StatelessWidget {
text: user.viewerIsFollowing ? 'Unfollow' : 'Follow',
onTap: (_) async {
if (user.viewerIsFollowing) {
await Provider.of<AuthModel>(context)
.deleteWithCredentials(
'/user/following/${user.login}');
user.viewerIsFollowing = false;
final res = await auth.gqlClient.execute(
GhUnfollowUserQuery(
variables:
GhUnfollowUserArguments(id: user.id)));
user.viewerIsFollowing =
res.data.unfollowUser.user.viewerIsFollowing;
} else {
Provider.of<AuthModel>(context).putWithCredentials(
'/user/following/${user.login}');
user.viewerIsFollowing = true;
final res = await auth.gqlClient.execute(
GhFollowUserQuery(
variables: GhFollowUserArguments(id: user.id)));
user.viewerIsFollowing =
res.data.followUser.user.viewerIsFollowing;
}
setState(() {});
},
),
if (payload != null) ...[