【发布时间】:2019-04-06 01:56:29
【问题描述】:
我看不到如何为 shopify 格式化这个石墨烯查询。我需要在 Django 中用石墨烯复制这个 curl 查询:
curl -X POST \
"https://<shop>.myshopify.com/api/graphql" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Storefront-Access-Token: <storefront-access-token>" \
-d '
{
shop {
collections(first: 5) {
edges {
node {
id
handle
}
}
pageInfo {
hasNextPage
}
}
}
}
'
到目前为止我有:
access_token = 'some_token'
headers = (
{ "Content-Type": "application/graphql" },
{ "X-Shopify-Storefront-Access-Token": access_token},
)
schema = graphene.Schema(query=Query)
print(schema)
result = schema.execute('{
catsinuniform {
collections(first: 5) {
edges {
node {
id
handle
}
}
pageInfo {
hasNextPage
}
}
}'')
print(result.data['catsinuniform'])
这种语法对于石墨烯来说是错误的,但我不明白它应该是什么样子?一旦我获得了正确格式的数据,我就可以发布请求以从 shopify storefrontapi 获取我想要的信息
【问题讨论】:
-
您是尝试创建graphql 请求,还是使用石墨烯复制shopify 上的数据结构?
-
我需要创建一个 graphql 请求,以便我可以访问 shopify 店面 api。如果我可以使用 python 发出请求,这个页面help.shopify.com/en/api/custom-storefronts/storefront-api/… 包含我需要的所有信息
标签: django graphql shopify-app