All things Shopify and commerce
Hi!
I have scaffolded a shopify project using shopify-cli. I am trying to query dummy customers of my store using GraphQL API. I want to query customers with varying parameters - first time on page load (react front-end) and second time on a user action (when user clicks on filter button after filling out the fields acting as filters), the query is successful first time but the app gets crashed if I call the same API with different filter parameters and I don't even get back any response.
Moreover, the same query works fine in the GraphQL playground installed as a shopify application.
Here is the query:
query GetCustomers($first: Int!, $reverse: Boolean!, $query: String) {
customers(
first: $first
sortKey: TOTAL_SPENT
reverse: $reverse
query: $query
) {
edges {
node {
id
displayName
ordersCount
totalSpent
}
}
}
}
`;
I am using useLazyQuery imported from '
'
const [
getCustomers,
{
loading: customersLoading,
error: customersError,
data,
networkStatus,
refetch,
},
] = useLazyQuery(GET_CUSTOMERS, {
fetchPolicy: "no-cache",
});
Here is the first query call:
useEffect(() => {
getCustomers({
variables: {
first: 7,
reverse: reverse,
query: "",
},
});
}, [reverse]);
Here is the second query call when user clicks on the filter button:
getCustomers({
variables: {
first: 7,
reverse: reverse,
query: "orders_count: '1'",
},
});
And here is what happens on the above call:
Please do respond if anyone knows anything about this issue.
Thanks!
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover 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, 2025