Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding field with resolver on a Type causes "Can't determine the return type " error on a different Type #3974

Closed
slimdave opened this issue Mar 6, 2022 · 8 comments

Comments

@slimdave
Copy link

slimdave commented Mar 6, 2022

Describe the bug

We are using a resolver Resolvers::TodoResolver on a field todos that is already present on two types – QueryType and WorkType. The resolver declares the type with type [Types::TodoType], null: false (see code below).

When we add a todos field UserType with the same resolver, we receive an error with the message: "Can't determine the return type for Work.todos (it has resolver: Resolvers::TodosResolver, consider configuration a type ... for that class)"

Removing the todos field from UserType, or replacing it with a definition that does not include the resolver, does not raise the error.

Versions

graphql version: 1.13.10
rails (or other framework): Rails 6.1.4.4
other applicable versions (graphql-batch, etc)
graphql-batch (0.5.0)
promise.rb (0.7.4)

GraphQL schema

Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?

module Resolvers
  class TodosResolver < GraphQL::Schema::Resolver

    type [Types::TodoType], null: false

    description "A list of todos"

    argument  :work_search,
              Types::Search::WorkSearchAttributes,
              description: <<~TXT,
                Search for todos based on the attributes of the works to which they are attached
              TXT
              required:    false

    argument  :product_search,
              Types::Search::ProductSearchAttributes,
              description: <<~TXT,
                Search for todos based on the attributes of products on the works to which they are attached
              TXT
              required:    false

    argument  :todo_search,
              Types::Search::TodoSearchAttributes,
              description: <<~TXT,
                Search for todos based on their attributes
              TXT
              required:    false

    def resolve(first:          nil,
                id_gt:          nil,
                work_search:    nil,
                product_search: nil,
                todo_search:    nil)

      Resolvers::TodoResolution.call(
        object:         object,
        context:        context,
        first:          first,
        id_gt:          id_gt,
        work_search:    work_search,
        product_search: product_search,
        todo_search:    todo_search
      )
    end
  end
end

module Types
  class QueryType < Types::BaseObject # rubocop:disable Metrics/ClassLength
    # other fields omited for brevity
    field :works,
          resolver: Resolvers::WorksResolver do
            complexity ->(ctx, args, child_complexity) {
              cardinality_estimate =
                (
                  args[:first]&.to_i ||
                  ctx[:current_client].works_count
                ).clamp(1, System.graphql_limit)
              cardinality_estimate * child_complexity
            }
          end

    field :todos,
          resolver: Resolvers::TodosResolver do
            complexity ->(ctx, args, child_complexity) {
              cardinality_estimate =
                (
                  args[:first]&.to_i ||
                  ctx[:current_client].todos.count
                ).clamp(1, System.graphql_limit)
              cardinality_estimate * child_complexity
            }
          end
  end
end

module Types
  class WorkType < Types::BaseObject # rubocop:disable Metrics/ClassLength
    # other fields omited for brevity
    field :todos,
          resolver: Resolvers::TodosResolver do
            complexity ->(_ctx, _args, child_complexity) {
              20 * child_complexity
            }
          end
  end
end

module Types
  class UserType < Types::BaseObject
    # other fields omited for brevity

    # This causes an error to be thrown
    field :todos,
          resolver: Resolvers::TodosResolver do
            complexity ->(_ctx, _args, child_complexity) {
              100 * child_complexity
            }
          end

    # Replacing the above filed definition with this does not
    # throw an error
    field :todos,
          [Types::TodoType],
          null:        false
  end
end

**GraphQL query**

Example GraphQL query and response (if query execution is involved)

Any query raises the error

Steps to reproduce

Steps to reproduce the behavior

Expected behavior

No error should be raised. The todos field should be available on QueryType, WorkType, and UserType

Actual behavior

Error was raised

Place full backtrace here (if a Ruby exception is involved):

