@@ -14,6 +14,7 @@ class Field
14
14
include GraphQL ::Schema ::Member ::AcceptsDefinition
15
15
include GraphQL ::Schema ::Member ::HasArguments
16
16
include GraphQL ::Schema ::Member ::HasPath
17
+ extend GraphQL ::Schema ::FindInheritedValue
17
18
18
19
# @return [String] the GraphQL name for this field, camelized unless `camelize: false` is provided
19
20
attr_reader :name
@@ -135,6 +136,22 @@ def scoped?
135
136
end
136
137
end
137
138
139
+ # This extension is applied to fields when {#connection?} is true.
140
+ #
141
+ # You can override it in your base field definition.
142
+ # @return [Class] A {FieldExtension} subclass for implementing pagination behavior.
143
+ # @example Configuring a custom extension
144
+ # class Types::BaseField < GraphQL::Schema::Field
145
+ # connection_extension(MyCustomExtension)
146
+ # end
147
+ def self . connection_extension ( new_extension_class = nil )
148
+ if new_extension_class
149
+ @connection_extension = new_extension_class
150
+ else
151
+ @connection_extension ||= find_inherited_value ( :connection_extension , ConnectionExtension )
152
+ end
153
+ end
154
+
138
155
# @param name [Symbol] The underscore-cased version of this field name (will be camelized for the GraphQL API)
139
156
# @param type [Class, GraphQL::BaseType, Array] The return type of this field
140
157
# @param owner [Class] The type that this field belongs to
@@ -246,7 +263,7 @@ def initialize(type: nil, name: nil, owner: nil, null: nil, field: nil, function
246
263
# The problem with putting this after the definition_block
247
264
# is that it would override arguments
248
265
if connection?
249
- self . extension ( ConnectionExtension )
266
+ self . extension ( self . class . connection_extension )
250
267
end
251
268
252
269
if definition_block
0 commit comments