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.8.18 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.17 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.16 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.15 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.14 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.13 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.12 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.11 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.10 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.9 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.8 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.7 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.6 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.5 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.4 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.3 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.2 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.1 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.0 lib/graphql/static_validation/rules/fragments_are_used.rb
graphql-1.8.0.pre11 lib/graphql/static_validation/rules/fragments_are_used.rb