Class: GraphitiGraphQL::GraphitiSchema::Wrapper
- Inherits:
-
Object
- Object
- GraphitiGraphQL::GraphitiSchema::Wrapper
- Defined in:
- lib/graphiti_graphql/graphiti_schema/wrapper.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #get_resource(name) ⇒ Object
-
#initialize(schema) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #resources ⇒ Object
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
#schema ⇒ Object (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 |
#resources ⇒ Object
16 17 18 |
# File 'lib/graphiti_graphql/graphiti_schema/wrapper.rb', line 16 def resources schema[:resources].map { |r| get_resource(r[:name]) } end |