ios – Passing nil for an optional parameter throws an error in Shopify SDK


This question is related to Shopify’s Buy SDK for iOS.

I’m creating a checkout using the checkoutCreate mutation. According to the docs, the email parameter is optional. But if I pass nil to it, the API call fails.

let checkoutInput = Storefront.CheckoutCreateInput.create(
    email: .value(email), // `email` is an optional string and I'm passing `nil` for that parameter
    lineItems: .value(lineItemInput),
    note: .value(note),
    allowPartialAddresses: .value(true)
)

The .value(:) case itself accepts an optional string value according to the docs.

image from SDK docs

So I’m not sure why it causes the API call to fail if I actually pass in nil. Anyone who has experience in working with Shopify SDK, would appreciate any help.

Thanks!

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img