Skip to content

Commit

Permalink
[MBL-873] Setup TriggerThirdPartyEvent GraphQL Mutation (#1833)
Browse files Browse the repository at this point in the history
* run bin/apollo-schema-download.sh

* setup TriggerThirdPartyEvent mutation

* update Service and ServiceType
* update MockService
* create new adapter files
* convert TriggerCapiEventInput to TriggerThirdPartyInput
* create TriggerThirdPartyEvent.graphql in /mutations

* update GraphAPI.swift

finally!
  • Loading branch information
scottkicks committed Jul 17, 2023
1 parent 268fbed commit 4b48213
Show file tree
Hide file tree
Showing 11 changed files with 754 additions and 6 deletions.
20 changes: 20 additions & 0 deletions Kickstarter.xcodeproj/project.pbxproj
Expand Up @@ -493,6 +493,11 @@
6078106F2A04191C0050D4F7 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 6078106E2A04191C0050D4F7 /* FirebaseAnalytics */; };
608E7A5328ABDBAE00289E92 /* SetYourPasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608E7A5128ABD5E700289E92 /* SetYourPasswordViewController.swift */; };
608E7A5628ABE6CD00289E92 /* SetYourPasswordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608E7A5428ABE27400289E92 /* SetYourPasswordViewModel.swift */; };
6093098D2A6054CB004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6093098C2A6054CB004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift */; };
6093098F2A6054D8004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6093098E2A6054D8004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift */; };
609309912A60555F004297AF /* TriggerThirdPartyEventInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 609309902A60555F004297AF /* TriggerThirdPartyEventInput.swift */; };
609309932A605563004297AF /* TriggerThirdPartyEventInputTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 609309922A605563004297AF /* TriggerThirdPartyEventInputTests.swift */; };
609309952A6055A5004297AF /* TriggerThirdPartyEvent.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 609309942A6055A5004297AF /* TriggerThirdPartyEvent.graphql */; };
60DA50EB28B689A4002E2DF1 /* SetYourPasswordViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DA50E928B68990002E2DF1 /* SetYourPasswordViewModelTests.swift */; };
60DA50F128B6953A002E2DF1 /* SetYourPasswordViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DA50EF28B69534002E2DF1 /* SetYourPasswordViewControllerTests.swift */; };
60DA50FE28C38DDB002E2DF1 /* AlamofireImage in Frameworks */ = {isa = PBXBuildFile; productRef = 60DA50FD28C38DDB002E2DF1 /* AlamofireImage */; };
Expand Down Expand Up @@ -2070,6 +2075,11 @@
606F2169299E8C9F00BA5CDF /* TriggerCapiEventInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerCapiEventInputTests.swift; sourceTree = "<group>"; };
608E7A5128ABD5E700289E92 /* SetYourPasswordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewController.swift; sourceTree = "<group>"; };
608E7A5428ABE27400289E92 /* SetYourPasswordViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewModel.swift; sourceTree = "<group>"; };
6093098C2A6054CB004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift"; sourceTree = "<group>"; };
6093098E2A6054D8004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift"; sourceTree = "<group>"; };
609309902A60555F004297AF /* TriggerThirdPartyEventInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerThirdPartyEventInput.swift; sourceTree = "<group>"; };
609309922A605563004297AF /* TriggerThirdPartyEventInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerThirdPartyEventInputTests.swift; sourceTree = "<group>"; };
609309942A6055A5004297AF /* TriggerThirdPartyEvent.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = TriggerThirdPartyEvent.graphql; sourceTree = "<group>"; };
60DA50E928B68990002E2DF1 /* SetYourPasswordViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewModelTests.swift; sourceTree = "<group>"; };
60DA50EF28B69534002E2DF1 /* SetYourPasswordViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewControllerTests.swift; sourceTree = "<group>"; };
60DF50962A434E6B002C771F /* DashboardDeprecationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardDeprecationView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5807,6 +5817,7 @@
062868E526B999EF00EC5052 /* DeletePaymentSource.graphql */,
47D7D09526C2EA5200D2BAB5 /* SignInWithApple.graphql */,
606F2165299D456D00BA5CDF /* TriggerCapiEvent.graphql */,
609309942A6055A5004297AF /* TriggerThirdPartyEvent.graphql */,
8AC3E0F4269F48A400168BF8 /* UpdateBacking.graphql */,
06643F3926A5FF1C002C5997 /* UpdateUserAccount.graphql */,
06C38CB826A9D13400591CED /* UpdateUserProfile.graphql */,
Expand Down Expand Up @@ -6027,6 +6038,8 @@
47D7D09B26C2FA5F00D2BAB5 /* GraphAPI.SignInWithAppleInput+SignInWithAppleInputTests.swift */,
606F215D299D414800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInput.swift */,
606F215A299D3EF800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInputTests.swift */,
6093098C2A6054CB004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift */,
6093098E2A6054D8004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift */,
8AC3E10C269F4D4000168BF8 /* GraphAPI.UpdateBackingInput+UpdateBackingInput.swift */,
8AC3E111269F4DAF00168BF8 /* GraphAPI.UpdateBackingInput+UpdateBackingInputTests.swift */,
06643F3B26A61338002C5997 /* GraphAPI.UpdateUserAccountInput+UpdateUserAccountInput.swift */,
Expand Down Expand Up @@ -7119,6 +7132,8 @@
77C0818D245CBA1B004ABE88 /* SignInWithAppleInputTests.swift */,
606F2167299D45F900BA5CDF /* TriggerCapiEventInput.swift */,
606F2169299E8C9F00BA5CDF /* TriggerCapiEventInputTests.swift */,
609309902A60555F004297AF /* TriggerThirdPartyEventInput.swift */,
609309922A605563004297AF /* TriggerThirdPartyEventInputTests.swift */,
4753C76E264DAFD300BB10B6 /* PostCommentInput.swift */,
4753C78E264EE1B100BB10B6 /* PostCommentInputTests.swift */,
);
Expand Down Expand Up @@ -7558,6 +7573,7 @@
06DAAE5626AA3CCB00194E58 /* LocationFragment.graphql in Resources */,
06DAAE5326AA3CC300194E58 /* RewardFragment.graphql in Resources */,
47A662F126AF1FCC001CE7B1 /* WatchProject.graphql in Resources */,
609309952A6055A5004297AF /* TriggerThirdPartyEvent.graphql in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -8849,6 +8865,7 @@
20EB9313266030CB004FA1C8 /* PostCommentEnvelope.swift in Sources */,
D01588BD1EEB2ED7006E7684 /* ProjectStatsEnvelope.RewardDistributionLenses.swift in Sources */,
D01588611EEB2ED7006E7684 /* Config.swift in Sources */,
609309932A605563004297AF /* TriggerThirdPartyEventInputTests.swift in Sources */,
D64DDCE123564D3700DE0EA9 /* PaymentSourceTemplates.swift in Sources */,
D002CAE5218CF951009783F2 /* WatchProjectResponseEnvelope.swift in Sources */,
D0158A1C1EEB30A2006E7684 /* ProjectNotificationTemplates.swift in Sources */,
Expand All @@ -8871,6 +8888,7 @@
8AC3E0962698CF0600168BF8 /* ShippingRule+ShippingRuleFragment.swift in Sources */,
06FE2D7726CDB01E00A4C0F4 /* MockGraphQLClient.swift in Sources */,
D6C9A2541F758C7900981E64 /* GraphCategoryLenses.swift in Sources */,
6093098F2A6054D8004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift in Sources */,
D015883B1EEB2ED7006E7684 /* MimeType.swift in Sources */,
D01589931EEB2ED7006E7684 /* User.swift in Sources */,
D0158A271EEB30A2006E7684 /* ShippingRuleTemplates.swift in Sources */,
Expand All @@ -8883,10 +8901,12 @@
8AF34C742342CBC2000B211D /* UpdateBackingInput.swift in Sources */,
4778EE2126A200BE0059EA69 /* UserEnvelope+GraphUserEnvelope.swift in Sources */,
8ADCCCAE264C98A50079D308 /* Comment.swift in Sources */,
609309912A60555F004297AF /* TriggerThirdPartyEventInput.swift in Sources */,
D0158A2E1EEB30A2006E7684 /* User.AvatarTemplates.swift in Sources */,
D01588771EEB2ED7006E7684 /* FriendStatsEnvelope.swift in Sources */,
D015891D1EEB2ED7006E7684 /* ShippingRule.swift in Sources */,
D67B6CD6221F468100B63A6B /* Location+Encode.swift in Sources */,
6093098D2A6054CB004297AF /* GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift in Sources */,
8AC3E105269F4D1C00168BF8 /* GraphAPI.ApplePay+ApplePayParams.swift in Sources */,
D01588331EEB2ED7006E7684 /* Decodable.swift in Sources */,
06232D3E2795EC2C00A81755 /* Element+Helpers.swift in Sources */,
Expand Down
267 changes: 267 additions & 0 deletions KsApi/GraphAPI.swift
Expand Up @@ -754,6 +754,179 @@ public enum GraphAPI {
}
}

