Skip to content

Commit

Permalink
Merge pull request #955 from Shopify/task/update-schema
Browse files Browse the repository at this point in the history
Update schema
  • Loading branch information
dbart01 authored Dec 21, 2018
2 parents b3ae748 + 9d98686 commit b635f5b
Show file tree
Hide file tree
Showing 16 changed files with 844 additions and 23 deletions.
8 changes: 8 additions & 0 deletions Buy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@
9A2ACDDB21CABB7100C09FF7 /* CheckoutLineItemsReplacePayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2ACDDA21CABB7000C09FF7 /* CheckoutLineItemsReplacePayload.swift */; };
9A2ACDDC21CABB7100C09FF7 /* CheckoutLineItemsReplacePayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2ACDDA21CABB7000C09FF7 /* CheckoutLineItemsReplacePayload.swift */; };
9A2ACDDD21CABB7100C09FF7 /* CheckoutLineItemsReplacePayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2ACDDA21CABB7000C09FF7 /* CheckoutLineItemsReplacePayload.swift */; };
9A2ACE2D21CD3C8700C09FF7 /* AutomaticDiscountApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2ACE2C21CD3C8600C09FF7 /* AutomaticDiscountApplication.swift */; };
9A2ACE2E21CD3C8700C09FF7 /* AutomaticDiscountApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2ACE2C21CD3C8600C09FF7 /* AutomaticDiscountApplication.swift */; };
9A2ACE2F21CD3C8700C09FF7 /* AutomaticDiscountApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2ACE2C21CD3C8600C09FF7 /* AutomaticDiscountApplication.swift */; };
9A4068E51E8E7659000254CD /* Pay.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A4068DC1E8E7658000254CD /* Pay.framework */; };
9A4068EA1E8E7659000254CD /* PaySessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A4068E91E8E7659000254CD /* PaySessionTests.swift */; };
9A4068EC1E8E7659000254CD /* Pay.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4068DE1E8E7659000254CD /* Pay.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -777,6 +780,7 @@
9A2ACDC321CABAC200C09FF7 /* Page.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Page.swift; sourceTree = "<group>"; };
9A2ACDC421CABAC200C09FF7 /* PageSortKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageSortKeys.swift; sourceTree = "<group>"; };
9A2ACDDA21CABB7000C09FF7 /* CheckoutLineItemsReplacePayload.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckoutLineItemsReplacePayload.swift; sourceTree = "<group>"; };
9A2ACE2C21CD3C8600C09FF7 /* AutomaticDiscountApplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutomaticDiscountApplication.swift; sourceTree = "<group>"; };
9A4068DC1E8E7658000254CD /* Pay.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pay.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9A4068DE1E8E7659000254CD /* Pay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Pay.h; sourceTree = "<group>"; };
9A4068DF1E8E7659000254CD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -957,6 +961,7 @@
9AA416C61EE095AA0060029B /* ArticleSortKeys.swift */,
9A0C7FFA1EAA51C50020F187 /* Attribute.swift */,
9A0C7FFB1EAA51C50020F187 /* AttributeInput.swift */,
9A2ACE2C21CD3C8600C09FF7 /* AutomaticDiscountApplication.swift */,
9A0C7FFC1EAA51C50020F187 /* AvailableShippingRates.swift */,
9AA416CC1EE095B20060029B /* Blog.swift */,
9AA416CD1EE095B20060029B /* BlogConnection.swift */,
Expand Down Expand Up @@ -1704,6 +1709,7 @@
9AC2EF471F6818180037E0D7 /* ProductEdge.swift in Sources */,
9AC2EF481F6818180037E0D7 /* CheckoutAttributesUpdatePayload.swift in Sources */,
9AC2EF491F6818180037E0D7 /* WeightUnit.swift in Sources */,
9A2ACE2E21CD3C8700C09FF7 /* AutomaticDiscountApplication.swift in Sources */,
9AC2EF4A1F6818180037E0D7 /* CustomerUpdatePayload.swift in Sources */,
9AC2EF4B1F6818180037E0D7 /* Graph.Task.swift in Sources */,
9AC2EF4C1F6818180037E0D7 /* Customer.swift in Sources */,
Expand Down Expand Up @@ -1898,6 +1904,7 @@
9A0C80A51EAA51C50020F187 /* ProductEdge.swift in Sources */,
9A0C805E1EAA51C50020F187 /* CheckoutAttributesUpdatePayload.swift in Sources */,
9A0C80B51EAA51C50020F187 /* WeightUnit.swift in Sources */,
9A2ACE2D21CD3C8700C09FF7 /* AutomaticDiscountApplication.swift in Sources */,
9A0C808C1EAA51C50020F187 /* CustomerUpdatePayload.swift in Sources */,
9A4069CF1E8ED98A000254CD /* Graph.Task.swift in Sources */,
9A0C807B1EAA51C50020F187 /* Customer.swift in Sources */,
Expand Down Expand Up @@ -2092,6 +2099,7 @@
9AF255C11F6FEE50005BB0C9 /* ProductEdge.swift in Sources */,
9AF255C21F6FEE50005BB0C9 /* CheckoutAttributesUpdatePayload.swift in Sources */,
9AF255C31F6FEE50005BB0C9 /* WeightUnit.swift in Sources */,
9A2ACE2F21CD3C8700C09FF7 /* AutomaticDiscountApplication.swift in Sources */,
9AF255C41F6FEE50005BB0C9 /* CustomerUpdatePayload.swift in Sources */,
9AF255C51F6FEE50005BB0C9 /* Graph.Task.swift in Sources */,
9AF255C61F6FEE50005BB0C9 /* Customer.swift in Sources */,
Expand Down
168 changes: 168 additions & 0 deletions Buy/Generated/Storefront/AutomaticDiscountApplication.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
//
// AutomaticDiscountApplication.swift
// Buy
//
// Created by Shopify.
// Copyright (c) 2017 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

