Method: Github::GraphQL#initialize
- Defined in:
- lib/github/graphql.rb
#initialize(token, query, vars = nil) ⇒ GraphQL
Expects a valid Github OAuth token & the GraphQL query string, and optionally a hash array of any variables to be passed with the query.
With raise an ArgumentError if either token or query are nil.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/github/graphql.rb', line 20 def initialize(token, query, vars = nil) @payload = {} uri = URI.parse('https://api.github.com/graphql') @http = Net::HTTP.new(uri.host, uri.port) @http.use_ssl = true @request = Net::HTTP::Post.new(uri) @request['Content-type'] = 'application/json' token(token) payload(query, vars) end |