Sha256: e933aa15ca719e5d431d2fdc3b4a67f47552be2407ebbcd638125491b5d5749c

Contents?: true

Size: 922 Bytes

Versions: 68

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    class FragmentsAreUsed
      include GraphQL::StaticValidation::Message::MessageHelper

      def validate(context)
        context.visitor[GraphQL::Language::Nodes::Document].leave << ->(_n, _p) do
          dependency_map = context.dependencies
          dependency_map.unmet_dependencies.each do |op_defn, spreads|
            spreads.each do |fragment_spread|
              context.errors << message("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?
              context.errors << message("Fragment #{fragment.name} was defined, but not used", fragment.node, path: fragment.path)
            end
          end
        end
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
graphql-1.7.4 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.7.3 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.7.2 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.7.1 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.7.0 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.8 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.7 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.6 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.5 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.4 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.5.15 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.3 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.2 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.1 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.6.0 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.5.14 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.5.13 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.5.7.1 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.5.12 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.5.11 lib/graphql/static_validation/rules/fragments_are_used.rb