Understanding Dynamic Complexity Costs in productCreate and productUpdate Mutations

Understanding Dynamic Complexity Costs in productCreate and productUpdate Mutations

Shopify Updates: 

Overview of Dynamic Complexity Costs

The productCreate and productUpdate mutations have been upgraded to use dynamic complexity costing. This change ensures computational costs are more accurately aligned with the operations being performed.

What’s Changing?

With the introduction of Dynamic Complexity, key changes include:

  • A base cost of 10 points for productCreate and productUpdate mutations.
  • Additional points calculated based on the complexity of the input:
  • Base cost: 10 points
  • Per product metafield: 0.4 points
  • Per product media: 1.9 points

The total complexity is calculated using this formula:

Total Complexity = 10 + (product_metafields × 0.4) + (product_media × 1.9)

Migration Guidance

Most apps require no changes. However, for apps dealing with highly complex products that exceed the 1000-point single query limit, consider the following:

  • Use bulk mutations: Opt for bulk operations when handling very large product datasets to remain within complexity limits.
  • Split operations: Execute complex actions in separate calls. For instance, use the productCreate and productUpdate mutations for essential product data, followed by metafieldsSet and fileCreate mutations for extended data fields.

Best Practices

Here are a few tips to optimize your usage of these mutations:

  • Regularly monitor complexity points to avoid exceeding thresholds.
  • Break down operations into manageable steps for smoother performance.
  • Leverage Shopify’s bulk mutation capabilities for batch processing.
Back to blog