extension Storefront {
/// Automatic discount applications capture the intentions of a discount that
/// was automatically applied.
open class AutomaticDiscountApplicationQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = AutomaticDiscountApplication

/// The method by which the discount's value is allocated to its entitled
/// items.
@discardableResult
open func allocationMethod(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "allocationMethod", aliasSuffix: alias)
return self
}

/// Which lines of targetType that the discount is allocated over.
@discardableResult
open func targetSelection(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "targetSelection", aliasSuffix: alias)
return self
}

/// The type of line that the discount is applicable towards.
@discardableResult
open func targetType(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "targetType", aliasSuffix: alias)
return self
}

/// The title of the application.
@discardableResult
open func title(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "title", aliasSuffix: alias)
return self
}

/// The value of the discount application.
@discardableResult
open func value(alias: String? = nil, _ subfields: (PricingValueQuery) -> Void) -> AutomaticDiscountApplicationQuery {
let subquery = PricingValueQuery()
subfields(subquery)

addField(field: "value", aliasSuffix: alias, subfields: subquery)
return self
}
}

/// Automatic discount applications capture the intentions of a discount that
/// was automatically applied.
open class AutomaticDiscountApplication: GraphQL.AbstractResponse, GraphQLObject, DiscountApplication {
public typealias Query = AutomaticDiscountApplicationQuery

internal override func deserializeValue(fieldName: String, value: Any) throws -> Any? {
let fieldValue = value
switch fieldName {
case "allocationMethod":
guard let value = value as? String else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return DiscountApplicationAllocationMethod(rawValue: value) ?? .unknownValue

case "targetSelection":
guard let value = value as? String else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return DiscountApplicationTargetSelection(rawValue: value) ?? .unknownValue

case "targetType":
guard let value = value as? String else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return DiscountApplicationTargetType(rawValue: value) ?? .unknownValue

case "title":
guard let value = value as? String else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return value

case "value":
guard let value = value as? [String: Any] else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return try UnknownPricingValue.create(fields: value)

default:
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
}

/// The method by which the discount's value is allocated to its entitled
/// items.
open var allocationMethod: Storefront.DiscountApplicationAllocationMethod {
return internalGetAllocationMethod()
}

func internalGetAllocationMethod(alias: String? = nil) -> Storefront.DiscountApplicationAllocationMethod {
return field(field: "allocationMethod", aliasSuffix: alias) as! Storefront.DiscountApplicationAllocationMethod
}

/// Which lines of targetType that the discount is allocated over.
open var targetSelection: Storefront.DiscountApplicationTargetSelection {
return internalGetTargetSelection()
}

func internalGetTargetSelection(alias: String? = nil) -> Storefront.DiscountApplicationTargetSelection {
return field(field: "targetSelection", aliasSuffix: alias) as! Storefront.DiscountApplicationTargetSelection
}

/// The type of line that the discount is applicable towards.
open var targetType: Storefront.DiscountApplicationTargetType {
return internalGetTargetType()
}

func internalGetTargetType(alias: String? = nil) -> Storefront.DiscountApplicationTargetType {
return field(field: "targetType", aliasSuffix: alias) as! Storefront.DiscountApplicationTargetType
}

/// The title of the application.
open var title: String {
return internalGetTitle()
}

func internalGetTitle(alias: String? = nil) -> String {
return field(field: "title", aliasSuffix: alias) as! String
}

/// The value of the discount application.
open var value: PricingValue {
return internalGetValue()
}

func internalGetValue(alias: String? = nil) -> PricingValue {
return field(field: "value", aliasSuffix: alias) as! PricingValue
}

internal override func childResponseObjectMap() -> [GraphQL.AbstractResponse] {
return []
}
}
}
33 changes: 33 additions & 0 deletions Buy/Generated/Storefront/CheckoutAttributesUpdateV2Payload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ extension Storefront {

/// List of errors that occurred executing the mutation.
@discardableResult
open func checkoutUserErrors(alias: String? = nil, _ subfields: (CheckoutUserErrorQuery) -> Void) -> CheckoutAttributesUpdateV2PayloadQuery {
let subquery = CheckoutUserErrorQuery()
subfields(subquery)

addField(field: "checkoutUserErrors", aliasSuffix: alias, subfields: subquery)
return self
}

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
@discardableResult
open func userErrors(alias: String? = nil, _ subfields: (UserErrorQuery) -> Void) -> CheckoutAttributesUpdateV2PayloadQuery {
let subquery = UserErrorQuery()
subfields(subquery)
Expand All @@ -66,6 +77,12 @@ extension Storefront {
}
return try Checkout(fields: value)

case "checkoutUserErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutAttributesUpdateV2Payload.self, field: fieldName, value: fieldValue)
}
return try value.map { return try CheckoutUserError(fields: $0) }

case "userErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutAttributesUpdateV2Payload.self, field: fieldName, value: fieldValue)
Expand All @@ -87,6 +104,16 @@ extension Storefront {
}

/// List of errors that occurred executing the mutation.
open var checkoutUserErrors: [Storefront.CheckoutUserError] {
return internalGetCheckoutUserErrors()
}

func internalGetCheckoutUserErrors(alias: String? = nil) -> [Storefront.CheckoutUserError] {
return field(field: "checkoutUserErrors", aliasSuffix: alias) as! [Storefront.CheckoutUserError]
}

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
open var userErrors: [Storefront.UserError] {
return internalGetUserErrors()
}
Expand All @@ -105,6 +132,12 @@ extension Storefront {
response.append(contentsOf: value.childResponseObjectMap())
}

case "checkoutUserErrors":
internalGetCheckoutUserErrors().forEach {
response.append($0)
response.append(contentsOf: $0.childResponseObjectMap())
}

case "userErrors":
internalGetUserErrors().forEach {
response.append($0)
Expand Down
33 changes: 33 additions & 0 deletions Buy/Generated/Storefront/CheckoutCompleteFreePayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ extension Storefront {

/// List of errors that occurred executing the mutation.
@discardableResult
open func checkoutUserErrors(alias: String? = nil, _ subfields: (CheckoutUserErrorQuery) -> Void) -> CheckoutCompleteFreePayloadQuery {
let subquery = CheckoutUserErrorQuery()
subfields(subquery)

addField(field: "checkoutUserErrors", aliasSuffix: alias, subfields: subquery)
return self
}

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
@discardableResult
open func userErrors(alias: String? = nil, _ subfields: (UserErrorQuery) -> Void) -> CheckoutCompleteFreePayloadQuery {
let subquery = UserErrorQuery()
subfields(subquery)
Expand All @@ -66,6 +77,12 @@ extension Storefront {
}
return try Checkout(fields: value)

case "checkoutUserErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutCompleteFreePayload.self, field: fieldName, value: fieldValue)
}
return try value.map { return try CheckoutUserError(fields: $0) }

case "userErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutCompleteFreePayload.self, field: fieldName, value: fieldValue)
Expand All @@ -87,6 +104,16 @@ extension Storefront {
}

/// List of errors that occurred executing the mutation.
open var checkoutUserErrors: [Storefront.CheckoutUserError] {
return internalGetCheckoutUserErrors()
}

func internalGetCheckoutUserErrors(alias: String? = nil) -> [Storefront.CheckoutUserError] {
return field(field: "checkoutUserErrors", aliasSuffix: alias) as! [Storefront.CheckoutUserError]
}

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
open var userErrors: [Storefront.UserError] {
return internalGetUserErrors()
}
Expand All @@ -105,6 +132,12 @@ extension Storefront {
response.append(contentsOf: value.childResponseObjectMap())
}

case "checkoutUserErrors":
internalGetCheckoutUserErrors().forEach {
response.append($0)
response.append(contentsOf: $0.childResponseObjectMap())
}

case "userErrors":
internalGetUserErrors().forEach {
response.append($0)
Expand Down
Loading

0 comments on commit b635f5b

Please sign in to comment.