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

Relationships not present in included resources #640

Open
nickschot opened this issue Jan 16, 2017 · 7 comments
Open

Relationships not present in included resources #640

nickschot opened this issue Jan 16, 2017 · 7 comments

Comments

@nickschot
Copy link
Contributor

nickschot commented Jan 16, 2017

When requesting to include records for relationships of the requested record (i.e. my-model?include=something1,something2, the relationships of those records are not included in the response.

I think this throws off at least ember-data a bit as it won't recognise any relationships for those records.

EDIT: some more information for this added below.

Example request:
GET /my-model/1?include=something

Example response from Lux (with the missing relationships for the records in "included"):

{
  "data": {
    "id": "1",
    "type": "my-model",
    "attributes": {
         ...
    },
    "relationships": {
      "something": {
        "data": {
          "id": "30",
          "type": "something"
        },
        "links": {
          "self": "http://localhost:5000/something/30"
        }
      }
    }
  },
  "included": [
    {
      "id": "30",
      "type": "something",
      "attributes": {
        ...
      },
      "links": {
        "self": "http://localhost:5000/something/30"
      }
    }
  ],
  "links": {
    "self": "http://localhost:5000/my-model/1?include=something"
  },
  "jsonapi": {
    "version": "1.0"
  }
}
@zacharygolba
Copy link
Contributor

I believe this is actually an error in the ember-data implementation, not Lux. See this section of the JSON API spec.

I'm going to close this issue for now.

@nickschot
Copy link
Contributor Author

nickschot commented Jan 16, 2017

-- oops, thought it was another issue.

EDIT: improvements to the first post to better clarify what this specific feature request is.

@zacharygolba zacharygolba reopened this Jan 16, 2017
@nickschot nickschot changed the title Relationships not included in included resources Relationships not present in included resources Jan 16, 2017
@nickschot
Copy link
Contributor Author

nickschot commented May 18, 2017

Can be enabled by toggling this boolean:

formatRelationships: false

@lehni
Copy link

lehni commented May 31, 2017

@nickschot I believe the lines have shifted since your link. Did you mean formatRelationships?

@nickschot
Copy link
Contributor Author

They seem to have! And I do! Thanks for pointing that out. I modified the comment with a more resilient link.

@lehni
Copy link

lehni commented May 31, 2017

How / where are you setting this value to true?

@nickschot
Copy link
Contributor Author

I am not currently. It can be set to true in the lux codebase as pointed out in the comment as an initial fix for this issue, some tests would need to be added though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants