Sha256: f696d3d403d9b275d04a66c8581701944c9c6fd6a705101b186d249ad6168503
Contents?: true
Size: 1.54 KB
Versions: 13
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module GraphQL module Stitching # Immutable structures representing a query plan. # May serialize to/from JSON. class Plan Op = Struct.new( :step, :after, :location, :operation_type, :selections, :variables, :path, :if_type, :boundary, keyword_init: true ) do def as_json { step: step, after: after, location: location, operation_type: operation_type, selections: selections, variables: variables, path: path, if_type: if_type, boundary: boundary&.as_json }.tap(&:compact!) end end class << self def from_json(json) ops = json["ops"] ops = ops.map do |op| boundary = op["boundary"] Op.new( step: op["step"], after: op["after"], location: op["location"], operation_type: op["operation_type"], selections: op["selections"], variables: op["variables"], path: op["path"], if_type: op["if_type"], boundary: boundary ? GraphQL::Stitching::Boundary.new(**boundary) : nil, ) end new(ops: ops) end end attr_reader :ops def initialize(ops: []) @ops = ops end def as_json { ops: @ops.map(&:as_json) } end end end end
Version data entries
13 entries across 13 versions & 1 rubygems