I am completely new to using Rails, I'm trying to create a basic crud application using ruby-graphql to do a simple find query with active record to a sqlite3 database. I set up a user type
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
Then I setup the query :
field :user, UserType, null:false,
description: "Get a single user" do
argument :username, String, required: true
end
def user(username:)
User.find(username)
end
My query is :
{
user(username:"test"){
username
}
}
I get the following error :
{
"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'",
If anyone could help me I would really appreciate it. How do I do this conversion in Ruby / Rails?