shopify_draft_proxy/proxy/metafield_definitions
Stateful Gleam port of the metafields/metafield-definitions slice.
The module intentionally keeps the owner-scoped metafield model narrow: Product, ProductVariant, Collection, and Customer owner IDs are accepted for local metafield staging/reads; broader HasMetafields families stay unsupported until their owning domains have evidence and state.
Types
pub type MetafieldDefinitionsError {
ParseFailed(root_field.RootFieldError)
}
Constructors
-
ParseFailed(root_field.RootFieldError)
pub type MetafieldsSetUserError {
MetafieldsSetUserError(
field: List(String),
message: String,
code: option.Option(String),
element_index: option.Option(Int),
)
}
Constructors
-
MetafieldsSetUserError( field: List(String), message: String, code: option.Option(String), element_index: option.Option(Int), )
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), )
pub type UserError {
UserError(
field: option.Option(List(String)),
message: String,
code: String,
)
}
Constructors
-
UserError( field: option.Option(List(String)), message: String, code: String, )
Values
pub fn handle_metafield_definitions_query(
store: store.Store,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(json.Json, MetafieldDefinitionsError)
pub fn handle_query_request(
proxy: proxy_state.DraftProxy,
request: proxy_state.Request,
primary_root_field: String,
query: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> #(proxy_state.Response, proxy_state.DraftProxy)
Pattern 1: cold LiveHybrid definition catalog/detail reads are just upstream reads. Once a local lifecycle has staged or deleted definitions, keep reads local so read-after-write and read-after-delete behavior does not leak back to Shopify.
pub fn is_metafield_definitions_mutation_root(
name: String,
) -> Bool
pub fn is_metafield_definitions_query_root(name: String) -> Bool
pub fn local_has_metafield_definition_state(
proxy: proxy_state.DraftProxy,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Bool
True when the local metafield-definition model must answer reads instead of LiveHybrid passthrough: a lifecycle flow has staged or deleted definitions, or a variable carries a proxy-synthetic definition id.
pub fn process(
store: store.Store,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(json.Json, MetafieldDefinitionsError)
pub fn process_mutation(
store_in: store.Store,
identity: synthetic_identity.SyntheticIdentityRegistry,
request_path: String,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(MutationOutcome, MetafieldDefinitionsError)
pub fn process_mutation_with_upstream(
store_in: store.Store,
identity: synthetic_identity.SyntheticIdentityRegistry,
request_path: String,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
upstream: upstream_query.UpstreamContext,
) -> Result(MutationOutcome, MetafieldDefinitionsError)