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

Resource option always_include_linkage_data: true not working #1394

Open
2 of 7 tasks
tpetrone opened this issue Sep 29, 2022 · 5 comments
Open
2 of 7 tasks

Resource option always_include_linkage_data: true not working #1394

tpetrone opened this issue Sep 29, 2022 · 5 comments

Comments

@tpetrone
Copy link

tpetrone commented Sep 29, 2022

This issue is a (choose one):

  • Problem/bug report.
  • Feature request.
  • Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.

Checklist before submitting:

  • I've searched for an existing issue.
  • I've asked my question on Gitter and have not received a satisfactory answer.
  • I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
  • The feature I'm asking for is compliant with the JSON:API spec.

Description

Choose one section below and delete the other:

Bug reports:

Under Rails 6 (6.1.7), at the latest gem version (0.10.7) , using always_include_linkage_data: true option does not return type and id of a given relationship. Downgrading to 0.9.12 solves the issue without any code modification.

@tpetrone tpetrone changed the title always_include_linkage_data: true not working Resource option always_include_linkage_data: true not working Sep 30, 2022
@lucaslm
Copy link

lucaslm commented Feb 4, 2023

I'm using this same version at work. Like you, I also needed the "data" key with the type and id of the related resource inside the "relationships" key, for each resource I tried to retrieve on a list. I've tried using "always_include_linkage_data: true" on the relation definition of the resource class I was fetching. I didn't work too, but I managed to get what I whanted by adding the include query parameter as defined by the JSON:API spec, asking for the related resource as well.
Of course, it also brought the "included" key (on the top level of the response) with all the related resources (and all their attributes), which in my case is a waste of net band.
Anyway, good luck.

@tpetrone
Copy link
Author

Hi @lucaslm
Are you using this gem in production environment at work?

@timrwood
Copy link

I ran into this as well.

I think the documentation is outdated, as it references always_include_linkage_data, but the code uses always_include_optional_linkage_data as the option name:

@always_include_optional_linkage_data = options.fetch(:always_include_optional_linkage_data, false) == true

@lucaslm
Copy link

lucaslm commented May 29, 2023

Hi @lucaslm Are you using this gem in production environment at work?

Yes

@lucaslm
Copy link

lucaslm commented May 29, 2023

It seems this option does not work when the relationship is toMany (but requiring the resource through the include query parameter does, as I explained).

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

No branches or pull requests

3 participants