Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Add ability to dynamically set nested schema type #415

Conversation

OliverJAsh
Copy link
Contributor

@OliverJAsh OliverJAsh commented Aug 27, 2019

Problem

Reinstates #159, which was unfortunately lost when v3 was released.

Fixes https://github.com/paularmstrong/normalizr/issues/413

Related: https://github.com/paularmstrong/normalizr/issues/130

I will update documentation once the code side of things has been approved.

/cc @paularmstrong @jgutta @fxck @joewestcott

TODO

  • Add & update tests
  • Ensure CI is passing (lint, tests, flow)
  • Update relevant documentation

@coveralls
Copy link

coveralls commented Aug 27, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling a2ff910 on OliverJAsh:oja/feature/dynamic-nested-schema into 3246f91 on paularmstrong:master.

@OliverJAsh OliverJAsh marked this pull request as ready for review August 27, 2019 18:22
@OliverJAsh
Copy link
Contributor Author

OliverJAsh commented Sep 2, 2019

Hi @paularmstrong @gaearon. Is there anyone who maintains normalizr that might be available to review this?

@OliverJAsh
Copy link
Contributor Author

Hi @paularmstrong @gaearon. Sorry to pester but this is blocking us at Unsplash from upgrading from v2 to v3. Would you mind reviewing, or do you know anyone who can? Thanks 😄

@OliverJAsh
Copy link
Contributor Author

Ping @paularmstrong

const user = new schema.Entity('users');

const responseSchema = new schema.Object({ users: new schema.Array(user) });
const normalizedData = normalize(data, responseSchema);
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these added brackets do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They provide unique block scope for each of the tests, so I can redeclare variables using the same name.

@BrentFarese
Copy link

Coming across this a while after it was posted/implemented, but has anyone noticed that this approach doesn't seem to work when calling denormalize? We had the approach working successfully for normalize, but denormalize fails always with schema.denormalize is not a function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Normalize union nested inside of array
4 participants