27 lines
524 B
Ruby
27 lines
524 B
Ruby
require "http"
|
|
|
|
API_ENDPOINT = "https://demo.consulproject.org/graphql".freeze
|
|
|
|
def make_request(query_string)
|
|
HTTP.headers("User-Agent" => "Mozilla/5.0", accept: "application/json")
|
|
.get(
|
|
API_ENDPOINT,
|
|
params: { query: query_string.delete("\n").delete(" ") }
|
|
)
|
|
end
|
|
|
|
query = <<-GRAPHQL
|
|
{
|
|
proposal(id: 1) {
|
|
id,
|
|
title,
|
|
public_created_at
|
|
}
|
|
}
|
|
GRAPHQL
|
|
|
|
response = make_request(query)
|
|
|
|
puts "Response code: #{response.code}"
|
|
puts "Response body: #{response.body}"
|