【问题标题】:Shopify GraphQL using swift not getting responseShopify GraphQL 使用 swift 没有得到响应
【发布时间】:2021-06-28 16:29:31
【问题描述】:

在 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()

但没有得到成功响应

【问题讨论】:

    标签: ios swift graphql shopify storefront


    【解决方案1】:

    您的代码中缺少 $ 符号,但您可以 在此处检查更新的代码 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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-22
      • 1970-01-01
      • 2023-01-19
      • 2023-02-23
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      相关资源
      最近更新 更多