Class: GitHub::GraphQL::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/github/graphql/client.rb,
lib/github/graphql/client/version.rb

Defined Under Namespace

Classes: HTTP

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Constructor Details

#initialize(token:) ⇒ Client

Returns a new instance of Client.



21
22
23
24
25
26
27
# File 'lib/github/graphql/client.rb', line 21

def initialize(token: )
  http   = ::GitHub::GraphQL::Client::HTTP.new(token)
  schema = ::GraphQL::Client.load_schema(http)

  @client = ::GraphQL::Client.new(schema: schema, execute: http)
  @client.allow_dynamic_queries = true
end

Instance Method Details

#query(query_string) ⇒ Object



29
30
31
32
33
# File 'lib/github/graphql/client.rb', line 29

def query(query_string)
  query  = @client.parse(query_string)
  result = @client.query(query)
  result.data
end