-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstitching.rb
More file actions
94 lines (75 loc) · 2.71 KB
/
stitching.rb
File metadata and controls
94 lines (75 loc) · 2.71 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# frozen_string_literal: true
require "graphql"
module GraphQL
module Stitching
# scope name of query operations.
QUERY_OP = "query"
# scope name of mutation operations.
MUTATION_OP = "mutation"
# scope name of subscription operations.
SUBSCRIPTION_OP = "subscription"
# introspection typename field.
TYPENAME = "__typename"
# @api private
EMPTY_OBJECT = {}.freeze
# @api private
EMPTY_ARRAY = [].freeze
class StitchingError < StandardError; end
class CompositionError < StitchingError; end
class ValidationError < CompositionError; end
class DocumentError < StandardError
def initialize(element)
super("Invalid #{element} encountered in document")
end
end
class << self
# Proc used to compute digests; uses SHA2 by default.
# @returns [Proc] proc used to compute digests.
def digest(&block)
if block_given?
@digest = block
else
@digest ||= ->(str) { Digest::SHA2.hexdigest(str) }
end
end
# Name of the directive used to mark type resolvers.
# @returns [String] name of the type resolver directive.
def stitch_directive
@stitch_directive ||= "stitch"
end
attr_writer :stitch_directive
# Name of the directive used to denote member visibilities.
# @returns [String] name of the visibility directive.
def visibility_directive
@visibility_directive ||= "visibility"
end
attr_writer :visibility_directive
# Name of the directive used to denote member authorizations.
# @returns [String] name of the authorization directive.
def authorization_directive
@authorization_directive ||= "authorization"
end
attr_writer :authorization_directive
MIN_VISIBILITY_VERSION = "2.5.3"
# @returns Boolean true if GraphQL::Schema::Visibility is fully supported
def supports_visibility?
return @supports_visibility if defined?(@supports_visibility)
# Requires `Visibility` (v2.4) with nil profile support (v2.5.3)
@supports_visibility = Gem::Version.new(GraphQL::VERSION) >= Gem::Version.new(MIN_VISIBILITY_VERSION)
end
end
end
end
require_relative "stitching/formatter"
require_relative "stitching/directives"
require_relative "stitching/supergraph"
require_relative "stitching/client"
require_relative "stitching/composer"
require_relative "stitching/executor"
require_relative "stitching/http_executable"
require_relative "stitching/plan"
require_relative "stitching/planner"
require_relative "stitching/request"
require_relative "stitching/type_resolver"
require_relative "stitching/util"
require_relative "stitching/version"