Class: GraphitiGraphQL::GraphitiSchema::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/graphiti_graphql/graphiti_schema/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ Wrapper

Returns a new instance of Wrapper.



6
7
8
# File 'lib/graphiti_graphql/graphiti_schema/wrapper.rb', line 6

def initialize(schema)
  @schema = schema
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



4
5
6
# File 'lib/graphiti_graphql/graphiti_schema/wrapper.rb', line 4

def schema
  @schema
end

Instance Method Details

#get_resource(name) ⇒ Object



10
11
12
13
14
# File 'lib/graphiti_graphql/graphiti_schema/wrapper.rb', line 10

def get_resource(name)
  config = schema[:resources].find { |r| r[:name] == name }
  raise "Could not find resource #{name} in schema" unless config
  Resource.new(self, schema[:resources].find { |r| r[:name] == name })
end

#resourcesObject



16
17
18
# File 'lib/graphiti_graphql/graphiti_schema/wrapper.rb', line 16

def resources
  schema[:resources].map { |r| get_resource(r[:name]) }
end