Class: GraphQL::Extras::Test::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/extras/test/schema.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context = {}) ⇒ Schema

Returns a new instance of Schema.



27
28
29
# File 'lib/graphql/extras/test/schema.rb', line 27

def initialize(context = {})
  @context = context
end

Class Method Details

.configure(schema:, queries:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/graphql/extras/test/schema.rb', line 11

def self.configure(schema:, queries:)
  loader = Loader.new

  Dir.glob(queries) do |path|
    loader.load(path)
  end

  loader.operations.each do |name, operation|
    query = loader.print(operation)

    define_method(name.underscore) do |variables = {}|
      __execute(schema, query, variables)
    end
  end
end