Class: GraphQL::Schema::Field::ConnectionExtension
- Inherits:
-
GraphQL::Schema::FieldExtension
- Object
- GraphQL::Schema::FieldExtension
- GraphQL::Schema::Field::ConnectionExtension
- Defined in:
- lib/graphql/schema/field/connection_extension.rb
Instance Attribute Summary
Attributes inherited from GraphQL::Schema::FieldExtension
#added_default_arguments, #added_extras, #field, #options
Instance Method Summary collapse
-
#after_resolve(value:, object:, arguments:, context:, memo:) ⇒ Object
-
#after_resolve_next(**kwargs) ⇒ Object
-
#apply ⇒ Object
-
#resolve(object:, arguments:, context:) {|object, next_args, arguments| ... } ⇒ Object
Remove pagination args before passing it to a user method.
-
#resolve_next(objects:, arguments:, context:) {|objects, next_args, arguments| ... } ⇒ Object
Methods inherited from GraphQL::Schema::FieldExtension
#after_define, #after_define_apply, default_argument, default_argument_configurations, extras, #initialize
Constructor Details
This class inherits a constructor from GraphQL::Schema::FieldExtension
Instance Method Details
#after_resolve(value:, object:, arguments:, context:, memo:) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/graphql/schema/field/connection_extension.rb', line 33 def after_resolve(value:, object:, arguments:, context:, memo:) original_arguments = memo context.query.after_lazy(value) do |resolved_value| context.schema.connections.populate_connection(field, object.object, resolved_value, original_arguments, context) end end |
#after_resolve_next(**kwargs) ⇒ Object
40 41 42 |
# File 'lib/graphql/schema/field/connection_extension.rb', line 40 def after_resolve_next(**kwargs) raise "This should never be called -- it's hardcoded in execution instead." end |
#apply ⇒ Object
7 8 9 10 11 12 |
# File 'lib/graphql/schema/field/connection_extension.rb', line 7 def apply field.argument :after, "String", "Returns the elements in the list that come after the specified cursor.", required: false field.argument :before, "String", "Returns the elements in the list that come before the specified cursor.", required: false field.argument :first, "Int", "Returns the first _n_ elements from the list.", required: false field.argument :last, "Int", "Returns the last _n_ elements from the list.", required: false end |
#resolve(object:, arguments:, context:) {|object, next_args, arguments| ... } ⇒ Object
Remove pagination args before passing it to a user method
15 16 17 18 19 20 21 22 |
# File 'lib/graphql/schema/field/connection_extension.rb', line 15 def resolve(object:, arguments:, context:) next_args = arguments.dup next_args.delete(:first) next_args.delete(:last) next_args.delete(:before) next_args.delete(:after) yield(object, next_args, arguments) end |
#resolve_next(objects:, arguments:, context:) {|objects, next_args, arguments| ... } ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/graphql/schema/field/connection_extension.rb', line 24 def resolve_next(objects:, arguments:, context:) next_args = arguments.dup next_args.delete(:first) next_args.delete(:last) next_args.delete(:before) next_args.delete(:after) yield(objects, next_args, arguments) end |