Hello everyone!
I’m new to the Shopify GraphQL API. Currently, I’m trying to write tests using the library
@shopify/shopify-api
I’ve encountered some strange behavior.
For example:
- When I try to create a product with tags (one tag) and then request all products filtered by that tag, I get no results. Only after a while does the product appear in the response.
The same situation occurs when I update a product. Immediately after the update, when I request a list of products filtered by product ID, I receive no results. After a while, the product appears.
I researched this issue and found tools/apps for Shopify that can resync data more frequently than Shopify does by default.
Here’s my code examples:
await gqlClient.request(
`mutation CreateProduct($input: ProductInput!) {
productCreate(input: $input) {
userErrors {
field
message
}
}
}`,
{
variables: {
input: {
title: 'new test product',
tags: ['test'],
},
},
},
);
const products = await gqlClient.request(
`query ListProducts($query: String, $after: String, $before: String, $first: Int, $last: Int, $reverse: Boolean,
$sortKey: ProductSortKeys, $savedSearchId: ID) {
products(query: $query, after: $after, before: $before, first: $first, last: $last, reverse: $reverse, sortKey: $sortKey,
savedSearchId: $savedSearchId) {
edges {
node {
id,
productType,
title,
createdAt,
publishedAt,
}
}
pageInfo {
startCursor, endCursor, hasNextPage, hasPreviousPage
}
}
}
`,
{
variables: {
first: 10,
query: 'tag:"test"',
},
},
);