Allow passing AR records to jsonapi_* http operations #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale: the
jsonapi_*
helpers for GET/POST/PUT/PATCH/DELETE each accept a url. In many api specs, the url can be derived from the ActiveRecord record(s) that are created before-hand. This allows the specs to pass the AR records to the jsonapi_* helpers directly and have the URL derived from the model the same way that Rails derives its routing for a given AR model instance.that allows
make_request
subjects like:jsonapi_get order
,jsonapi_put user
,jsonapi_delete card
and for index:jsonapi_get products_path
Initial slack discussion: https://graphiti-api.slack.com/archives/C5A4UEMGS/p1658959255745979
The url_for helper still accepts a regular string, so it should be backwards compatible with existing usage.