Skip to content

Commit

Permalink
Merge pull request #280 from cjoudrey/directives-lexer-parser
Browse files Browse the repository at this point in the history
Add support for directive definitions to the lexer, parser, and Generation class.
  • Loading branch information
Robert Mosolgo authored Sep 29, 2016
2 parents ca91964 + 164b5de commit df0e026
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 df0e026

Please sign in to comment.