Class: GraphQL::Stitching::Shaper
- Inherits:
-
Object
- Object
- GraphQL::Stitching::Shaper
- Defined in:
- lib/graphql/stitching/shaper.rb
Instance Method Summary collapse
-
#initialize(supergraph:, document:, raw:) ⇒ Shaper
constructor
A new instance of Shaper.
- #perform! ⇒ Object
Constructor Details
#initialize(supergraph:, document:, raw:) ⇒ Shaper
Returns a new instance of Shaper.
7 8 9 10 11 12 |
# File 'lib/graphql/stitching/shaper.rb', line 7 def initialize(supergraph:, document:, raw:) @supergraph = supergraph @document = document @result = raw @errors = [] end |
Instance Method Details
#perform! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/graphql/stitching/shaper.rb', line 14 def perform! if @result.key?("data") && ! @result["data"].empty? munge_entry(@result["data"], @document.operation.selections, @supergraph.schema.query) # hate doing a second pass, but cannot remove _STITCH_ fields until the fragements are processed clean_entry(@result["data"]) end if @errors.length > 0 @result = [] unless @result.key?("errors") @result["errors"] += @errors end @result end |