Skip to content

Conversation

timkomip
Copy link

@timkomip timkomip commented Apr 7, 2023

History

Setting the readable option on a relationship to a callables (procs, lambdas, etc) would only evaulate on load (once). Conditionally hiding relationships per request was not supported. Feature was disabled

Current State (before PR)

readable option on relationships (has_many, belongs_to) doesn't support callables (procs, lambdas, etc).

This PR

Adds support for setting readable with callables.

Changes

  • Sideload evaluates readable flag every time so that the read conditions can be check against current request (or context)
  • Move readable check to serializer. Sets :if option on JSONAPI::Serializable::Relationship object with lambda that calls sideload.readable?
  • Apply sideload/relationship without checking readable? on sideload since the check will be happening in the serializer.
  • Filters out the include from the include_hash if the current included relationships is not readable.

end

context "when a sideload macro not readable" do
xcontext "when a sideload macro not readable" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

@timkomip why are these skipped now?

@jkeen jkeen added the question label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants