Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
452 stars 199 forks source link

Passing nil for an optional parameter throws an error #1221

Open Isuru-Nanayakkara opened 11 months ago

Isuru-Nanayakkara commented 11 months ago

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.

Screenshot 2023-11-23 at 5 15 38 PM

So I'm not sure why it causes the API call to fail if I actually pass in nil.