/// Autogenerated input type of TriggerThirdPartyEvent
public struct TriggerThirdPartyEventInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap

/// - Parameters:
/// - deviceId
/// - eventName
/// - firebaseScreen
/// - firebasePreviousScreen
/// - items
/// - projectId
/// - pledgeAmount
/// - shipping
/// - transactionId
/// - userId
/// - appData
/// - clientMutationId: A unique identifier for the client performing the mutation.
public init(deviceId: String, eventName: String, firebaseScreen: Swift.Optional<String?> = nil, firebasePreviousScreen: Swift.Optional<String?> = nil, items: Swift.Optional<[ThirdPartyEventItemInput]?> = nil, projectId: GraphQLID, pledgeAmount: Swift.Optional<Double?> = nil, shipping: Swift.Optional<Double?> = nil, transactionId: Swift.Optional<String?> = nil, userId: Swift.Optional<String?> = nil, appData: Swift.Optional<AppDataInput?> = nil, clientMutationId: Swift.Optional<String?> = nil) {
graphQLMap = ["deviceId": deviceId, "eventName": eventName, "firebaseScreen": firebaseScreen, "firebasePreviousScreen": firebasePreviousScreen, "items": items, "projectId": projectId, "pledgeAmount": pledgeAmount, "shipping": shipping, "transactionId": transactionId, "userId": userId, "appData": appData, "clientMutationId": clientMutationId]
}

