Hey,
I am trying to Fetch product details with the Graphql Admin API from my embedded app when a button click happens.
On my Server I am using Koa-shopify-graphql-proxy as middleware as per this tutorial.
Server.js
const { default: graphQLProxy } = require('@shopify/koa-shopify-graphql-proxy');
const { ApiVersion } = require('@shopify/koa-shopify-graphql-proxy');
app.prepare().then(() => {
...
server.use(graphQLProxy({ version: ApiVersion.July19 }));
...
}
I am calling fetch as suggested here for client script ā https://github.com/Shopify/quilt/tree/master/packages/koa-shopify-graphql-proxy
As per my understanding, with this I can make a call from client and Koa-shopify-graphql-proxy will handle all the authentication on its end and should return the data.
Component.js
const GET_PRODUCT = gql`
query {
product (id: "gid://shopify/Product/#######"){
title
id
description
onlineStoreUrl
}
}
`;
handleProductSelection = (selectPayload) => {
....
fetch('/graphql', {method: 'POST' ,credentials: 'include', body: GET_PRODUCT})
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(JSON.stringify(myJson));
});
....
}
I am getting the following error when I run this.
Component.js: POST https://#####.ngrok.io/graphql 400 (Bad Request)
Component.js: {"errors":{"query":"Required parameter missing or invalid"}}
In the docs of Koa-shopify-graphql-proxy they donāt write āmethod: POSTā. If I remove then I get an error that canāt send ābodyā in GET/HEAD request.
What is the issue here?
- Query?
- How the fetch is composed? Or should I use some other fetch like isomorphic?
- My app is a sales channel app, is there something related to that?
Appreciate any help here guys.

