shopify_draft_proxy/proxy/gift_cards
Mirrors src/proxy/gift-cards.ts.
Pass 19 ships the four query roots (giftCard, giftCards,
giftCardsCount, giftCardConfiguration) plus the seven mutation
roots (giftCardCreate/Update/Credit/Debit/Deactivate,
giftCardSendNotificationToCustomer/Recipient).
Gift cards never delete — giftCardDeactivate flips an enabled
flag and stamps deactivated_at instead. The store therefore tracks
gift_cards + gift_card_order only (no deleted-id set) and
stage_create_gift_card doubles as stageUpdateGiftCard.
Currency / decimal formatting follows the TS handler’s
formatDecimalAmount exactly: round to 2dp, then trim a single
trailing zero, but never below <int>.0. Negative debit amounts on
transactions are signed by the handler — the underlying balance
math uses unsigned magnitudes.
Types
Errors specific to the gift-cards handler.
pub type GiftCardsError {
ParseFailed(root_field.RootFieldError)
}
Constructors
-
ParseFailed(root_field.RootFieldError)
Outcome of a gift-cards mutation.
pub type MutationOutcome {
MutationOutcome(
data: json.Json,
store: store.Store,
identity: synthetic_identity.SyntheticIdentityRegistry,
staged_resource_ids: List(String),
log_drafts: List(mutation_helpers.LogDraft),
)
}
Constructors
-
MutationOutcome( data: json.Json, store: store.Store, identity: synthetic_identity.SyntheticIdentityRegistry, staged_resource_ids: List(String), log_drafts: List(mutation_helpers.LogDraft), )
User-error payload. Mirrors GiftCardUserErrorRecord (no code
field — gift-card user errors are field+message only).
pub type UserError {
UserError(field: List(String), message: String)
}
Constructors
-
UserError(field: List(String), message: String)
Values
pub fn handle_gift_card_query(
store: store.Store,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(json.Json, GiftCardsError)
Process a gift-cards query document and return a JSON data
envelope. Mirrors handleGiftCardQuery.
pub fn is_gift_card_mutation_root(name: String) -> Bool
Predicate matching GIFT_CARD_MUTATION_ROOTS.
pub fn is_gift_card_query_root(name: String) -> Bool
Predicate matching GIFT_CARD_QUERY_ROOTS.
pub fn process(
store: store.Store,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(json.Json, GiftCardsError)
Convenience: parse + handle + wrap, for the dispatcher.
pub fn process_mutation(
store: store.Store,
identity: synthetic_identity.SyntheticIdentityRegistry,
request_path: String,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(MutationOutcome, GiftCardsError)
Process a gift-cards mutation document.
pub fn process_mutation_with_upstream(
store: store.Store,
identity: synthetic_identity.SyntheticIdentityRegistry,
request_path: String,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
upstream: upstream_query.UpstreamContext,
) -> Result(MutationOutcome, GiftCardsError)
Pattern 2: update/credit/debit/deactivate and notification roots need the prior upstream gift-card record before they can stage or short-circuit local effects for an existing Shopify gift card. Snapshot mode/no transport falls back to the local-only not-found behavior; LiveHybrid parity installs a cassette for this narrow read.