class GnListResolver::GnGraphQL

GraphQL client for gnindex API

Attributes

client[R]
query[R]

Public Class Methods

new() click to toggle source
# 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,
                       advancedResolution: true) {
            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