public var deviceId: String {
get {
return graphQLMap["deviceId"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "deviceId")
}
}

public var eventName: String {
get {
return graphQLMap["eventName"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "eventName")
}
}

public var firebaseScreen: Swift.Optional<String?> {
get {
return graphQLMap["firebaseScreen"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "firebaseScreen")
}
}

public var firebasePreviousScreen: Swift.Optional<String?> {
get {
return graphQLMap["firebasePreviousScreen"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "firebasePreviousScreen")
}
}

public var items: Swift.Optional<[ThirdPartyEventItemInput]?> {
get {
return graphQLMap["items"] as? Swift.Optional<[ThirdPartyEventItemInput]?> ?? Swift.Optional<[ThirdPartyEventItemInput]?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "items")
}
}

public var projectId: GraphQLID {
get {
return graphQLMap["projectId"] as! GraphQLID
}
set {
graphQLMap.updateValue(newValue, forKey: "projectId")
}
}

public var pledgeAmount: Swift.Optional<Double?> {
get {
return graphQLMap["pledgeAmount"] as? Swift.Optional<Double?> ?? Swift.Optional<Double?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "pledgeAmount")
}
}

public var shipping: Swift.Optional<Double?> {
get {
return graphQLMap["shipping"] as? Swift.Optional<Double?> ?? Swift.Optional<Double?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "shipping")
}
}

