Sha256: a4f187fef3d76a090c2aceec2c0b8eea3db4867ae678eb527c478d4e015d761b

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module Waveapps
  class << self
    attr_accessor :access_token
  end
  class Api
    API_URL = 'https://gql.waveapps.com/graphql/public'
    HTTP = GraphQL::Client::HTTP.new(API_URL) do
      def headers(_context)
        # Optionally set any HTTP headers
        {
          'Authorization' => "Bearer #{Waveapps.access_token}"
        }
      end
    end

    # Fetch latest schema on init, this will make a network request
    Schema = GraphQL::Client.load_schema(HTTP)

    # However, it's smart to dump this to a JSON file and load from disk
    #
    # Run it from a script or rake task
    # rake schema:dump
    #
    # Schema = GraphQL::Client.load_schema("./tmp/schema.json")

    Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waveapps-0.1.4 lib/waveapps/api.rb