Shopify product creating delay

ipashkevich
New Member
1 0 1

Hello guys,

I am having problems with creating the product via GraphQL API. 

I'm a developer, my team has a backend in AWS that communicates with Shopify GraphQL API.

We faced this problem:

  1. We have the script that triggers when we add new record to our "table with products" in AWS
  2. Script makes "filter query" to Shopify to check that product doesn't exist in Shopify already
  3. If it doesn't exist, script creates a new product in Shopify
  4. After that script has some more actions
  5. And if script fails for some reason on this subsequent actions, it retries immediately (we need this logic on our backend)
  6. Script starts from the begging, checks that product doesn't exist in Shopify
  7. Shopify should return the response with product that was created in step (3), but the response from Shopify has no any products
  8. Our script creates the same product
  9. If it fails on one of the next actions, it will retry again and create the same product another time

    And in the worst scenario it can be repeated 8 times!!

It seems like there is quite big delay between product was created and product will appear in get queries. I tried to simulate this manually and yes, there is delay, about 30 seconds.

 

This is example of creation request:

mutation productCreate($input: ProductInput!) {
  productCreate(input: $input) {
    product {
      id
      variants(first:1) {
        edges {
            node {
                id
            }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

and creation variables:

{
  "input": {
      "title": "Some title",
      "descriptionHtml": "Some description",
      "collectionsToJoin": [
          "gid://shopify/Collection/12345"
      ],
      "variants": [
          {
              "sku": "SOME_SKU",
              "price": 5.99,
              "taxCode": "P0000000",
              "weight": 2,
              "weightUnit": "GRAMS",
              "fulfillmentServiceId": "gid://shopify/FulfillmentService/some-fulfillment-service"
          }
      ],
      "status": "DRAFT",
      "vendor": "Some vendor"
  }
}

 

API returns us 200 OK and ID's of new product and variant that were created

and here is the example of query request:

query productVariants ($sku: String!){
    productVariants(first: 1, query: $sku) {
        edges{
            node {
                id
            }
        }
    }
}


and query variables:

{
    "sku": "SOME_SKU"
}

 

What we expect from Shopify to return to us:

{
    "data": {
        "productVariants": {
            "edges": [
                {
                    "node": {
                        "id": "gid://shopify/ProductVariant/12345"
                    }
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 3,
            "actualQueryCost": 3,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1997,
                "restoreRate": 100.0
            }
        }
    }
}

 

and what we really get at first 30 seconds:

{
    "data": {
        "productVariants": {
            "edges": []
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 3,
            "actualQueryCost": 2,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1998,
                "restoreRate": 100.0
            }
        }
    }
}

 

and only after ~30 seconds we will get the response that we expect (as I mentioned above)

 

And after all this detailed issue description (maybe too much detailed), my main question is: Where does that delay come from and how to prevent that?

Replies 0 (0)