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

Mongoose Model Support Attempt 1 - Failed #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

natac13
Copy link
Contributor

@natac13 natac13 commented Sep 14, 2020

Hey @arackaf I was really trying to get the support for Mongoose models done so that I can use this library rather than my hack job of it. Plus this can finish #2. However I have run into a few problems that I am hoping you can help with.

I have duplicated all the tests from testProject1 to testProject11 as per your instructions
My issue right now is trying to get the embedded Author document to work with Book Model. For some reason I cannot get the generated GraphQL to set the Author for the get type() function.

Please look over
test/testProject11/projectSetup.js
test/mongooseHelpers/*
And on lines 261 & 301 of src/mongooseHelpers.js for where I am attempting to use the arrayOf and objectOf types

PS I have borrowed heavily from graphql-compose-mongoose, as I am not a 'power' user of Mongoose. Especially the convertTypes file.

@arackaf
Copy link
Owner

arackaf commented Sep 16, 2020

@natac13 howdy - thanks for the PR. I'll try to get to this as soon as possible - probably over the weekend. If you can think of any other context that might be helpful, feel free to add it :)

@natac13
Copy link
Contributor Author

natac13 commented Sep 16, 2020

No problem. Ill keep trying as well!

Note most of the added files are just me copying the testProject1folder to start the testProject11 folder

@natac13
Copy link
Contributor Author

natac13 commented Sep 18, 2020

From my last commit you can see that I am getting most of the structure correct. Except when it comes to the sub documents. As the dataTypes.js functions will modify the existing type object. I am not sure how to do this when I just take in a mongoose model.

You can see from my test the difference in returned values.

@natac13
Copy link
Contributor Author

natac13 commented Sep 18, 2020

If you run the test now I am trying to just generate the graphql from createGraphqlSchema, by passing in a mongoose option flag. It works with just Author, however when I do Author and Books the Book authors and primaryAuthor get type() do no populate as expected.

@arackaf
Copy link
Owner

arackaf commented Sep 21, 2020

Ugh - this slipped my mind this weekend - sorry. Will look this week.

@arackaf
Copy link
Owner

arackaf commented Sep 27, 2020

Ok I'm trying to find the point at which this breaks, but I'm having a hard time. When running test suite 11 I get this

You provide incorrect mongoose model to createMGSOutput(). Correct model should contain modelName property.

The line numbers from your original comment no long appear to pinpoint where this fails. I'm seeing these calls

export const Book = createMGSOutput(BookModel);

Should that be using the BookSchema instead of the BookModel?

Otherwise I'm afraid I need more of a pinpointed location of where exactly this is failing if I'm gonna try to help.

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

Successfully merging this pull request may close these issues.

2 participants