public var transactionId: Swift.Optional<String?> {
get {
return graphQLMap["transactionId"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "transactionId")
}
}

public var userId: Swift.Optional<String?> {
get {
return graphQLMap["userId"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "userId")
}
}

public var appData: Swift.Optional<AppDataInput?> {
get {
return graphQLMap["appData"] as? Swift.Optional<AppDataInput?> ?? Swift.Optional<AppDataInput?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "appData")
}
}

/// A unique identifier for the client performing the mutation.
public var clientMutationId: Swift.Optional<String?> {
get {
return graphQLMap["clientMutationId"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "clientMutationId")
}
}
}

public struct ThirdPartyEventItemInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap

/// - Parameters:
/// - itemId: The ID of the item.
/// - itemName: The name of the item.
/// - price: The monetary price of the item, in units of the specified currency parameter.
public init(itemId: String, itemName: String, price: Swift.Optional<Double?> = nil) {
graphQLMap = ["itemId": itemId, "itemName": itemName, "price": price]
}

/// The ID of the item.
public var itemId: String {
get {
return graphQLMap["itemId"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "itemId")
}
}

/// The name of the item.
public var itemName: String {
get {
return graphQLMap["itemName"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "itemName")
}
}

/// The monetary price of the item, in units of the specified currency parameter.
public var price: Swift.Optional<Double?> {
get {
return graphQLMap["price"] as? Swift.Optional<Double?> ?? Swift.Optional<Double?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "price")
}
}
}

/// Autogenerated input type of UnwatchProject
public struct UnwatchProjectInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap
Expand Down Expand Up @@ -4460,6 +4633,100 @@ public enum GraphAPI {
}
}

public final class TriggerThirdPartyEventMutation: GraphQLMutation {
/// The raw GraphQL definition of this operation.
public let operationDefinition: String =
"""
mutation triggerThirdPartyEvent($input: TriggerThirdPartyEventInput!) {
triggerThirdPartyEvent(input: $input) {
__typename
success
}
}
"""

public let operationName: String = "triggerThirdPartyEvent"

public var input: TriggerThirdPartyEventInput

public init(input: TriggerThirdPartyEventInput) {
self.input = input
}

public var variables: GraphQLMap? {
return ["input": input]
}

public struct Data: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["Mutation"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("triggerThirdPartyEvent", arguments: ["input": GraphQLVariable("input")], type: .object(TriggerThirdPartyEvent.selections)),
]
}

public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public init(triggerThirdPartyEvent: TriggerThirdPartyEvent? = nil) {
self.init(unsafeResultMap: ["__typename": "Mutation", "triggerThirdPartyEvent": triggerThirdPartyEvent.flatMap { (value: TriggerThirdPartyEvent) -> ResultMap in value.resultMap }])
}

/// Triggers third party event
public var triggerThirdPartyEvent: TriggerThirdPartyEvent? {
get {
return (resultMap["triggerThirdPartyEvent"] as? ResultMap).flatMap { TriggerThirdPartyEvent(unsafeResultMap: $0) }
}
set {
resultMap.updateValue(newValue?.resultMap, forKey: "triggerThirdPartyEvent")
}
}

public struct TriggerThirdPartyEvent: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["TriggerThirdPartyEventPayload"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLField("success", type: .nonNull(.scalar(Bool.self))),
]
}

public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public init(success: Bool) {
self.init(unsafeResultMap: ["__typename": "TriggerThirdPartyEventPayload", "success": success])
}

public var __typename: String {
get {
return resultMap["__typename"]! as! String
}
set {
resultMap.updateValue(newValue, forKey: "__typename")
}
}

public var success: Bool {
get {
return resultMap["success"]! as! Bool
}
set {
resultMap.updateValue(newValue, forKey: "success")
}
}
}
}
}

public final class UnwatchProjectMutation: GraphQLMutation {
/// The raw GraphQL definition of this operation.
public let operationDefinition: String =
Expand Down

0 comments on commit 4b48213

Please sign in to comment.