0

I am using graphql-ruby gem v 1.9.6 with the class-version base. I am using 2 models. See below.

model 1 :

class User < ApplicationRecord
  include EnsureUUID

  has_secure_password

  has_one :freelancer, dependent: :destroy ....

model 2 :

class Freelancer < ApplicationRecord
  include EnsureUUID

    belongs_to :user
    validates_uniqueness_of :user_id
end

if I write :

field :from_user, UserType, null: true, method: :user

in my freelancer_type declaration all is ok !

if I write :

field :from_user, UserType, null: true

schema is BAD !

My question is what is "method: :user" doing ?? I couldn't find in documentation...

Nithin
  • 3,679
  • 3
  • 30
  • 55

1 Answers1

0

You can just do

field :user, UserType, null: true

which will work!

ok what does method do?

It acts like an alias for field name provided, field name here is from_user which I believe caller(front-end) knows/identifies/wants to be.

field :from_user, UserType, null: true, method: :user
Nithin
  • 3,679
  • 3
  • 30
  • 55