Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 5bc7aa2

Browse files
author
Ryan Nystrom
committed
add/remove reaction queries
1 parent a2adba9 commit 5bc7aa2

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

gql/API.swift

+126
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,69 @@ public enum ReactionContent: String {
1414

1515
extension ReactionContent: JSONDecodable, JSONEncodable {}
1616

17+
public final class AddReactionMutation: GraphQLMutation {
18+
public static let operationDefinition =
19+
"mutation AddReaction($subject_id: ID!, $content: ReactionContent!) {" +
20+
" addReaction(input: {subjectId: $subject_id, content: $content}) {" +
21+
" __typename" +
22+
" subject {" +
23+
" __typename" +
24+
" ...reactionFields" +
25+
" }" +
26+
" }" +
27+
"}"
28+
public static let queryDocument = operationDefinition.appending(ReactionFields.fragmentDefinition)
29+
30+
public let subjectId: GraphQLID
31+
public let content: ReactionContent
32+
33+
public init(subjectId: GraphQLID, content: ReactionContent) {
34+
self.subjectId = subjectId
35+
self.content = content
36+
}
37+
38+
public var variables: GraphQLMap? {
39+
return ["subject_id": subjectId, "content": content]
40+
}
41+
42+
public struct Data: GraphQLMappable {
43+
/// Adds a reaction to a subject.
44+
public let addReaction: AddReaction?
45+
46+
public init(reader: GraphQLResultReader) throws {
47+
addReaction = try reader.optionalValue(for: Field(responseName: "addReaction", arguments: ["input": ["subjectId": reader.variables["subject_id"], "content": reader.variables["content"]]]))
48+
}
49+
50+
public struct AddReaction: GraphQLMappable {
51+
public let __typename: String
52+
/// The reactable subject.
53+
public let subject: Subject
54+
55+
public init(reader: GraphQLResultReader) throws {
56+
__typename = try reader.value(for: Field(responseName: "__typename"))
57+
subject = try reader.value(for: Field(responseName: "subject"))
58+
}
59+
60+
public struct Subject: GraphQLMappable {
61+
public let __typename: String
62+
63+
public let fragments: Fragments
64+
65+
public init(reader: GraphQLResultReader) throws {
66+
__typename = try reader.value(for: Field(responseName: "__typename"))
67+
68+
let reactionFields = try ReactionFields(reader: reader)
69+
fragments = Fragments(reactionFields: reactionFields)
70+
}
71+
72+
public struct Fragments {
73+
public let reactionFields: ReactionFields
74+
}
75+
}
76+
}
77+
}
78+
}
79+
1780
public final class IssueOrPullRequestQuery: GraphQLQuery {
1881
public static let operationDefinition =
1982
"query IssueOrPullRequest($owner: String!, $repo: String!, $number: Int!, $page_size: Int!) {" +
@@ -1027,6 +1090,69 @@ public final class IssueOrPullRequestQuery: GraphQLQuery {
10271090
}
10281091
}
10291092

1093+
public final class RemoveReactionMutation: GraphQLMutation {
1094+
public static let operationDefinition =
1095+
"mutation RemoveReaction($subject_id: ID!, $content: ReactionContent!) {" +
1096+
" removeReaction(input: {subjectId: $subject_id, content: $content}) {" +
1097+
" __typename" +
1098+
" subject {" +
1099+
" __typename" +
1100+
" ...reactionFields" +
1101+
" }" +
1102+
" }" +
1103+
"}"
1104+
public static let queryDocument = operationDefinition.appending(ReactionFields.fragmentDefinition)
1105+
1106+
public let subjectId: GraphQLID
1107+
public let content: ReactionContent
1108+
1109+
public init(subjectId: GraphQLID, content: ReactionContent) {
1110+
self.subjectId = subjectId
1111+
self.content = content
1112+
}
1113+
1114+
public var variables: GraphQLMap? {
1115+
return ["subject_id": subjectId, "content": content]
1116+
}
1117+
1118+
public struct Data: GraphQLMappable {
1119+
/// Removes a reaction from a subject.
1120+
public let removeReaction: RemoveReaction?
1121+
1122+
public init(reader: GraphQLResultReader) throws {
1123+
removeReaction = try reader.optionalValue(for: Field(responseName: "removeReaction", arguments: ["input": ["subjectId": reader.variables["subject_id"], "content": reader.variables["content"]]]))
1124+
}
1125+
1126+
public struct RemoveReaction: GraphQLMappable {
1127+
public let __typename: String
1128+
/// The reactable subject.
1129+
public let subject: Subject
1130+
1131+
public init(reader: GraphQLResultReader) throws {
1132+
__typename = try reader.value(for: Field(responseName: "__typename"))
1133+
subject = try reader.value(for: Field(responseName: "subject"))
1134+
}
1135+
1136+
public struct Subject: GraphQLMappable {
1137+
public let __typename: String
1138+
1139+
public let fragments: Fragments
1140+
1141+
public init(reader: GraphQLResultReader) throws {
1142+
__typename = try reader.value(for: Field(responseName: "__typename"))
1143+
1144+
let reactionFields = try ReactionFields(reader: reader)
1145+
fragments = Fragments(reactionFields: reactionFields)
1146+
}
1147+
1148+
public struct Fragments {
1149+
public let reactionFields: ReactionFields
1150+
}
1151+
}
1152+
}
1153+
}
1154+
}
1155+
10301156
public struct ReactionFields: GraphQLNamedFragment {
10311157
public static let fragmentDefinition =
10321158
"fragment reactionFields on Reactable {" +

gql/AddReaction.graphql

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mutation AddReaction($subject_id: ID!, $content: ReactionContent!) {
2+
addReaction(input:{subjectId: $subject_id, content:$content}) {
3+
subject{
4+
...reactionFields
5+
}
6+
}
7+
}

gql/RemoveReaction.graphql

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mutation RemoveReaction($subject_id: ID!, $content: ReactionContent!) {
2+
removeReaction(input:{subjectId: $subject_id, content:$content}) {
3+
subject{
4+
...reactionFields
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)