App reviews, troubleshooting, and recommendations
const getSegmentation = async (query) => {
try{
const response = await ShopifyData(query);
return response;
}catch(e){
return e;
}
};
router.get('/getgraphql',async (req,res,next) => {
const query =
`query {
segments(first: 10) {
nodes {
id
name
}
}
}`;
try{
const result = await getSegmentation(query);
res.json({result:result});
}catch(ex){
res.json({result:ex});
}
})
const ShopifyData = (query) => {
const URL = `https://${domain}/api/2022-07/graphql.json`
const options = {
endpoint: URL,
method: "POST",
headers: {
"X-Shopify-Storefront-Access-Token": storefrontAccessToken,
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ query })
}
return new Promise((resolve,reject) => {
fetch(URL, options).then(response => {
resolve(response.json());
}).catch(e => {
reject(e);
});
});
}
{
errors: [
{
message: "Field 'segments' doesn't exist on type 'QueryRoot'",
locations: [Array],
path: [Array],
extensions: [Object]
}
]
}
router.get('/getgraphql',async (req,res,next) => {
const query =
`query {
products(first: 10) {
nodes {
id
handle
}
}
}`;
try{
const result = await getSegmentation(query);
res.json({result:result});
}catch(ex){
res.json({result:ex});
}
})
4.The result of 3 is not an error
{ data: { products: { nodes: [Array] } } }
I've tried the same thing with Laravel, but
Exactly the same result.
Queries such as general products do not cause errors, and queries such as
segments results in an error.
I would like to get a list of the correct segments.
Does anyone know of a solution to this?
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025