ezcontainer_example/lib/ezcontainer_railway/graphql_client.ex

16 lines
476 B
Elixir
Raw Permalink Normal View History

2023-10-25 03:58:10 -04:00
defmodule EzcontainerRailway.GraphqlClient do
@graphql_url "https://backboard.railway.app/graphql/v2"
def query(query, opts) when is_binary(query) and is_list(opts) do
body = %{
"query" => query,
"variables" => opts[:variables]
}
case Req.Request.put_headers(Req.new(), [{"Authorization", "Bearer #{opts[:token]}"}]) |> Req.post(url: @graphql_url, json: body) do
{:ok, resp} -> resp
2023-10-25 04:48:36 -04:00
{:error, e} -> raise(e)
2023-10-25 03:58:10 -04:00
end
end
end