Module: HQ::GraphQL::Ext::SchemaExtensions
- Defined in:
- lib/hq/graphql/ext/schema_extensions.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#add_type_and_traverse_with_types(*args, **options) ⇒ Object
Defer adding types until first schema execution github.com/rmosolgo/graphql-ruby/blob/345ebb2e3833909963067d81e0e8378717b5bdbf/lib/graphql/schema.rb#L1792.
- #dump ⇒ Object
- #dump_directory(directory = Rails.root.join("app/graphql")) ⇒ Object
- #dump_filename(filename = "#{self.name.underscore}.graphql") ⇒ Object
- #execute(*args, **options) ⇒ Object
- #load_types! ⇒ Object
Class Method Details
.prepended(klass) ⇒ Object
7 8 9 10 |
# 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 |
Instance Method Details
#add_type_and_traverse_with_types(*args, **options) ⇒ Object
Defer adding types until first schema execution github.com/rmosolgo/graphql-ruby/blob/345ebb2e3833909963067d81e0e8378717b5bdbf/lib/graphql/schema.rb#L1792
41 42 43 44 |
# File 'lib/hq/graphql/ext/schema_extensions.rb', line 41 def add_type_and_traverse_with_types(*args, **) @add_type_and_traverse_with_types ||= [] @add_type_and_traverse_with_types.push([args, ]) end |
#dump ⇒ Object
25 26 27 28 29 |
# 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")) ⇒ Object
17 18 19 |
# 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 = "#{self.name.underscore}.graphql") ⇒ Object
21 22 23 |
# 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) ⇒ Object
12 13 14 15 |
# File 'lib/hq/graphql/ext/schema_extensions.rb', line 12 def execute(*args, **) load_types! super end |
#load_types! ⇒ Object
31 32 33 34 35 36 37 |
# 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, = @add_type_and_traverse_with_types.shift) add_type_and_traverse_without_types(*args, **) end end |