Sha256: 09b4159fe65d047bbe79a534e6f2bacae94f0a4002310a2e1f19083af0580bff
Contents?: true
Size: 797 Bytes
Versions: 1
Compression:
Stored size: 797 Bytes
Contents
# frozen_string_literal: true module GraphQL module StaticValidation module OperationNamesAreValid def initialize(*) super @operation_names = Hash.new { |h, k| h[k] = [] } end def on_operation_definition(node, parent) @operation_names[node.name] << node super end def on_document(node, parent) super op_count = @operation_names.values.inject(0) { |m, v| m + v.size } @operation_names.each do |name, nodes| if name.nil? && op_count > 1 add_error(%|Operation name is required when multiple operations are present|, nodes) elsif nodes.length > 1 add_error(%|Operation name "#{name}" must be unique|, nodes) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-1.9.0.pre1 | lib/graphql/static_validation/rules/operation_names_are_valid.rb |