Giter Site home page Giter Site logo

Comments (4)

Roriz avatar Roriz commented on June 1, 2024 2

up

from jsonapi-serializer.

ev8dev avatar ev8dev commented on June 1, 2024 1

I have hit the same issue, and it appears to be a problem with how the code is detecting recursive relationships. If any of the parents have types that are a substring of the child type they will be detected as a recursive relation e.g. from your example because elements-layouts-profiles contains the string elements it won't keep parsing relations.

To work around this, in deserializer utils I have updated the check to look at type and id instead of just type when detecting a recursion.

...
 function findIncluded(relationshipData, ancestry) {
...
      if (included) {
        // To prevent circular references, check if the record type
        // has already been processed in this thread
        if (ancestry.indexOf(included.type + included.id) > -1) {
...

I noticed I never replied to this, but still thanks @danielpigott.

We distribute this package onto our servers automatically so for now we're still on 3.6.5 since the issue doesn't occur there. It would be nice if this issue could be fixed in a future version so we can use the newest package.

from jsonapi-serializer.

danielpigott avatar danielpigott commented on June 1, 2024

I have hit the same issue, and it appears to be a problem with how the code is detecting recursive relationships. If any of the parents have types that are a substring of the child type they will be detected as a recursive relation e.g. from your example because elements-layouts-profiles contains the string elements it won't keep parsing relations.

To work around this, in deserializer utils I have updated the check to look at type and id instead of just type when detecting a recursion.

...
 function findIncluded(relationshipData, ancestry) {
...
      if (included) {
        // To prevent circular references, check if the record type
        // has already been processed in this thread
        if (ancestry.indexOf(included.type + included.id) > -1) {
...

from jsonapi-serializer.

kln avatar kln commented on June 1, 2024

up

from jsonapi-serializer.

jun-sheaf avatar jun-sheaf commented on June 1, 2024

So support for this library has been down. I've been recently going around the other serializers checking for people who are looking for a better serializer. Over the past few days I've designed a resource-recursive, typescript/javascript library for serializing the entire JSON:API spec. You might want to check it out if this library doesn't fix the recursion :)

Link: https://github.com/jun-sheaf/ts-japi

from jsonapi-serializer.

jun-sheaf avatar jun-sheaf commented on June 1, 2024

@danielpigott @ev8dev @kln @Roriz So I have been going around looking for those who are struggling to find a proper JSONAPI serializer.

Over the past few days I've designed a resource-recursive, typescript/javascript library for serializing the entire JSON:API spec. Our API is far more fluent (and obvious) than the one here (and every other serializer I have seen/used). If this serializer doesn't fit your need, you might want to check it out :) Development is active.

If you are in particular struggling with issues such as links, resource relationships, and deep recursion (essentially any of the complicated parts of the JSON:API spec), I strongly recommend moving to our library.

{TS:JAPI}: https://github.com/jun-sheaf/ts-japi

from jsonapi-serializer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.