Skip to content

Commit

Permalink
Merge pull request #4931 from thomasmarshall/fix-directive-definition
Browse files Browse the repository at this point in the history
Set DirectiveDefinitionNode.children_method_name
  • Loading branch information
rmosolgo committed Apr 23, 2024
2 parents 43bbe01 + 221db86 commit 0799211
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/graphql/language/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class DirectiveDefinition < AbstractNode
arguments: Nodes::Argument,
locations: Nodes::DirectiveLocation,
)
self.children_method_name = :definitions
end

# An enum value. The string is available as {#name}.
Expand Down
14 changes: 14 additions & 0 deletions spec/graphql/language/visitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ def on_variable_definition(node, parent)
super
end
end

def on_directive_definition(node, parent)
if node.name == "deleteMe"
super(DELETE_NODE, parent)
else
super
end
end
end

def get_result(query_str)
Expand Down Expand Up @@ -375,6 +383,10 @@ def get_result(query_str)

it "works with SDL" do
before_query = <<-GRAPHQL.chop
directive @deleteMe on FIELD
directive @keepMe on FIELD
type Rename @doStuff {
f: Int
renameThis: String
Expand All @@ -383,6 +395,8 @@ def get_result(query_str)
GRAPHQL

after_query = <<-GRAPHQL.chop
directive @keepMe on FIELD
type WasRenamed @doStuff(addedArgument2: 2) {
f: Int
wasRenamed: String
Expand Down

0 comments on commit 0799211

Please sign in to comment.