GraphQL Code Libraries, Tools and Services


For our examples in Ruby, we’re going to be using a very simple custom client to make our calls to the Kana GraphQL API - specify the following as its own class:

# Install the following gems beforehand and require them
require 'httparty'
require 'json'

# Setup the GraphQL API client in Ruby
class KanaGraphqlClient
  def initialize(api_key)
    @api_key = api_key

  def execute(query:, variables: nil)
      headers: {
        'Content-Type'  => 'application/json',
        'Authorization' => @api_key
      body: {
        query: query,
        variables: variables

We can now initialize this when required by providing a Kana API Key - we’ll tie this initialized object to the client variable like so:

client ={API_KEY})

Make sure to either replace #{APIKEY} or define API_KEY with the Kana API Key you were provisioned. More on authentication can be found here.

You’re now ready to go!