Commit 0286ce4
committed
Make context accessible when customizing relationship params
`context` can be useful when customizing params in a relationship. This
makes it accessible in the `params` block by adding it as the third
block variable:
```
class PostResource < ApplicationResource
has_many :comments do
params do |hash, _posts, context|
hash[:filter] = { locale: context.locale }
end
end
end
```
The current workaround is to directly reference
`Graphiti.context[:object]` within the block, which is less desirable
because that private API could change.1 parent 4f0b669 commit 0286ce4
3 files changed
+24
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
437 | 441 | | |
438 | 442 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | | - | |
| 569 | + | |
570 | 570 | | |
571 | | - | |
| 571 | + | |
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | | - | |
577 | | - | |
578 | | - | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| |||
655 | 655 | | |
656 | 656 | | |
657 | 657 | | |
658 | | - | |
| 658 | + | |
659 | 659 | | |
| 660 | + | |
660 | 661 | | |
661 | 662 | | |
662 | 663 | | |
663 | 664 | | |
| 665 | + | |
664 | 666 | | |
665 | 667 | | |
666 | | - | |
| 668 | + | |
| 669 | + | |
667 | 670 | | |
668 | 671 | | |
669 | 672 | | |
670 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
671 | 677 | | |
672 | 678 | | |
673 | 679 | | |
| |||
0 commit comments