shopify_draft_proxy/proxy/segments
Mirrors the core slice of src/proxy/segments.ts.
Pass 20 ships the three “owned” query roots (segment, segments,
segmentsCount) and the three core mutations
(segmentCreate / segmentUpdate / segmentDelete). Customer-
segment-membership surfaces (customerSegmentMembers,
customerSegmentMembersQuery, customerSegmentMembership,
customerSegmentMembersQueryCreate) and upstream-hybrid surfaces
(segmentFilters, segmentFilterSuggestions, segmentValueSuggestions,
segmentMigrations) are deferred — they require a CustomerRecord
store slice and an upstream-hybrid plumbing path that haven’t ported
yet.
Query validation matches the TS regex set in
validateSegmentQueryString: number_of_orders comparators,
customer_tags CONTAINS, email_subscription_status =, plus the
canned error path. Failures share the 'segment-mutation' mode so
messages are prefixed with Query.
Types
Outcome of a segments 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), )
Errors specific to the segments handler.
pub type SegmentsError {
ParseFailed(root_field.RootFieldError)
}
Constructors
-
ParseFailed(root_field.RootFieldError)
User-error payload. Mirrors SegmentUserError (field+message only).
pub type UserError {
UserError(field: List(String), message: String)
}
Constructors
-
UserError(field: List(String), message: String)
Values
pub fn handle_segments_query(
store: store.Store,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(json.Json, SegmentsError)
Process a segments query document and return a JSON data envelope.
pub fn is_segment_mutation_root(name: String) -> Bool
Predicate matching the supported subset of SEGMENT_MUTATION_ROOTS.
pub fn is_segment_query_root(name: String) -> Bool
Predicate matching the supported subset of SEGMENT_QUERY_ROOTS.
Customer-membership and upstream-hybrid roots aren’t implemented yet
and are intentionally excluded — the dispatcher must not delegate
those to this module.
pub fn normalize_segment_name(name: String) -> String
Trim whitespace from a segment name. Mirrors normalizeSegmentName.
pub fn process(
store: store.Store,
document: String,
variables: dict.Dict(String, root_field.ResolvedValue),
) -> Result(json.Json, SegmentsError)
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, SegmentsError)
Process a segments mutation document.
pub fn resolve_unique_segment_name(
store: store.Store,
requested: String,
current_id: option.Option(String),
) -> String
Resolve a segment name against existing names, appending “ (N)“ until
a free slot is found. Mirrors resolveUniqueSegmentName. The
current_id argument lets segmentUpdate keep its existing name
without colliding with itself.
pub fn validate_segment_query(
raw: option.Option(String),
field_path: List(String),
) -> List(UserError)
Validate a segment query string. Mirrors validateSegmentQuery +
validateSegmentQueryString in segment-mutation mode.