GraphQL with AWS AppSync: Building a Product AP...

GraphQL with AWS AppSync: Building a Product API at HEMA

How HEMA, the 100-year-old Dutch retailer, introduced GraphQL with AWS AppSync to build one Product Data Service that serves the webshop, in-store shelf labels, stock systems and more from a single API. Raw, honest lessons from the pioneer phase of GraphQL adoption during HEMA's move from a monolith to composable commerce.

Speakers:
Ivan Jančić, Solutions Architect @ Brighting
Bart Rijksen @ HEMA

API Standards Conference @ FOST Paris 2026
https://www.joinfost.io/events/paris

FOST, powered by apidays PRO

December 03, 2026

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

34 slides
  1. Who we are Ivan Jančić Bart Rijksen Involved from the

    start, shaping the concept behind HEMA’s product data service Built the GraphQL API behind the product data service, then drove GraphQL adoption across HEMA
  2. 2 BRIGHTING AT A GLANCE 20+ 2022 EMPLOYEES FOUNDING YEAR

    TEAM SETUP 20% >100% ANNUAL GROWTH 100% CLIENT RETENTION OFFICES NOV I SAD S ER BI A NON-ENGINEERING 80% SENIOR ENGINEERS A MSTE RD AM N E TH E R LA N DS
  3. About HEMA A Dutch high-street favourite since 1926, designing its

    own everyday products 100 755+ Millions years old in 2026 stores online orders a year FAMOUS FOR Rookworst Smoked sausage Tompouce Dutch mille-feuille Rompertjes Baby bodysuits
  4. HEMA 100: from a monolith to independent micro-frontends A multi-year

    migration across six markets, page by page, while the live platform keeps running BEFORE HEMA 100 hema.nl · hema.com one domain, each page served by its own team’s app One monolithic frontend All teams in one codebase, one shared release train Content My Account Live platform keeps running underneath First up: product data, which every page and channel depends on Catalog Checkout, later
  5. One product, many consumers Every channel needs a different slice

    of the same product data Webshop needs: descriptions and images In-store shelf labels needs: prices Stock systems needs: availability One tompouce How do you serve all of them, without building a new API for each?
  6. The Product Data Service The central service that provides product

    information across all HEMA channels Product Data Service General Info Sales Fulfillment Prices Consumers Stock Customer engagement In-store systems (ESL) Customer order history Webshop - PDP Up to this point, all APIs at HEMA were REST-based — this service was the starting point for GraphQL
  7. Why GraphQL at HEMA? The problem The solution Multiple REST

    calls to assemble product data Single GraphQL endpoint for product data Over-fetching across 4 different data sources Request exactly what you need New fields = new version, new endpoints Schema grows organically Different consumers need different product attributes Inversion of control
  8. Apollo vs AWS AppSync Apollo AWS AppSync Self-managed (ECS, EKS,

    Lambda) Fully managed GraphQL service Full Node.js runtime flexibility APPSYNC_JS runtime (limited) Custom middleware & plugins Native AWS integrations You own scaling & infrastructure Built-in caching Federation for microservices Federation exists but not so mature Complete control, more ops work Less control, less ops overhead
  9. AppSync Data Sources DynamoDB Lambda HTTP RDS NoSQL tables Custom

    logic REST / APIs SQL databases OpenSearch EventBridge None Full-text search Event routing Local resolvers PODS uses 4 DynamoDB tables as data sources ProductData, ProductSales, ProductFulfillment, ProductPrices
  10. Resolver Types Unit Resolver Pipeline Resolver Single data source per

    resolver Request Mapping Template Simple, one-to-one mapping Data Source Chain multiple functions sequentially Response Before Fn 1 Fn 2 Fn 3 Shared context via the stash object We use pipeline resolvers — chaining 4 functions to compose complete product data After
  11. Pipeline resolver • The before step preprocesses request data •

    Functions execute in order against data sources • Each function passes its result to the next • The after step finalizes the response to the client
  12. Pipeline Execution sequential vs parallel Current: Pipeline Resolver (sequential) getProductData

    getProductSales ~80ms ~60ms getProductFulfillment getProductPrices Alternative: Field Resolvers (parallel) general sales ~90ms ~70ms Total: ~300ms Shared stash between functions BatchGetItem within each function ~80ms ~60ms fulfillment prices ~90ms ~70ms Total: ~90ms (slowest resolver) Faster execution Resolvers scale independently Final response structure (since each resolver runs independently) Smart skipping via selectionSetList Total latency is the sum of all functions Context not shared between resolvers
  13. Resolver Runtimes VTL (Velocity Template Language) ## Request mapping template

    #set($ids = []) #foreach($id in $ctx.args.ids) #set($map = {}) $util.qr($map.put("id", $util.dynamodb .toDynamoDBJson($id))) $util.qr($ids.add($map)) #end { "version": "2018-05-29", "operation": "BatchGetItem", "tables": { "ProductData": { "keys": $util.toJson($ids) } } } Template language — simple logic, limited reusability, hard to debug & test APPSYNC_JS (JavaScript) // Request handler export function request(ctx) { const keys = ctx.args.ids .map(id => util.dynamodb.toMapValues( { id } )); return { operation: 'BatchGetItem', tables: { ProductData: { keys } } }; } Recommended — familiar syntax, testable, TypeScript support (write TypeScript code locally and transpile it to JavaScript), use the bundling tools (esbuild) to compile and bundle the code
  14. APPSYNC_JS Runtime Not your typical JavaScript runtime No async/await No

    npm packages No Promises, no async operations within resolvers Only built-in utilities from @aws-appsync/utils package Limited JS features 32KB code limit Subset of ES2015+, no try/catch, no classes Each resolver function max 32KB after bundling Execution timeout esbuild required 30 second max execution per resolver Bundle and transpile before deployment
  15. Things You'll Miss Most The most painful limitations when writing

    APPSYNC_JS resolvers try / catch / finally / throws async / await You can't gracefully handle runtime errors. Resolver fails with cryptic error if something throws. No async operations or Promises inside resolvers. Use util.error() and util.appendError() to surface errors in a controlled way Use pipeline functions to chain calls Unary operators In operator ++, –, ~ No way to check if a key exists in an object. Use i = i + 1 Object.hasOwn(propertyData, 'prices') continue, do-while, and while loops for(initialization; condition; afterthought) You can't skip iterations & complex filtering logic becomes painful. The traditional for loop doesn't work, which means losing the construct that gives you explicit control over index, bounds, and step. Restructure with .filter() and .map() chains, or use early return inside Use for...of for array iteration and map, filter, reduce, and forEach for transformations and aggregation
  16. Catching Issues Before Deployment Three layers of defense to prevent

    unsupported code from reaching AppSync ESLint Plugin Compliance Script Unit & Integration Tests @aws-appsync/eslint-plugin appsync-compliance-check jest Flags unsupported JS syntax and patterns at code-time with IDE integration Runs in CI pipeline and blocks deployment of non-compliant resolver code Validates resolver logic against mock data Earliest feedback loop Gate before deploy Catches logic errors What these catch Unsupported JavaScript syntax and language features Incorrect data source request/response mappings Resolver code that exceeds runtime limits Broken field resolution and schema mismatches
  17. Our Architecture KONG API Gateway API Management /omni-products/v1/graphql Pipeline resolvers:

    getProductData ProductData → getProductSales ProductSales → VPC Endpoint AWS AppSync Private connection Private API (VPC) getProductFulfillment ProductFulfillment → getProductPrices ProductPrices DynamoDB Tables CDK-managed • KONG routes external traffic to API Gateway • Private VPC endpoint connects API GW to AppSync Pipeline resolvers • APPSYNC_JS runtime
  18. Smart Querying & The Stash Query only what you need

    The stash pattern Each pipeline function checks the incoming GraphQL selection set. If a field wasn't requested, we skip that data source entirely. Pipeline functions share data via ctx.stash — e.g. getProductSales sets the locale, getProductPrices reads it. // Pipeline before-mapping const fields = ctx.info.selectionSetList; // getProductSales ctx.stash.countryCode = locale; // Skip sales if not in request if (!fields.includes('salesData')) { return { skip: true }; } // getProductPrices const cc = ctx.stash.countryCode; Supported locales Result: fewer DynamoDB reads, lower latency, lower cost nl_NL en_GB fr_BE fr_FR nl_BE de_DE
  19. Latency in Production ~90-330 ms (avg: 175.75 ms) What causes

    variability? Lambda-backed resolvers How to reduce it Use JS resolvers for direct data source access Subject to standard Lambda cold starts VPC-connected data sources Network interface provisioning adds latency Enable server-side caching with appropriate TTL Increase Lambda memory / use SnapStart Uncached data source calls Every request hits DynamoDB directly Configure MaxBatchSize to avoid N+1 Monitor with enhanced metrics AppSync is fully managed — no traditional cold starts. Variability comes from your architecture, not AppSync itself.
  20. Caching Strategies AppSync offers server-side caching with an in-memory managed

    cache (ElastiCache under the hood) Full Request Caching The entire API response is cached based on the full query string and variables. Per-Resolver Caching Each resolver caches its own result independently with custom TTL and custom cache keys — e.g. by SKU and locale. Operation-Level Caching Caches at the GraphQL operation level — the named query or mutation becomes the cache key along with its variables. our choice
  21. CloudWatch integration & monitoring General API Metrics 4xx and 5xx

    for tracking client and server errors, latency for measuring response times, requests for monitoring total API calls, and TokensConsumed for tracking resource usage. Request-level Logs Field-level Logs Bonus Overall request information, including HTTP headers, GraphQL queries, operation summaries, and subscription registrations. Information about individual field resolutions. - Request/response mapping. excludeVerboseContent retention fieldLogLevel - None - All - Error - Info - Debug Using a custom metric filter to get the useful errors out of all the noise (GraphQLFieldRuntimeError…)
  22. Developer Experience What works well What doesn’t spark joy CDK

    infrastructure as code Limitations of APPSYNC_JS runtime No operational overhead Local testing is painful & resolver debugging is limited Unified TypeScript stack Error messages often cryptic Built-in CloudWatch integration Requires careful orchestration and state management when passing data between functions
  23. AppSync vs Self-Hosted: Cost Comparison AppSync Peak traffic 3.5M Avg

    response size ~ 2KB Costs $14$/m $400 $300 Self-hosted Fargate + ALB 2 tasks x 1 vCPU × 2 GB Costs $106/m $200 CROSSOVER Dec Peak CROSSOVER POINT $100 ~27M $0 1M 3.5M 10M ~27M Monthly Requests AWS AppSync Self-hosted (Fargate + ALB) 50M 100M 7.5x cheaper at current traffic
  24. The Verdict - Pipeline resolvers & DynamoDB Pros Cons When

    to Use Fully managed, zero servers Limited JS runtime AWS-native stack Native AWS integrations Debugging is hard DynamoDB as primary DB Built-in caching Vendor lock-in Low traffic Pay per request Limited federation support Small team, less ops Learning curve Serverless architecture
  25. Going Live From 3.5 million to 350 million requests per

    month Before: 3.5M requests per month Now: 350M requests per month AWS AppSync AWS AppSync Pipeline resolvers 6 functions, run in sequence Lambda resolver Connects AppSync to OpenSearch DynamoDB 6 tables OpenSearch cluster 1 document per product Pipeline resolvers too inefficient at scale One document holds the entire product DynamoDB reads too expensive at scale Combining data from multiple tables Combining data from multiple tables Large cache absorbs the load
  26. Lessons Learned What going live at 100x the traffic taught

    us Per-request costs multiply at 100x traffic Six sequential pipeline functions and six DynamoDB reads per request worked at 3.5 million requests per month. At 350 million they were too slow and too expensive. Store the product the way it is read Instead of combining six tables on every request, we now serve one OpenSearch document per product. A Lambda resolver connects AppSync to it, since AppSync can't reach OpenSearch inside a VPC. Size the cache for peak load A small AppSync cache is a burstable instance that can run out of burst capacity. The AWS docs don't mention this. A large cache fixed it.
  27. Future: The HEMA Supergraph Connecting domain services into a single

    federated graph HEMA Supergraph today Product Data Sales Orders Fulfillment Customer Current AppSync API Order management Shipping & logistics Profiles & accounts How to federate with AppSync? AppSync Merged APIs Router-based Federation Build-time schema composition. Each team owns an AppSync source API; AWS merges them into a single endpoint. No gateway needed. Runtime query planning via Apollo Router or GraphQL Fusion. AppSync APIs act as subgraphs alongside non-AppSync services. All subgraphs must be AppSync Mix AppSync + non-AppSync subgraphs

More Decks by FOST, powered by apidays

Other Decks in Technology