Class: GraphQL::Validations::FragmentsAreUsed
- Inherits:
-
Object
- Object
- GraphQL::Validations::FragmentsAreUsed
- Defined in:
- lib/graph_ql/validations/fragments_are_used.rb
Instance Method Summary collapse
Instance Method Details
#validate(context) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/graph_ql/validations/fragments_are_used.rb', line 2 def validate(context) v = context.visitor used_fragment_names = [] defined_fragment_names = [] v[GraphQL::Nodes::FragmentSpread] << -> (node) { used_fragment_names << node.name } v[GraphQL::Nodes::FragmentDefinition] << -> (node) { defined_fragment_names << node.name} v[GraphQL::Nodes::Document].leave << -> (node) { add_errors(context.errors, used_fragment_names, defined_fragment_names) } end |