grape-entity
grape-entity copied to clipboard
Getting separate queries for each attribute of an entity
I am wondering why I am getting a separate query for each attribute of my entity.
For example, here I am asking for a CustomerEntity
and it has more than 40 exposed attributes, and it seems that grape entity ask for each attribute with a separate query:
My entity is:
class CustomerEntity < Grape::Entity
expose :is_wholesale
expose :catch_all
expose :max_managers
expose :max_customizations
expose :max_mailing_lists
expose :max_email_quota
expose :max_email_accounts_archive
expose :max_email_accounts
expose :max_domains
expose :expiration
expose :billing
expose :is_reseller
expose :status_detail
expose :status
expose :code
expose :company
expose :lastname
expose :firstname
# authentication
expose :fakefield2
expose :fakefield
expose :fakefield3
expose :fakefield4
expose :fakefield5
expose :email_address
expose :language
expose :type
end
and I am calling in my endpoint with:
class Users::Authentication < Grape::API
represent Customer, with: CustomerEntity
get do
present(u)
end
Am I doing something wrong?
@ciaoben … please can you provide a Gist, or a Spec, where the behavior would be reproduced? without it, it is pretty difficult to investigate … thanks