Skip to content

Configurable camelizing type values #34

Closed
@antonkomarev

Description

@antonkomarev

As was discovered in PR #33 there is potential issue with camelizing type's values inside relationships data objects.

Despite camelizing option explicitly called: camelizeKeys: true it's affecting type values too.
It will be great to have separate configurable option to camelize type values.

Input:

const json = {
  data: [
    {
      type: 'post',
      relationships: {
        'rel1-to-camelize': {
          data: [
            {
              id: 4,
              type: 'type1-to-camelize',
            },
          ],
        },
      },
      id: 2620,
    },
  ],
};

Output:

const output = {
  post: {
    2620: {
      type: 'post',
      id: 2620,
      relationships: {
        rel1ToCamelize: {
          data: [
            {
              id: 4,
              type: 'type1ToCamelize',
            },
          ],
        },
      },
    },
  },
};

In my point of view this should work by this way:

result = normalize(json, {
    camelizeKeys: true,
    camelizeTypeValues: true,
});

And camelizeTypeValues should be in false state by default.

This is breaking change

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