module HQ::GraphQL::Ext::SchemaExtensions

Public Class Methods

prepended(klass) click to toggle source
# File lib/hq/graphql/ext/schema_extensions.rb, line 7
def self.prepended(klass)
  klass.alias_method :add_type_and_traverse_without_types, :add_type_and_traverse
  klass.alias_method :add_type_and_traverse, :add_type_and_traverse_with_types
end

Public Instance Methods

add_type_and_traverse_with_types(*args, **options) click to toggle source

Defer adding types until first schema execution github.com/rmosolgo/graphql-ruby/blob/345ebb2e3833909963067d81e0e8378717b5bdbf/lib/graphql/schema.rb#L1792

# File lib/hq/graphql/ext/schema_extensions.rb, line 41
def add_type_and_traverse_with_types(*args, **options)
  @add_type_and_traverse_with_types ||= []
  @add_type_and_traverse_with_types.push([args, options])
end
dump() click to toggle source
# File lib/hq/graphql/ext/schema_extensions.rb, line 25
def dump
  load_types!
  ::FileUtils.mkdir_p(dump_directory)
  ::File.open(::File.join(dump_directory, dump_filename), "w") { |file| file.write(self.to_definition) }
end
dump_directory(directory = Rails.root.join("app/graphql")) click to toggle source
# File lib/hq/graphql/ext/schema_extensions.rb, line 17
def dump_directory(directory = Rails.root.join("app/graphql"))
  @dump_directory ||= directory
end
dump_filename(filename = " click to toggle source
# File lib/hq/graphql/ext/schema_extensions.rb, line 21
def dump_filename(filename = "#{self.name.underscore}.graphql")
  @dump_filename ||= filename
end
execute(*args, **options) click to toggle source
Calls superclass method
# File lib/hq/graphql/ext/schema_extensions.rb, line 12
def execute(*args, **options)
  load_types!
  super
end
load_types!() click to toggle source
# File lib/hq/graphql/ext/schema_extensions.rb, line 31
def load_types!
  ::HQ::GraphQL.load_types!
  return if @add_type_and_traverse_with_types.blank?
  while (args, options = @add_type_and_traverse_with_types.shift)
    add_type_and_traverse_without_types(*args, **options)
  end
end