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 without data #2

Closed
eiktyrner opened this issue Feb 3, 2017 · 5 comments
Closed

Relationships without data #2

eiktyrner opened this issue Feb 3, 2017 · 5 comments
Assignees

Comments

@eiktyrner
Copy link

This throws Cannot read property 'id' of undefined

      "relationships": {
        "movie": {
          "links": {
            "self": "http://localhost:3000/api/v1/actor/1c9d234b-66c4-411e-b785-955d57db5536/relationships/movie",
            "related": "http://localhost:3000/api/v1/actor/1c9d234b-66c4-411e-b785-955d57db5536/movie"
          }
        }
      }

While this works.

      "relationships": {
        "movie": {
          "data": { "type": "movie", "id": "9" },
          "links": {
            "self": "http://localhost:3000/api/v1/actor/1c9d234b-66c4-411e-b785-955d57db5536/relationships/movie",
            "related": "http://localhost:3000/api/v1/actor/1c9d234b-66c4-411e-b785-955d57db5536/movie"
          }
        }
      }

It seems that a data object is assumed for each relationship even though the spec says it's not required.

@yury-dymov
Copy link
Owner

@eiktyrner, thank you for the feedback. Before diving into the implementation, I would like to discuss more business side of the issue.

Are we talking about lazy loading here? We know that movie object exists and related to the parent object, but we will load it only at the time we really need it?

@yury-dymov yury-dymov self-assigned this Feb 3, 2017
@eiktyrner
Copy link
Author

@yury-dymov That is indeed one case where this could happen. The point is that this library needs to follow the whole spec before it's usable, regardless of business case.

@yury-dymov
Copy link
Owner

@eiktyrner, I agree with you regarding the spec. The point here is that I need to understand exact business cases for the optimal implementation.

Well, for json-api-normalizer it would be easy but for redux-object there would be no "easy fix" as far as I can see.

@yury-dymov
Copy link
Owner

yury-dymov commented Feb 3, 2017

Should be resolved via 9eba58b, please check.

redux-object will not support lazy loading as for now. I need to think regarding a good API for such occasion.

Update: implementation details: https://github.com/yury-dymov/json-api-normalizer#lazy-loading

@eiktyrner
Copy link
Author

Thanks for the quick help, that seems to solve my issue.

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

2 participants