Sha256: a5f44fd27f414d2396d83e94036cd38931b0987132dafefc3c9feaf8e2d8620e

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module FragmentsAreUsed
      def on_document(node, parent)
        super
        dependency_map = context.dependencies
        dependency_map.unmet_dependencies.each do |op_defn, spreads|
          spreads.each do |fragment_spread|
            add_error("Fragment #{fragment_spread.name} was used, but not defined", fragment_spread.node, path: fragment_spread.path)
          end
        end

        dependency_map.unused_dependencies.each do |fragment|
          if !fragment.name.nil?
            add_error("Fragment #{fragment.name} was defined, but not used", fragment.node, path: fragment.path)
          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/fragments_are_used.rb