shopify_draft_proxy/shopify/upstream_client
Shared upstream HTTP client used by both commit.run_commit_* and
the live-hybrid dispatch path. Mirrors the relevant parts of
src/shopify/upstream-request.ts plus the small fetch/httpc shims
that previously lived inside commit.gleam and draft_proxy.gleam.
The transport-level result shapes (HttpOutcome, CommitTransportError)
remain owned by commit.gleam so existing tests / consumers don’t
churn — this module imports and reuses them. The CommitTransportError
name is a historical accident; treat it as a generic upstream-transport
error.
Types
JS-only async transport. Wraps send_async (or any other Promise-
returning shim).
pub type AsyncTransport {
AsyncTransport(
send: fn(request.Request(String)) -> promise.Promise(
Result(commit.HttpOutcome, commit.CommitTransportError),
),
)
}
Constructors
-
AsyncTransport( send: fn(request.Request(String)) -> promise.Promise( Result(commit.HttpOutcome, commit.CommitTransportError), ), )
Synchronous transport. Cassettes implement this directly; on Erlang production HTTP also fits this shape.
pub type SyncTransport {
SyncTransport(
send: fn(request.Request(String)) -> Result(
commit.HttpOutcome,
commit.CommitTransportError,
),
)
}
Constructors
-
SyncTransport( send: fn(request.Request(String)) -> Result( commit.HttpOutcome, commit.CommitTransportError, ), )
Values
pub fn build_graphql_request(
origin: String,
path: String,
body: String,
inbound_headers: dict.Dict(String, String),
) -> Result(request.Request(String), Nil)
Build a POST request to origin <> path carrying body, with the
inbound proxy headers forwarded through commit.forward_headers/1.
Returns Error(Nil) only when the URL is unparseable (config bug).
pub fn send_async(
req: request.Request(String),
) -> promise.Promise(
Result(commit.HttpOutcome, commit.CommitTransportError),
)