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

The result after serialize will not have included if the input doesn't have attributes #128

Closed
yidongw opened this issue Aug 16, 2021 · 5 comments

Comments

@yidongw
Copy link

yidongw commented Aug 16, 2021

Considering this data

  {
      id: 'u999',
      name: 'Awesome Project',
      description: 'This is an awesome project',
      format: {
        id: 'u1',
        inputFormats: [ 'u45', 'u46' ],
        outputFormats: [ 'u47', 'u48' ],
      }
    }

with this serializer

serializer.register("projects", {
  whitelist: ["name", "description"],
  relationships: {
    format: {
      type: 'format',
    }
  },
});

serializer.register("format", {
  relationships: {
    inputFormats: {
      type: 'inputFormats',
    },
    outputFormats: {
      type: 'outputFormats',
    }
  }
});

After serializing the data, it will not serialize the [ 'u45', 'u46' ] and [ 'u47', 'u48' ] and include the results in the included, unless I have some attributes in the format serializer and provide that attributes in the format in the data

Another thing is I can't have an empty list of attributes (whitelist). AFAIK JSON API doesn't say we have to have attributes in the resource

@danivek
Copy link
Owner

danivek commented Sep 14, 2021

it closes the first issue you mentioned.

For the empty list of attributes a major version is required because the default value of this option is a currently empty list.

It needed a new issue.

@danivek
Copy link
Owner

danivek commented Sep 15, 2021

@yidongw Actually, a possible workaround to have an empty list of attributes is to use the option like that: whitelist: ['']

@groyoh
Copy link

groyoh commented Sep 15, 2021

@danivek thanks for this fix! I faced this bug earlier today and saw it fixed on master when checking the codebase. Would it be possible for you to create a patch release?

@danivek
Copy link
Owner

danivek commented Sep 15, 2021

@groyoh v2.6.4 🎉

@groyoh
Copy link

groyoh commented Sep 15, 2021

Thanks @danivek ! 🙌

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