-1

I'm trying to make the Item's Paperclip thumbnail variant available through the GraphQL Ruby gem:

app/graphql/types/item_type.rb:

class Types::ItemType < Types::BaseObject
  description 'An item'
  field :title, String, null: false
  field :thumbnail_image, String, null: true

  def thumbnail_image
    item.image.url(:thumb_2x)
  end
end

This just results in the following error:

"message": "undefined local variable or method `item' for #<Types::ItemType:0x00007ff3f1dbc4e0>"

What's the right way to get this to work? Do I need a resolver?

tirdadc
  • 4,603
  • 3
  • 38
  • 45

1 Answers1

1

Figured it out, I needed to do this:

def thumbnail_image
  object.image.url(:thumb_2x)
end
tirdadc
  • 4,603
  • 3
  • 38
  • 45