Skip to content

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

Closed
@yidongw

Description

@yidongw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions