我对使用Rails完全陌生,我正在尝试使用ruby-graphql创建一个基本的crud应用程序来对sqlite3数据库执行一个简单的带有活动记录的查找查询。我设置了一个用户类型
class UserType < Types::BaseObject
description "A user type "
field :id, ID, null: false
field :username, String, null: false
field :email, String, null: false
field :email_confirmed, Boolean, null:false
field :first_name, String , null:false
field :last_name, String, null:false
field :biography, String, null:true
field :avatar, String, null:true
field :created_at, GraphQL::Types::ISO8601DateTime, null:false
field :updated_at, GraphQL::Types::ISO8601DateTime, null:false
end然后我设置查询:
field :user, UserType, null:false,
description: "Get a single user" do
argument :username, String, required: true
end
def user(username:)
User.find(username)
end我的问题是:
{
user(username:"test"){
username
}
}我得到以下错误:
{
"error": {
"message": "no implicit conversion of #<Class:0x000000000b975440> into Hash",
"backtrace": [
"C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/graphql-1.9.13/lib/graphql/schema/field.rb:519:in `block in resolve'",如果有人能帮助我,我将不胜感激。如何在Ruby / Rails中执行此转换?
发布于 2019-10-15 09:32:25
原来我使用Ruby gem升级到新的gem时出现了一个问题,它解决了这个问题。请参见- https://github.com/rmosolgo/graphql-ruby/issues/2537
https://stackoverflow.com/questions/58374118
复制相似问题