shopify_draft_proxy/proxy/capabilities

Mirrors src/proxy/capabilities.ts.

Given a parsed operation and a (already-loaded) operation registry, resolve the capability — domain + execution mode + a normalised operation name. The TS version caches a Map of match-name → entry at module load. We don’t bother: lookup walks the implemented subset of the registry, which is small. Callers that want to amortise can wrap this themselves.

Types

Mirrors the TS OperationCapability interface. operation_name is the chosen candidate name (root field or operation name) when the lookup matched, or the operation’s declared name / first root field in the fallback.

pub type OperationCapability {
  OperationCapability(
    type_: parse_operation.GraphQLOperationType,
    operation_name: option.Option(String),
    domain: operation_registry.CapabilityDomain,
    execution: operation_registry.CapabilityExecution,
  )
}

Constructors

Values

pub fn get_operation_capability(
  operation: parse_operation.ParsedOperation,
  registry: List(operation_registry.RegistryEntry),
) -> OperationCapability

Mirrors getOperationCapability. Resolution order:

  1. First root field whose match-name matches an implemented entry of the right type.
  2. Otherwise, first candidate (root fields, then operation name) that matches.
  3. Otherwise, fall back to unknown / passthrough and surface the operation name (or first root field) verbatim.

The TS additionally re-derives operationNameEntry to prefer the operation’s declared name over the matched root field iff both resolve to the same registry entry. We replicate that.

Search Document