Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set DirectiveDefinitionNode.children_method_name #4931

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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