API Idempotency for Payment Services
Building Resilient GraphQL APIs Using Idempotency - Shopify

Building Resilient GraphQL APIs Using Idempotency - Shopify

8/27/2019

What this post added

This post details the implementation of API idempotency within Shopify's new Payment Service to ensure transactional resilience. It introduces the concept of idempotency keys (UUIDs) as first-class API parameters, the use of locks based on client and idempotency key to prevent simultaneous duplicate requests, and the tracking of incoming requests via an 'IncomingRequest' model. A key contribution is the 'steps' or 'recovery points' strategy for structuring mutation handlers, partitioning code by side-effect type (no side effects, local, remote) to enable granular progress tracking and recovery. This allows for the resumption of operations from the point of failure, ensuring that even if an initial request fails, subsequent retries can safely complete the transaction. The post also discusses the trade-offs, such as increased database writes and a specific coding style, and emphasizes the importance of remembering side effects for successful recovery.

Read the original post ↗