Click to view exception backtrace
{
	"errors": [
		{
			"message": "Can't determine the return type for Work.todos (it has `resolver: Resolvers::TodosResolver`, consider configuration a `type ...` for that class)",
			"backtrace": [
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/field.rb:601:in `type'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/field.rb:143:in `connection?'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/field.rb:308:in `initialize'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/member/accepts_definition.rb:154:in `initialize'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/field.rb:129:in `new'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/field.rb:129:in `from_options'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.10/lib/graphql/schema/member/has_fields.rb:12:in `field'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/work_type.rb:25:in `<class:WorkType>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/work_type.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/work_type.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/todo_type.rb:74:in `<class:TodoType>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/todo_type.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/todo_type.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/resolvers/todos_resolver.rb:6:in `<class:TodosResolver>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/resolvers/todos_resolver.rb:4:in `<module:Resolvers>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/resolvers/todos_resolver.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/user_type.rb:53:in `<class:UserType>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/user_type.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/user_type.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_fulfiller_union.rb:6:in `<class:RoleFulfillerUnion>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_fulfiller_union.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_fulfiller_union.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_fulfillment_type.rb:11:in `<class:RoleFulfillmentType>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_fulfillment_type.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_fulfillment_type.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_type.rb:21:in `<class:RoleType>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_type.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/role_type.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/mutations/create_role.rb:10:in `<class:CreateRole>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/mutations/create_role.rb:4:in `<module:Mutations>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/mutations/create_role.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/mutation_type.rb:5:in `<class:MutationType>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/mutation_type.rb:4:in `<module:Types>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/types/mutation_type.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/consonance_schema.rb:4:in `<class:ConsonanceSchema>'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/graphql/consonance_schema.rb:3:in `<main>'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/skylight-5.1.1/lib/skylight/probes.rb:167:in `require'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'",
				"/Users/davidaldridge/Work/Repositories/consonance/app/controllers/graphql_controller.rb:14:in `execute'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/abstract_controller/base.rb:228:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal/rendering.rb:30:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/abstract_controller/callbacks.rb:42:in `block in process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:106:in `run_callbacks'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/abstract_controller/callbacks.rb:41:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal/rescue.rb:22:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:203:in `block in instrument'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/instrumenter.rb:24:in `instrument'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:203:in `instrument'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal/instrumentation.rb:33:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/railties/controller_runtime.rb:27:in `process_action'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/abstract_controller/base.rb:165:in `process'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionview-6.1.4.4/lib/action_view/rendering.rb:39:in `process'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal.rb:190:in `dispatch'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_controller/metal.rb:254:in `dispatch'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/route_set.rb:33:in `serve'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:50:in `block in serve'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:32:in `each'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:32:in `serve'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/route_set.rb:842:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/static.rb:24:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bullet-7.0.1/lib/bullet/rack.rb:12:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/batch-loader-2.0.1/lib/batch_loader/middleware.rb:11:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/warden-1.2.9/lib/warden/manager.rb:36:in `block in call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `catch'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/conditional_get.rb:40:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/http/permissions_policy.rb:22:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/http/content_security_policy.rb:18:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/cookies.rb:689:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/migration.rb:601:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:98:in `run_callbacks'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/callbacks.rb:26:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/executor.rb:14:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rack.rb:51:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:132:in `call_app'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:28:in `block in call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:17:in `catch'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:17:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.1.4.4/lib/rails/rack/logger.rb:37:in `call_app'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.1.4.4/lib/rails/rack/logger.rb:26:in `block in call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/tagged_logging.rb:99:in `block in tagged'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/tagged_logging.rb:37:in `tagged'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/tagged_logging.rb:99:in `tagged'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.1.4.4/lib/rails/rack/logger.rb:26:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/request_store-1.5.1/lib/request_store/middleware.rb:19:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/request_id.rb:26:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/executor.rb:14:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/static.rb:24:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/host_authorization.rb:119:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/hirefire-resource-0.10.0/lib/hirefire/middleware.rb:37:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/webpacker-5.4.3/lib/webpacker/dev_server_proxy.rb:25:in `perform_request'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rack-proxy-0.7.2/lib/rack/proxy.rb:67:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:539:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/puma-5.5.2/lib/puma/configuration.rb:249:in `call'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/puma-5.5.2/lib/puma/request.rb:77:in `block in handle_request'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/puma-5.5.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/puma-5.5.2/lib/puma/request.rb:76:in `handle_request'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/puma-5.5.2/lib/puma/server.rb:447:in `process_client'",
				"/Users/davidaldridge/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/puma-5.5.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'"
			]
		}
	],
	"data": {}
}

Additional context

I notice a slight change in the error message in v2, referencing cyclic conditions, but can't upgrade to 2 yet because of the graphql-batch restriction.

@slimdave
Copy link
Author

slimdave commented Mar 7, 2022

I've worked around this for now by adding a new Resolvers::UserTodoResolver as a copy of Resolvers::TodoResolver and referencing that in the UserType

@rmosolgo
Copy link
Owner

rmosolgo commented Mar 7, 2022

Hey, sorry for the trouble! Thanks for the detailed report.

cyclic conditions

Yep ... and I think this spot is particularly tough, since it's the type(...) of the resolver that eventually references the resolver itself.

I think you could get around this by using a string for the type name:

  module Resolvers
    class TodosResolver < GraphQL::Schema::Resolver

-     type [Types::TodoType], null: false
+     type "[Types::TodoType]", null: false

I think that would defer the reference to Types::TodoType until when the resolver is attached to a field. Does it work for you?

@slimdave
Copy link
Author

slimdave commented Mar 7, 2022

Perfect!

Thanks so much.

@slimdave slimdave closed this as completed Mar 7, 2022
@digitalmoksha
Copy link

@rmosolgo hmm, what if your type looks like this

    type Types::IssueType.connection_type, null: true

Quoting it won't help in this case 🤔

@rmosolgo
Copy link
Owner

  1. Create app/graphql/types/issue_connection_type.rb with:

    Types::IssueConnectionType = Types::IssueType.connection_type 
  2. Then use a quoted reference to the type:

    type("Types::IssueConnectionType", null: true)

Want to give that a try?

@digitalmoksha
Copy link

Thanks, that did the trick!

@yannickgloster
Copy link

  1. Create app/graphql/types/issue_connection_type.rb with:
    Types::IssueConnectionType = Types::IssueType.connection_type 
  2. Then use a quoted reference to the type:
    type("Types::IssueConnectionType", null: true)

Want to give that a try?

This trick didn't work for me. When doing this, I end up getting type errors in my paginated data query from my front end.

@rmosolgo
Copy link
Owner

rmosolgo commented Aug 2, 2024

Hey @yannickgloster, I'd be happy to help you debug this. If you're interested, please open a new issue with all the relevant details (resolver definition, example query, full error message, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants