View Source Appwrite.Services.GraphQL (appwrite v0.2.1)
The GraphQL service allows you to query and mutate your Appwrite server using the GraphQL protocol.
You can use GraphQL to interact with any service in your Appwrite project. The endpoint accepts a JSON object containing a GraphQL query string and an optional variables map.
Summary
Functions
@spec mutation(map()) :: {:ok, map()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Execute a GraphQL mutation.
Parameters
query(map()): The GraphQL mutation document as a map with the"query"key (required) and optionally"variables"and"operationName"keys.%{ "query" => "mutation CreateUser($email: String!) { createAccount(email: $email) { _id } }", "variables" => %{"email" => "user@example.com"} }
Returns
{:ok, map()}containing the GraphQL response data on success.{:error, AppwriteException.t()}on failure.
Examples
iex> Appwrite.Services.GraphQL.mutation(%{
...> "query" => "mutation { createAccount(email: \"user@example.com\", password: \"password\") { _id } }"
...> })
{:ok, %{"data" => %{"createAccount" => %{"_id" => "..."}}}}
@spec query(map()) :: {:ok, map()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Execute a GraphQL query.
Parameters
query(map()): The GraphQL query document as a map with the"query"key (required) and optionally"variables"and"operationName"keys.%{ "query" => "query GetUser($id: String!) { getAccount { _id name email } }", "variables" => %{"id" => "user123"} }
Returns
{:ok, map()}containing the GraphQL response data on success.{:error, AppwriteException.t()}on failure.
Examples
iex> Appwrite.Services.GraphQL.query(%{
...> "query" => "{ getAccount { _id name email } }"
...> })
{:ok, %{"data" => %{"getAccount" => %{"_id" => "...", "name" => "...", "email" => "..."}}}}