On a Centra fashion storefront, shoppers pick a size on the product page and add the line to a session cart. Checkout can later offer click-and-collect, so the stack talks to Centra's Storefront API in two operating modes. Session mode covers cart, checkout, customer, and order calls tied to the shopper's session. NO_SESSION is Centra's catalog mode for product pages, listings, and store-finder style lookups without that session.
While I was wiring a pre-go-live load test on Centra QA and a load-test Centra, every add-to-cart and every session cart query failed with the literal GraphQL error you don't have access to this, always on path item.stockByWarehouse, Centra's warehouse-stock breakdown (how many units sit in each warehouse). It looks like a permissions bug. The schema description on that field says it only belongs in NO_SESSION, not in session cart traffic.
Toggle Session (cart) with warehouse-stock Spread on in the demo below and you should see the same error string on item.stockByWarehouse; flip to NO_SESSION (catalog) or turn Spread off and the panel returns a cart line or warehouse rows instead.
Interactive
Session cart vs catalog warehouse stock
Centra answers the same GraphQL field differently depending on whether the call runs with a shopper session.
you don't have access to this
path: item.stockByWarehouse
Schema note for Item.stockByWarehouse: Required operating mode: NO_SESSION
Session cart request failed on item.stockByWarehouse: you don't have access to this.
Why warehouse stock lived on a shared fragment
Warehouse stock, Centra's stockByWarehouse breakdown, lists how many units sit in each warehouse. Store pickup and find-in-store flows need those numbers when the API runs without a shopper session.
A fragment in our GraphQL documents is a named field bundle that operations spread with ...fragmentName. Anything inside a shared item fragment rides along on every operation that spreads it, including nested spreads inside the cart line fragment.
I had already split warehouse stock out of the shared item fragment once, into itemWarehouseStock, and limited that spread to catalog fragments that only run in NO_SESSION. Session cart lines kept ...item only. That should have kept session traffic away from stockByWarehouse.
How the field crept back onto cart lines
A later click-and-collect change needed warehouse quantities on cart lines so checkout could hide pickup stores whose stock fell at or below a stock buffer, a minimum quantity from Sanity checkout settings. The feature spread itemWarehouseStock inside line.item again. Catalog still needed the spread for product detail and find-in-store. Session cart and checkout started requesting the same field during add-to-cart.
Centra does not return a gentle null. It answers you don't have access to this when the request runs in another operating mode than the one the field documents. Same query text, same fragments, wrong mode.
What we shipped after the load test
I removed ...itemWarehouseStock from the session cart line fragment again and regenerated types. That unstuck add-to-cart on QA and the load-test Centra. I found it while preparing that pre-go-live load test, and it was a real storefront bug, not only a load-test issue. It would have blocked any session cart call that still spread the warehouse fragment.
Checkout click-and-collect no longer trims stores from cart-line warehouse rows, because those rows are not fetched in session mode anymore. Product pages and store finder still use NO_SESSION and still see warehouse stock. Checkout falls back to Centra fulfillment checks for pickup store lists, and the extra buffer pass only runs when lines already carry warehouse rows (which they do not after this fix).
Guard session operations against NO_SESSION-only fields
Splitting fragments helps until the next feature spreads the wrong bundle into a shared parent. I added a Vitest file that reads the checked-in Centra schema, walks every session query and mutation (plus nested fragment spreads), and collects fields whose description contains Centra's NO_SESSION marker. The list has to stay empty. Item.stockByWarehouse is asserted to carry that marker so the test cannot rot quietly.
Session operations in the walk include cart, checkout, customer, order, and session queries, plus mutations except the catalog lookups that Centra documents as NO_SESSION. The same rule now sits in package docs for storefront GraphQL work: session-shaped documents must not select fields the schema marks NO_SESSION only.
fragment item on Item {
id
name
}
fragment itemWarehouseStock on Item {
stockByWarehouse {
stock {
available
quantity
}
warehouseId
}
}
fragment line on Line {
item {
...item
}
}Catalog fragments can still spread both item and itemWarehouseStock. Cart line should spread item alone unless you have a no-session code path.
Next time Centra throws you don't have access to this on a field that exists in the schema, I read the operating mode in the description before I chase API keys.
Happy coding! Sander