I’m encountering an issue where GraphQL requests hang indefinitely when using the Shopify iOS Buy SDK (MobileBuySDK).
However, the same GraphQL queries work perfectly when sent via manual URLSession requests or cURL.
Steps to Reproduce:
SDK Setup:
Using Shopify’s Buy SDK (MobileBuySDK).
Correctly set up SHOPIFY_STORE_DOMAIN, SHOPIFY_API_TOKEN, and SHOPIFY_API_VERSION in Config.xcconfig and Info.plist.
Fetching Products via SDK:
let query = Storefront.buildQuery { $0
.products(first: 5) { $0
.edges { $0
.node { $0
.title()
.description()
.images(first: 1) { $0.edges { $0.node { $0.url() } } }
}
}
}
}
client.queryGraphWith(query) { response, error in
if let error = error {
print("Error: \(error.localizedDescription)")
} else {
print("Success: \(response)")
}
}
Expected Result:
Products should be fetched and displayed.
Actual Result:
The SDK hangs, and no response is received.
Logs show:
Sending GraphQL request via Shopify SDK...
GraphQL Query: query {products(first:5){edges{node{title,description,images(first:1){edges{node{url}}}}}}}
Still waiting for Shopify SDK response... Check network settings or API configuration.
Manual Request (Works as Expected): Sending the same GraphQL query via URLSession or cURL successfully fetches products.
Manual Swift Code:
var request = URLRequest(url: URL(string: "https://my-store-name.myshopify.com/api/2023-07/graphql.json")!)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("YOUR_ACCESS_TOKEN", forHTTPHeaderField: "X-Shopify-Storefront-Access-Token")
request.httpBody = try? JSONSerialization.data(withJSONObject: ["query": "query { products(first: 5) { edges { node { title description } } } }"])
URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8)!)
}
}.resume()
Environment:
SDK Version: MobileBuySDK (Version 13.0)
Xcode Version: 12.4
iOS Deployment Target: 14.0
Shopify API Version: 2023-07
Device/Simulator: iPhone Simulator (iOS 14.4)
pod 'Mobile-Buy-SDK', '~> 13.0'
Troubleshooting Steps Taken:
Verified API credentials and permissions—manual requests work fine.
Removed /api/{version} from the shopDomain when initializing Graph.Client.
Added debug URL protocols to log network requests (no requests were leaving the SDK).
Updated/downgraded SDK versions, but the issue persists.
Expected Behavior:
The SDK should fetch products without hanging, as the manual request confirms that the API and permissions are configured correctly.
Actual Behavior:
The SDK hangs on GraphQL requests without returning any errors.
Additional Information:
It seems like the SDK isn’t properly sending or receiving requests, but no clear error is thrown.
The network request via URLSession works without any issues, so it’s likely related to the SDK’s internal handling of GraphQL requests.
Let me know if any additional information is needed.
Thanks.
I’m encountering an issue where GraphQL requests hang indefinitely when using the Shopify iOS Buy SDK (MobileBuySDK).
However, the same GraphQL queries work perfectly when sent via manual URLSession requests or cURL.
Steps to Reproduce:
SDK Setup:
Using Shopify’s Buy SDK (MobileBuySDK).
Correctly set up SHOPIFY_STORE_DOMAIN, SHOPIFY_API_TOKEN, and SHOPIFY_API_VERSION in Config.xcconfig and Info.plist.
Fetching Products via SDK:
Expected Result:
Products should be fetched and displayed.
Actual Result:
The SDK hangs, and no response is received.
Logs show:
Manual Request (Works as Expected): Sending the same GraphQL query via URLSession or cURL successfully fetches products.
Manual Swift Code:
Environment:
SDK Version: MobileBuySDK (Version 13.0)
Xcode Version: 12.4
iOS Deployment Target: 14.0
Shopify API Version: 2023-07
Device/Simulator: iPhone Simulator (iOS 14.4)
Troubleshooting Steps Taken:
Verified API credentials and permissions—manual requests work fine.
Removed /api/{version} from the shopDomain when initializing Graph.Client.
Added debug URL protocols to log network requests (no requests were leaving the SDK).
Updated/downgraded SDK versions, but the issue persists.
Expected Behavior:
The SDK should fetch products without hanging, as the manual request confirms that the API and permissions are configured correctly.
Actual Behavior:
The SDK hangs on GraphQL requests without returning any errors.
Additional Information:
It seems like the SDK isn’t properly sending or receiving requests, but no clear error is thrown.
The network request via URLSession works without any issues, so it’s likely related to the SDK’s internal handling of GraphQL requests.
Let me know if any additional information is needed.
Thanks.