Skip to content

Commit

Permalink
Add parser/generation support for directive definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
cjoudrey committed Sep 27, 2016
1 parent 74c31bc commit 164b5de
Show file tree
Hide file tree
Showing 8 changed files with 947 additions and 808 deletions.
5 changes: 4 additions & 1 deletion lib/graphql/language/generation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def generate(node, indent: "")
out << generate_directives(node.directives)
out << generate_selections(node.selections, indent: indent)
out

when Nodes::FragmentSpread
out = "#{indent}...#{node.name}"
out << generate_directives(node.directives)
Expand Down Expand Up @@ -123,6 +122,10 @@ def generate(node, indent: "")
out << " #{generate(field)}\n"
end
out << "}"
when Nodes::DirectiveDefinition
out = "directive @#{node.name}"
out << "(#{node.arguments.map { |a| generate(a) }.join(", ")})" if node.arguments.any?
out << " on #{node.locations.join(' | ')}"
when Nodes::AbstractNode
node.to_query_string(indent: indent)
when FalseClass, Float, Integer, NilClass, String, TrueClass
Expand Down
Loading

0 comments on commit 164b5de

Please sign in to comment.