Shopify GraphQL使用swift没有得到响应



在Shopify商店前台grahpQL调用商店名称时出现问题

这是的代码

let client: Graph.Client = Graph.Client(shopDomain: shopDomain, apiKey: apiKey, locale: locale)
let query = Storefront.buildQuery { 
.shop { 
.name()
}

}
let task = client.queryGraphWith(query) { response, error in
if let response = response {
print(response);
}else {
print("Query failed: (error)")
}
}
task.resume()

但未获得成功响应

如果您的代码中缺少$符号,您可以在此处检查更新的代码https://github.com/skyclones/ShopifyMobileApp

let shopDomain = "YOUR STORE NAME"
let apiKey     = "YOUR STORE KEY"
let locale   = Locale(identifier: "en-US")
let client: Graph.Client = Graph.Client(shopDomain: shopDomain, apiKey: apiKey, locale: locale)
client.cachePolicy = .cacheFirst(expireIn: 3600)
let query = Storefront.buildQuery { $0
.shop { $0
.name()
}

}
let task = client.queryGraphWith(query) { response, error in
if let response = response {
print(response);
}else {
print("Query failed: (error)")
}
}
task.resume()

相关内容

  • 没有找到相关文章

最新更新