Created
March 19, 2020 04:02
-
-
Save pocke/bb25e74e9b89df91296e2ce091dddb02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'json' | |
TEAM = ENV['TEAM'] or raise 'TEAM env is required' | |
TOKEN = ENV['KIBELA_ACCESS_TOKEN'] or raise 'KIBELA_ACCESS_TOKEN env is required' | |
def req(query) | |
http = Net::HTTP.new("#{TEAM}.kibe.la", 443) | |
http.use_ssl = true | |
header = { | |
"Authorization" => "Bearer #{TOKEN}", | |
'Content-Type' => 'application/json', | |
'User-Agent' => 'Kibela API tester', | |
} | |
resp = http.request_post('/api/v1', JSON.generate(query), header) | |
JSON.parse(resp.body, symbolize_names: true).tap do |content| | |
raise content[:errors].inspect if content[:errors] | |
end | |
end | |
pp req({ | |
query: <<~GRAPHQL | |
// Write query here! | |
GRAPHQL | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment