This commit is contained in:
benbot 2023-10-25 03:58:10 -04:00
parent 6a258db47f
commit beaf92f7c4
22 changed files with 773 additions and 238 deletions

View file

@ -9,7 +9,7 @@ defmodule EzcontainerRailway.Application do
def start(_type, _args) do
children = [
EzcontainerRailwayWeb.Telemetry,
EzcontainerRailway.Repo,
# EzcontainerRailway.Repo,
{DNSCluster, query: Application.get_env(:ezcontainer_railway, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: EzcontainerRailway.PubSub},
# Start the Finch HTTP client for sending emails

View file

@ -0,0 +1,16 @@
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

View file

@ -0,0 +1,19 @@
defmodule EzcontainerRailway.Railway do
alias EzcontainerRailway.GraphqlClient
def get_projects(token) do
GraphqlClient.query(
"""
query {
projects {
edges {
node {
id
}
}
}
}
""",
token: token
)
end
end

View file

@ -1,5 +1,2 @@
defmodule EzcontainerRailway.Repo do
use Ecto.Repo,
otp_app: :ezcontainer_railway,
adapter: Ecto.Adapters.Postgres
end