ezcontainer_example/lib/ezcontainer_railway/graphql_client.ex

17 lines
523 B
Elixir
Raw Normal View History

2023-10-25 03:58:10 -04:00
defmodule EzcontainerRailway.GraphqlClient do
@graphql_url "https://backboard.railway.app/graphql/v2"
@token "98237cc5-d503-4514-bb59-984d3403afe6"
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
{:error, _} -> :error
end
end
end