Class: GnListResolver::GnGraphQL

Inherits:
Object
  • Object
show all
Defined in:
lib/gn_list_resolver/graphql.rb

Overview

GraphQL client for gnindex API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGnGraphQL



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gn_list_resolver/graphql.rb', line 8

def initialize
  http = GraphQL::Client::HTTP.new(RESOLVER_URL)
  schema = GraphQL::Client.load_schema(http)
  @client = GraphQL::Client.new(schema: schema, execute: http)
  @query = <<~GRAPHQL_QUERY
    query($names: [name!]!, $dataSourceIds: [Int!]) {
      nameResolver(names: $names, dataSourceIds: $dataSourceIds) {
        responses {
          suppliedId suppliedInput
          results {
            name { value }
            canonicalName { value }
            acceptedName { name { value } }
            synonym
            matchType { kind score editDistance }
            taxonId classification { path pathRanks }
            score { value parsingQuality }
          }
        }
      }
    }
  GRAPHQL_QUERY
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/gn_list_resolver/graphql.rb', line 6

def client
  @client
end

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/gn_list_resolver/graphql.rb', line 6

def query
  @query
end