Skip to content

Commit 05c1aeb

Browse files
committed
Don't support partials on individual field nodes
1 parent 4dab451 commit 05c1aeb

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/graphql/query/partial.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class Partial
1818
# @param object [Object] A starting object for execution
1919
# @param query [GraphQL::Query] A full query instance that this partial is based on. Caches are shared.
2020
# @param context [Hash] Extra context values to merge into `query.context`, if provided
21-
def initialize(path:, object:, query:, context: nil, node: nil)
21+
# @param fragment_node [GraphQL::Language::Nodes::InlineFragment, GraphQL::Language::Nodes::FragmentDefinition]
22+
def initialize(path:, object:, query:, context: nil, fragment_node: nil)
2223
@path = path
2324
@object = object
2425
@query = query
@@ -32,17 +33,10 @@ def initialize(path:, object:, query:, context: nil, node: nil)
3233
@result_values = nil
3334
@result = nil
3435

35-
if node && type
36-
@ast_nodes = case node
37-
when GraphQL::Language::Nodes::Field
38-
[node]
39-
when GraphQL::Language::Nodes::InlineFragment, GraphQL::Language::Nodes::FragmentDefinition
40-
node.selections
41-
else
42-
raise ArgumentError, "AST node not supported by Query::Partial"
43-
end
44-
@root_type = type
45-
# This is only used when `@leaf` -- probably could be based on `node`
36+
if node
37+
@ast_nodes = node.selections
38+
@root_type = type || raise(ArgumentError, "Pass `type:` when using `node:`")
39+
# This is only used when `@leaf`
4640
@field_definition = nil
4741
else
4842
set_type_info_from_path

0 commit comments

Comments
 (0)