Bsdkrun.GraphQL (bsdkrun_ex v0.3.1)

Copy Markdown View Source

The HTTP transport for Bsdkrun.Client: one POST per query or mutation, over Erlang's built-in :httpc (part of :inets — no hex dependency).

Mirrors web/src/lib/graphql.ts's gql(): same headers (content-type: application/json, authorization: Bearer <token>), same body shape ({"query": ..., "variables": ...}), and the same error semantics — a 401 or a GraphQL error with extensions.code == "UNAUTHENTICATED" is an auth failure (Bsdkrun.Error with kind: :auth_error); anything else that goes wrong (unreachable daemon, a non-JSON response, any other GraphQL error) is kind: :graphql_error.

Summary

Functions

POST query/variables as a GraphQL request to url, authenticated with the bearer token. Returns {:ok, data} — the decoded data field of the response — or {:error, %Bsdkrun.Error{}}.

Functions

request(url, token, query, variables \\ %{})

@spec request(String.t(), String.t(), String.t(), map()) ::
  {:ok, term()} | {:error, Bsdkrun.Error.t()}

POST query/variables as a GraphQL request to url, authenticated with the bearer token. Returns {:ok, data} — the decoded data field of the response — or {:error, %Bsdkrun.Error{}}.