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

Defining denormalization in an inversed link before direct link throws wrong error #374

Open
Floriferous opened this issue Aug 15, 2019 · 1 comment

Comments

@Floriferous
Copy link
Contributor

Floriferous commented Aug 15, 2019

If you define an inversed link with denormalization before the direct link, it throws: TypeError: Cannot read property 'isMeta' of undefined.

at:

W20190815-18:12:19.069(2)? (STDERR) TypeError: Cannot read property 'isMeta' of undefined
W20190815-18:12:19.069(2)? (STDERR)     at Linker.isMeta (packages/cultofcoders:grapher/lib/links/linker.js:93:50)
W20190815-18:12:19.069(2)? (STDERR)     at Linker._initDenormalization (packages/cultofcoders:grapher/lib/links/linker.js:410:18)
W20190815-18:12:19.069(2)? (STDERR)     at new Linker (packages/cultofcoders:grapher/lib/links/linker.js:28:14)
W20190815-18:12:19.070(2)? (STDERR)     at _.each (packages/cultofcoders:grapher/lib/links/extension.js:23:28)
W20190815-18:12:19.070(2)? (STDERR)     at Function._.each._.forEach (packages/underscore.js:147:22)
W20190815-18:12:19.070(2)? (STDERR)     at ns.Collection.addLinks (packages/cultofcoders:grapher/lib/links/extension.js:14:11)
W20190815-18:12:19.070(2)? (STDERR)     at undefinedCollectionBug.test.js (server/tests/undefinedCollectionBug.test.js:20:3)

Here's a reproduction:

const B = new Mongo.Collection('b');
const C = new Mongo.Collection('c');
B.addLinks({
  c: {
    collection: C,
    inversedBy: 'bs',
    denormalize: {
      field: 'cCache',
      body: { _id: 1, name: 1 }
    }
  },
});

C.addLinks({
  bs: {
    collection: B,
    field: 'bLinks',
    type: 'many',
    metadata: true,
    autoremove: true,
    unique: true
  }
});

I expect it to throw an error that helps me identify what the issue is.

@Floriferous
Copy link
Contributor Author

A simple way to get around this is to define all your direct links normally, but all your inversed links in Meteor.startup :)

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

1 participant