Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow multiple resource relation retrieval methods #1425

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

bf4
Copy link
Collaborator

@bf4 bf4 commented Jan 4, 2024

This PR was named from my experience that it wasn't letting me have a JSONAPI::Resource with the default retrieval method and also create another resource using the mixin with a different retrieval method.

While working on it, I realized it was possible to apply multiple different retrieval methods. If it's the same, it warns you, which I think is fine, but the new thing is that if it's different, it raises, since I can't imagine anything good could come from intentionally saying 'using v10' but it's already 'v09' and not knowing that 'v09' wasn't included

I saw some slightly different behavior in the JSONAPI::Resource vs. all manual includes so I'll try that in our app and see if it works by 100% avoiding JSONAPI::Resource


  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

New Feature Submissions:

  • I've submitted an issue that describes this feature, and received the go ahead from the maintainers.
  • My submission includes new tests.
  • My submission maintains compliance with JSON:API.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

@bf4 bf4 changed the base branch from master to v0-11-dev January 4, 2024 12:11
@bf4
Copy link
Collaborator Author

bf4 commented Jan 5, 2024

@lgebhardt oh, cool, it's green. Shouldn't be too hard to add a failing test which this makes pass when I'm next at my computer

@bf4 bf4 changed the title ### All Submissions: fix: allow multiple resource relation retrieval methods Jan 5, 2024
@bf4 bf4 force-pushed the include_once_and_only_once_differently branch from 93cea02 to b4905b4 Compare January 17, 2024 07:15
# frozen_string_literal: true

module JSONAPI
module RelationRetrieval
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ideally, I think, this defines the required abstract interface, I think, required for a valid strategy

Copy link
Member

@lgebhardt lgebhardt left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good.

@lgebhardt lgebhardt merged commit 9f436b5 into v0-11-dev Jan 17, 2024
39 checks passed
@lgebhardt lgebhardt deleted the include_once_and_only_once_differently branch January 17, 2024 22:38
lgebhardt added a commit that referenced this pull request Apr 18, 2024
* fix: check if relation retrieval in included via included_modules

* require 'jsonapi/relation_retrieval'

* feat: raise when cannot include different retrieval strategy

* test: multiple retrieval strategies

---------

Co-authored-by: lgebhardt <larry@cerebris.com>
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.

2 participants