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

Copy Markdown View Source

Testable version of the GraphQL transport that allows injecting mock modules.

Summary

Functions

call_tool(transport, tool_name, args, provider)

@spec call_tool(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  String.t(),
  map(),
  map()
) :: {:ok, map()} | {:error, term()}

call_tool_stream(transport, tool_name, args, provider)

@spec call_tool_stream(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  String.t(),
  map(),
  map()
) :: {:ok, map()} | {:error, term()}

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(transport)

deregister_tool_provider(transport, provider)

@spec deregister_tool_provider(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  map()
) :: :ok | {:error, term()}

introspect_schema(transport, provider, opts \\ [])

@spec introspect_schema(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  map(),
  keyword()
) :: {:ok, map()} | {:error, term()}

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

@spec mutation(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  map(),
  String.t(),
  map(),
  keyword()
) :: {:ok, map()} | {:error, term()}

new(opts \\ [])

@spec new(keyword()) :: %ExUtcp.Transports.Graphql.Testable{
  connection_module: module(),
  connection_timeout: non_neg_integer(),
  genserver_module: module(),
  logger: function(),
  max_retries: non_neg_integer(),
  pool_opts: keyword(),
  retry_config: map(),
  retry_delay: non_neg_integer()
}

Creates a new testable GraphQL transport.

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

@spec query(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  map(),
  String.t(),
  map(),
  keyword()
) :: {:ok, map()} | {:error, term()}

register_tool_provider(transport, provider)

@spec register_tool_provider(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  map()
) :: {:ok, [map()]} | {:error, term()}

Overloaded public functions that accept a transport struct as the first argument to allow direct manipulation of the transport state in tests.

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

@spec subscription(
  %ExUtcp.Transports.Graphql.Testable{
    connection_module: term(),
    connection_timeout: term(),
    genserver_module: term(),
    logger: term(),
    max_retries: term(),
    pool_opts: term(),
    retry_config: term(),
    retry_delay: term()
  },
  map(),
  String.t(),
  map(),
  keyword()
) :: {:ok, [map()]} | {:error, term()}