Skip to content

Conversation

idlechara
Copy link

Currently there is no way to pass top-level meta objects in the current implementation as it only filters for pagination options, record_count and page_count.

This line allows to jsonapi_render to include top-level meta information in the following way:

jsonapi_render json: MyResource.first, status: :ok, options: { meta: { author: "Erik Regla", pls_approve_dis: "true" } } 

@npendery
Copy link

Any hold up on this change. It would be very useful!

# @api private
def result_options(records, options)
{}.tap do |data|
data[:meta] = options.fetch(:meta, {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if data[:meta] has record counts already, but id maybe merge the two instead of assigning

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data[:meta] = options.fetch(:meta, {})
data[:meta] = data.fetch(:meta, {}).merge(options.fetch(:meta, {}))

@kceb
Copy link

kceb commented Aug 19, 2021

@tiagopog could we add this? It would be very useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants