Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

getPopulatableFields fails when cloning schemae #21

Open
hennessyevan opened this issue Oct 23, 2019 · 0 comments · May be fixed by #20
Open

getPopulatableFields fails when cloning schemae #21

hennessyevan opened this issue Oct 23, 2019 · 0 comments · May be fixed by #20
Labels
bug Something isn't working

Comments

@hennessyevan
Copy link

hennessyevan commented Oct 23, 2019

Describe the bug
In mongoose, cloning models produces some internal fields that are picked up by mode.schema.eachPath() that have no types which causes an error on Line 183 of registry.ts and other lines following where type is expected to be defined but in fact is undefined.

To Reproduce
Create a schema and a clone it for that model as in the example in the Mongoose Docs

Expected behavior
Mogr should ignore such typeless fields as they are only for internal mongoose/(user?) logic and not projectable anyways.

Desktop (please complete the following information):

  • OS: macOS 10.15
  • NodeJS Version: 10.16.3
  • GraphQL Version: 14.5.8
  • Mongoose Version: 5.7.5

I imagine just adding a simple

if (!type) {
  return []
}

before Line 183 of registry.ts should do the trick

@hennessyevan hennessyevan added the bug Something isn't working label Oct 23, 2019
hennessyevan added a commit to ParishConnect/mogr that referenced this issue Oct 23, 2019
@hennessyevan hennessyevan linked a pull request Oct 23, 2019 that will close this issue
hennessyevan added a commit to ParishConnect/mogr that referenced this issue Oct 23, 2019
@hennessyevan hennessyevan changed the title getPopulatableFields fails on Model Discriminator types getPopulatableFields fails when cloning models Oct 23, 2019
@hennessyevan hennessyevan changed the title getPopulatableFields fails when cloning models getPopulatableFields fails when cloning schemae Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant