Api Nuxt Apollo Shopify Graphql

Api Nuxt Apollo Shopify Graphql,api,graphql,shopify,apollo,nuxt.js,Api,Graphql,Shopify,Apollo,Nuxt.js,所以我用的是 我正在尝试将其设置为连接到我的shopify graphql API 在nuxt.config.js上: apollo: { clientConfigs: { default: { httpEndpoint: 'https://my-store.myshopify.com/admin/api/2020-01/graphql.json', getAuth: () => 'Bearer 26cfd63bbba75243b55

所以我用的是 我正在尝试将其设置为连接到我的shopify graphql API

在nuxt.config.js上:

  apollo: {
    clientConfigs: {
      default: {
        httpEndpoint: 'https://my-store.myshopify.com/admin/api/2020-01/graphql.json',
        getAuth: () => 'Bearer 26cfd63bbba75243b55fad2c8de0a12f'
      },
    }
  },
在index.vue上,我有以下内容:

  <script>
    import gql from 'graphql-tag'

    export default {
      apollo: {
        data: {
          query: gql`
            query {
              shop {
                name
              }
            }
          `,
        }
      }
    }
  </script>

从“graphql标记”导入gql
导出默认值{
阿波罗:{
数据:{
查询:gql`
质疑{
商店{
名称
}
}
`,
}
}
}
  • 这是正确的设置吗
  • 我似乎收到了cors策略错误。我认为这与Shopify需要的缺少标题有关:
    • 如何将“X-Shopify-Access-Token”添加到设置中
任何帮助都将不胜感激


谢谢

这就是我们在Nuxt配置中的工作方式

    apollo: {
        clientConfigs: {
            default: {
                httpEndpoint:
                    "http://api.another-backend-example.com/graphql",
                persisting: false
            },
            shopify: {
                httpEndpoint:
                    "https://my-store.myshopify.com/api/2019-07/graphql.json",
                httpLinkOptions: {
                    headers: {
                        "Content-Type": "application/json",
                        "X-Shopify-Storefront-Access-Token":
                            "123456789abcdefghi"
                    }
                },
                persisting: false
            }
        }
    }

我们还为Nuxt构建了许多有用的Shopify组件,也许这对您有所帮助:

这就是我们在Nuxt配置中使用它的方式

    apollo: {
        clientConfigs: {
            default: {
                httpEndpoint:
                    "http://api.another-backend-example.com/graphql",
                persisting: false
            },
            shopify: {
                httpEndpoint:
                    "https://my-store.myshopify.com/api/2019-07/graphql.json",
                httpLinkOptions: {
                    headers: {
                        "Content-Type": "application/json",
                        "X-Shopify-Storefront-Access-Token":
                            "123456789abcdefghi"
                    }
                },
                persisting: false
            }
        }
    }

我们还为Nuxt构建了许多有用的Shopify组件,也许这对您有帮助:

我的答案有帮助吗?有什么遗漏吗?我的回答有用吗?有什么东西不见了吗?谢谢你!这帮了大忙。我也看过你的git回购协议。这将有助于我完成网站的其余部分。谢谢,谢谢你!这帮了大忙。我也看过你的git回购协议。这将有助于我完成网站的其余部分。谢谢