ADR-00006 — GraphQL for the Mobile Storefront API, REST for Admin

By Engineering Team•September 26, 2026•5 min read
  • Status: Approved / Implemented
  • Date: 2026-09-26
  • Authors: Engineering Team

Context

shop-service serves two structurally different clients from the same tenant-configuration data. ui-admin-application edits fixed-shape resources — a screen’s ordered section list, a banner record, a category group’s mapped IDs — through ordinary CRUD operations (BRD-005/SR-005’s 3-step wizard). ui-application (the Flutter shopper app) instead needs one screen render (Shop, Search, or Product Detail) to come back as a single response containing a per-tenant-variable mix of up to 13 structurally different section shapes, decided by that tenant’s own screens/banners/category_mappings configuration — and it needs to ask for only the section shapes relevant to the screen it’s currently rendering, not fetch all 13 every time.


Decision Drivers (FRs & NFRs)

See SR-005 and Architecture-00005 for the full detail.

  • FR-02/FR-03 (Section Ordering & Read): The set and order of sections a given tenant’s Shop screen returns is per-tenant and reconfigurable at any time — the client-facing response shape isn’t fixed across tenants.
  • FR-12 (Shopper-App Delivery): The mobile client must be able to request exactly the section shapes it needs for the screen it’s rendering, in one round trip, rather than calling one endpoint per possible section type or fetching a large fixed envelope with unused fields.
  • NFR-02 (Auth Enforcement): Every admin mutation must sit behind the same AuthMiddleware/no-store contract every other REST admin surface in this platform uses — the admin side has no requirement that would benefit from GraphQL’s client-shaped querying.

Options Evaluated

Option 1 — GraphQL for the mobile client, REST for the admin client, same service (CHOSEN)

shop-service exposes a gqlgen GraphQL endpoint (getShopSections returning the ShopSection union, searchProducts) to ui-application, and REST endpoints (mobile-app-config, category-mapping) to ui-admin-application — two transports, one service, split by which client actually benefits from which shape.

  • Pros:
    • The Flutter client requests only the section fragments it needs per screen type in a single query — the per-tenant-variable section mix lives in one GraphQL union type instead of forcing either N REST endpoints (one per SectionType) that the client would have to call and aggregate itself, or one large fixed-shape REST response with mostly-null fields for any given tenant’s actual active sections.
    • The admin UI keeps the fixed-shape CRUD pattern that matches its own workflow (edit a screen’s section list, edit a banner record, edit a category group) and this platform’s established REST-admin convention (per the layered architecture standard’s template selection matrix) — nothing about admin editing benefits from GraphQL’s client-shaped querying.
    • Both clients are served by the same service and the same underlying MongoDB collections — no data duplication or synchronization between a “GraphQL read model” and a “REST write model.”
  • Cons & Accepted Trade-offs:
    • Two transport layers to maintain in one service, rather than a single uniform API style.
    • GraphQL’s payload-shaping benefit isn’t fully realized today — the mobile client’s queries use inline union-type conditions with repeated field lists rather than reusable named fragments, so some of the intended reduction in duplicated query text doesn’t materialize yet. Tracked as a gap, see Technical Debt — Mobile App Storefront Configuration Gaps, TD-02.

Option 2 — REST for both admin and mobile

Either one REST endpoint per SectionType, or a single “get shop screen” REST endpoint returning every possible section’s fields in one large envelope.

  • Pros:
    • One transport style across the whole service.
  • Cons (Why Rejected):
    • Per-endpoint: the Flutter client would need to call up to 13 endpoints and aggregate/order the results itself — the server-side aggregation and tenant-driven ordering shop-service already owns would move onto the client.
    • Single-envelope: the response would carry a large, mostly-null payload for any tenant whose configuration activates only a handful of the 13 possible sections, and every schema change to any one section type would touch one shared response shape used by every screen.

Option 3 — GraphQL for both admin and mobile

A single GraphQL schema serving both ui-admin-application and ui-application.

  • Pros:
    • One transport style, one schema, for the whole service.
  • Cons (Why Rejected):
    • Admin editing is fixed-shape CRUD against known resources (a screen’s sections, a banner, a category group) — GraphQL’s benefit (a client shaping a variable/union query) doesn’t apply here, and every other admin surface in this platform is REST; adopting GraphQL for this one admin API alone would be a one-off deviation from the template selection matrix with no corresponding requirement driving it.

Final Decision

Option 1 is selected. GraphQL is the right fit specifically for the mobile client’s actual problem — a per-tenant-variable, per-screen-type response shape assembled from up to 13 section types — while the admin client’s fixed-shape CRUD workflow is better served by the platform’s standard REST-admin convention. Splitting by client need, in the same service, avoids forcing either client onto a transport mismatched to how it actually uses the API.