【问题标题】:Graphql query constructing in python在 python 中构建 Graphql 查询
【发布时间】:2022-01-13 23:25:54
【问题描述】:
payload = """ query GetOrders($num_els: Int, $created_at: String, $cursor: String) {
              orders(first: $num_els, query: $created_at, after: $cursor) {
                edges {
                  node{
                    email
                  }
                }
              }
            }"""

我尝试发送一个简单的查询。 $cursor 字段可以为空。

variables = {'num_els': num_elements, 'created_at': f'created_at:>2022-01-10', 'cursor': None}
r = requests.post(constants['SHOPIFY_URL'], headers=headers,
                          json={'query': payload, 'variables': variables}).json()

但是这给了我

[{'message': 'Parse error on "query" (STRING) at [1, 2]', 'locations': [{'line': 1, 'column': 2}]}]

即使我用$created_at 放弃了有点复杂的部分,问题仍然存在。你有什么建议吗?

【问题讨论】:

    标签: python graphql shopify


    【解决方案1】:

    Content-Type 更改为application/json 的工作方式与here 相同

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-21
      • 2018-12-21
      • 2020-06-07
      • 2020-02-16
      • 1970-01-01
      • 2023-03-26
      • 2020-08-27
      相关资源
      最近更新 更多