Shopify.GraphQL (shopify_graphql v2.1.0)
Link to this section Summary
Functions
Add a variable to the operation.
Add variables to the operation.
Send a GraphQL operation to Shopify.
Link to this section Types
Link to this type
http_headers_t()
Link to this type
http_method_t()
@type http_method_t() :: :delete | :get | :head | :patch | :post | :put
Link to this type
http_response_t()
@type http_response_t() :: {:ok, Shopify.GraphQL.Response.t()} | {:error, Shopify.GraphQL.Response.t() | any()}
Link to this type
http_status_code_t()
@type http_status_code_t() :: pos_integer()
Link to this section Functions
Link to this function
put_variable(operation_or_query, name, value)
@spec put_variable(binary() | Shopify.GraphQL.Operation.t(), binary() | atom(), any()) :: Shopify.GraphQL.Operation.t()
Add a variable to the operation.
It's possible to pass either a Shopify.GraphQL.Operation
struct or, as a
convenience, a binary query.
Link to this function
put_variables(operation_or_query, map)
@spec put_variables(binary() | Shopify.GraphQL.Operation.t(), map()) :: Shopify.GraphQL.Operation.t()
Add variables to the operation.
It's possible to pass either a Shopify.GraphQL.Operation
struct or, as a
convenience, a binary query.
Link to this function
send(query, config)
@spec send(String.t() | Shopify.GraphQL.Operation.t(), Keyword.t()) :: http_response_t()
Send a GraphQL operation to Shopify.
It's possible to send either a Shopify.GraphQL.Operation
struct or, as a
convenience, a binary query.
query =
"""
{
shop {
name
}
}
"""
operation = %Shopify.GraphQL.Operation{ query: query }
Shopify.GraphQL.send(operation)
or
query =
"""
{
shop {
name
}
}
"""
Shopify.GraphQL.send(query)
You must also pass configuration as a keyword list to the second argument. This allows you to use different config values on a per-request basis.