解析器的未定义方法“deprecation_reason”
Undefined method `deprecation_reason' for Resolvers
我正在为某些字段定义一个解析器,使用 graphql gem for ruby。
这是解析器定义:
module Resolvers
class Events < BaseResolver
type [Types::EventType], null: true
argument :input, Types::EventInput, required: true
def resolve(input:)
# do something
end
end
end
这是 BaseResolver class:
module Resolvers
class BaseResolver < GraphQL::Schema::Resolver
end
end
这就是我调用解析器的地方:
module Types
class CommonSpaceType < BaseObject
field :active, Boolean, null: true
field :events, function: Resolvers::Events
end
end
这是我使用 Insomnia 得到的回复:
"message": "undefined method `deprecation_reason' for Resolvers::Events:Class\nDid you mean? deprecate_constant"
它已经很老了,但也许有人会用到这些信息。你应该改变
field :events, function: Resolvers::Events
到
field :events, resovler: Resolvers::Events
因为您使用的是 GraphQL::Schema::Resolver
对象,而不是 GraphQL::Function
。
我正在为某些字段定义一个解析器,使用 graphql gem for ruby。
这是解析器定义:
module Resolvers
class Events < BaseResolver
type [Types::EventType], null: true
argument :input, Types::EventInput, required: true
def resolve(input:)
# do something
end
end
end
这是 BaseResolver class:
module Resolvers
class BaseResolver < GraphQL::Schema::Resolver
end
end
这就是我调用解析器的地方:
module Types
class CommonSpaceType < BaseObject
field :active, Boolean, null: true
field :events, function: Resolvers::Events
end
end
这是我使用 Insomnia 得到的回复:
"message": "undefined method `deprecation_reason' for Resolvers::Events:Class\nDid you mean? deprecate_constant"
它已经很老了,但也许有人会用到这些信息。你应该改变
field :events, function: Resolvers::Events
到
field :events, resovler: Resolvers::Events
因为您使用的是 GraphQL::Schema::Resolver
对象,而不是 GraphQL::Function
。