Skip to content

Commit

Permalink
fix: drop actionpack from runtime dependencies (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
prikha authored and rylanc committed Oct 22, 2019
1 parent 550f783 commit 64acd27
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/apollo-federation/tracing/node_map.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'active_support/core_ext/array/wrap'
require 'apollo-federation/tracing/proto'

module ApolloFederation
Expand Down Expand Up @@ -28,7 +27,7 @@ def root
end

def node_for_path(path)
nodes[Array.wrap(path).join('.')]
nodes[array_wrap(path).join('.')]
end

def add(path)
Expand All @@ -54,10 +53,10 @@ def add(path)
end

def add_error(error)
path = Array.wrap(error['path']).join('.')
path = array_wrap(error['path']).join('.')
node = nodes[path] || root

locations = Array.wrap(error['locations']).map do |location|
locations = array_wrap(error['locations']).map do |location|
ApolloFederation::Tracing::Location.new(location)
end

Expand All @@ -67,6 +66,16 @@ def add_error(error)
json: JSON.dump(error),
)
end

def array_wrap(object)
if object.nil?
[]
elsif object.respond_to?(:to_ary)
object.to_ary || [object]
else
[object]
end
end
end
end
end

0 comments on commit 64acd27

Please sign in to comment.