ExUtcp.Transports.Graphql.Connection (ex_utcp v0.3.2)

Copy Markdown View Source

Manages GraphQL connections with pooling and lifecycle management.

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the GraphQL connection.

Gets the last used timestamp.

Checks if the connection is healthy.

Introspects the GraphQL schema.

Starts a new GraphQL connection process.

Updates the last used timestamp.

Types

t()

@type t() :: %ExUtcp.Transports.Graphql.Connection{
  client: Req.Request.t(),
  connection_state: :connecting | :connected | :disconnected | :error,
  last_used: DateTime.t(),
  max_retries: non_neg_integer(),
  provider: map(),
  retry_count: non_neg_integer(),
  subscription_handles: %{required(String.t()) => pid()}
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid)

@spec close(pid()) :: :ok

Closes the GraphQL connection.

get_last_used(pid)

@spec get_last_used(pid()) :: integer()

Gets the last used timestamp.

healthy?(pid)

@spec healthy?(pid()) :: boolean()

Checks if the connection is healthy.

introspect_schema(pid, opts \\ [])

@spec introspect_schema(
  pid(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Introspects the GraphQL schema.

mutation(pid, mutation_string, variables \\ %{}, opts \\ [])

@spec mutation(pid(), String.t(), map(), keyword()) :: {:ok, map()} | {:error, term()}

Executes a GraphQL mutation.

query(pid, query_string, variables \\ %{}, opts \\ [])

@spec query(pid(), String.t(), map(), keyword()) :: {:ok, map()} | {:error, term()}

Executes a GraphQL query.

start_link(provider, opts \\ [])

@spec start_link(
  map(),
  keyword()
) :: {:ok, pid()} | {:error, term()}

Starts a new GraphQL connection process.

subscription(pid, subscription_string, variables \\ %{}, opts \\ [])

@spec subscription(pid(), String.t(), map(), keyword()) ::
  {:ok, [map()]} | {:error, term()}

Executes a GraphQL subscription.

update_last_used(pid)

@spec update_last_used(pid()) :: :ok

Updates the last used timestamp.