Skip to content

Instantly share code, notes, and snippets.

@pocke
Created March 19, 2020 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocke/bb25e74e9b89df91296e2ce091dddb02 to your computer and use it in GitHub Desktop.
Save pocke/bb25e74e9b89df91296e2ce091dddb02 to your computer and use it in GitHub Desktop.
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