Module: ElasticGraph::Support::GraphQLGemLoader

Defined in:
lib/elastic_graph/support/graphql_gem_loader.rb

Overview

Helper module to load the graphql gem and optionally graphql-c_parser for better performance. Prints a yellow warning to stderr when c_parser is unavailable (except on JRuby where C extensions don’t work).

Constant Summary collapse

YELLOW =

ANSI escape code for yellow text

"\e[33m"
RESET =
"\e[0m"

Class Method Summary collapse

Class Method Details

.loadObject

Loads the graphql gem and attempts to load graphql/c_parser. If c_parser is unavailable, prints a warning once (unless on JRuby).



24
25
26
27
28
29
30
31
32
# File 'lib/elastic_graph/support/graphql_gem_loader.rb', line 24

def self.load
  require "graphql"

  begin
    require "graphql/c_parser"
  rescue LoadError
    print_warning_once
  end
end