File: fragment_spreads_are_possible_error.rb

package info (click to toggle)
ruby-graphql 2.2.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,584 kB
  • sloc: ruby: 67,505; ansic: 1,753; yacc: 831; javascript: 331; makefile: 6
file content (35 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
module GraphQL
  module StaticValidation
    class FragmentSpreadsArePossibleError < StaticValidation::Error
      attr_reader :type_name
      attr_reader :fragment_name
      attr_reader :parent_name

      def initialize(message, path: nil, nodes: [], type:, fragment_name:, parent:)
        super(message, path: path, nodes: nodes)
        @type_name = type
        @fragment_name = fragment_name
        @parent_name = parent
      end

      # A hash representation of this Message
      def to_h
        extensions = {
          "code" => code,
          "typeName" => type_name,
          "fragmentName" => fragment_name,
          "parentName" => parent_name
        }

        super.merge({
          "extensions" => extensions
        })
      end

      def code
        "cannotSpreadFragment"
      end
    end
  end
end