Sha256: 2c2fefd0485a479ccfa85d993db38812720622a0bd43a169fed57defde83dc11

Contents?: true

Size: 1.04 KB

Versions: 191

Compression:

Stored size: 1.04 KB

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(GraphQL::StaticValidation::FragmentsAreUsedError.new(
              "Fragment #{fragment_spread.name} was used, but not defined",
              nodes: fragment_spread.node,
              path: fragment_spread.path,
              fragment: fragment_spread.name
            ))
          end
        end

        dependency_map.unused_dependencies.each do |fragment|
          if fragment && !fragment.name.nil?
            add_error(GraphQL::StaticValidation::FragmentsAreUsedError.new(
              "Fragment #{fragment.name} was defined, but not used",
              nodes: fragment.node,
              path: fragment.path,
              fragment: fragment.name
            ))
          end
        end
      end
    end
  end
end

Version data entries

191 entries across 191 versions & 2 rubygems

Version Path
graphql-2.4.4 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.4.3 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.4.2 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.4.1 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.4.0 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.20 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.19 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.18 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.17 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.16 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.15 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.14 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.13 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.12 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.11 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.10 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.2.16 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.1.13 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.9 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-2.3.8 lib/graphql/static_validation/rules/fragments_are_used.rb