Skip to content

Only Option Not Correct for Nested Value #181

Open
@Linell

Description

@Linell

I have a couple entities that look like this:

class Foo::Entity < Grape::Entity
  expose :id, :foo_name
end

class Bar::Entity < Grape::Entity
  expose :id, :stuff, :things

  expose :foo, :using => Foo::Entity
end

In the resource for Bar, I'm doing

get '/' do
  present @bars.index(:limit => @limit), :only => @only
end

For the first layer, this works great. For example, passing [:id, :things] to @only works perfectly. Passing nothing to @only results in me getting the full Foo object too, which is exactly what I want.

The issue arises when I pass [:id, :things, {:foo => [:foo_name]}]. Instead of the expected id, things, and foo hash containing foo_name, I get back id, things and a foo hash containing just the foo object's id.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions