Sha256: bfc8fb9db84cfd8f6b6a5359eab42b58b78571a2eb9cc900e72ae62427b7c755
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module GraphQL module Stitching # Immutable (in theory) 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, :resolver, 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, resolver: resolver }.tap(&:compact!) end end class << self def from_json(json) ops = json["ops"] ops = ops.map do |op| 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"], resolver: op["resolver"], ) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-stitching-1.4.3 | lib/graphql/stitching/plan.rb |