The result of a TypeQL query.
TypeDB answers come in three shapes, and the driver gives each its own struct so you can pattern match on the one you expect:
TypeDB.Answer.Ok— the query produced no answers.define,undefine, and writes whose results were not requested.TypeDB.Answer.ConceptRows— amatch/insert/updatepipeline. Each row binds query variables to concepts.TypeDB.Answer.ConceptDocuments— afetchpipeline. Each document is plain decoded JSON, shaped by the query itself.
Every answer carries query_type (:read, :write or :schema), which is
what TypeDB determined the query to be — not what you asked for.
query = "match $p isa person; select $p;"
case TypeDB.query!(conn, "social", query, transaction_type: :read) do
%TypeDB.Answer.ConceptRows{rows: rows} -> length(rows)
%TypeDB.Answer.Ok{} -> 0
endConceptRows and ConceptDocuments are Enumerable, so they can be piped
straight into Enum and Stream. Select an attribute if you want values —
typed_value/2 on an entity answers nil, because an entity is a thing with
an identity rather than a value:
conn
|> TypeDB.query!("social", "match $p isa person, has name $name; select $name;",
transaction_type: :read)
|> Enum.map(&TypeDB.ConceptRow.typed_value(&1, "name"))
#=> ["Alice", "Bob"]
Summary
Functions
Returns the documents of a ConceptDocuments answer, or [] for any other.
Returns the query type TypeDB classified this query as.
Returns the rows of a ConceptRows answer, or [] for any other answer.
Returns the server-side warning attached to an answer, if any.
Types
@type query_type() :: :read | :write | :schema
What TypeDB classified the query as.
@type t() :: TypeDB.Answer.Ok.t() | TypeDB.Answer.ConceptRows.t() | TypeDB.Answer.ConceptDocuments.t()
Functions
Returns the documents of a ConceptDocuments answer, or [] for any other.
@spec query_type(t()) :: query_type()
Returns the query type TypeDB classified this query as.
@spec rows(t()) :: [TypeDB.ConceptRow.t()]
Returns the rows of a ConceptRows answer, or [] for any other answer.
Returns the server-side warning attached to an answer, if any.
A read that returns exactly 10,000 rows has probably been truncated. That
is TypeDB's own default cap on a read over the HTTP API, and it is not an
error: the answer arrives with the rows it did produce and this warning
attached. Raise it — or lower it — with :answer_count_limit, per query or
per connection.
{:ok, answer} = TypeDB.query(conn, "social", "match $p isa person;",
transaction_type: :read, answer_count_limit: 50_000)
case TypeDB.Answer.warning(answer) do
nil -> :ok
warning -> Logger.warning("partial answer: " <> warning)
endThe driver logs the warning for you at :warning level, so a truncated answer
is never silent — but a log line is not a decision, and only you know whether
a partial answer is one your code can use.