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

Internal error creating checkout #1059

Closed dlallie closed 4 years ago

dlallie commented 4 years ago

I am trying to create a basic checkout from a single product ID to then hand off to the browser with the web URL. The graph mutation task however returns an invalid query error with an "Internal error" reason.

One of my request IDs from this error is: 009b1e52-0a89-4918-aa10-5dc5314282e1

Below is the code I am using with version 3.7.0 of the SDK:

let checkout = Storefront.CheckoutCreateInput.create(
    lineItems: .value([
        Storefront.CheckoutLineItemInput.create(quantity: 1, variantId: GraphQL.ID(rawValue: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ1MzM4NTg1OTg5ODY="))
    ])
)

let mutation = Storefront.buildMutation { $0
    .checkoutCreate(input: checkout) { $0
        .checkout { $0
            .webUrl()
        }
    }
}

let task = client.mutateGraphWith(mutation) { result, error in
    ...
}
task.resume()
dlallie commented 4 years ago

I found that this issue was caused by inputing a product ID in the GraphQL.ID initialiser. When using the correct variant ID for a product (even one with no variants) creating checkouts is now working as expected.