arackaf / mongo-graphql-starter

Creates a fully functioning, performant, extensible GraphQL endpoint from a Mongo DB. Supports middleware, Mongo 4 transactions.
MIT License
423 stars 29 forks source link

On Update, inserting existing ObjectId #28

Closed ekajogja closed 6 years ago

ekajogja commented 6 years ago

Problem: During creation, input Id (of existing document) is correctly stored as ObjectId. However, during update, input Id is stored as string.

  1. On playground, I use Updates: { fieldId: "${document._id}" } since I need to insert existing doc instead of creating a new one. screen shot 2018-09-10 at 06 31 43

  2. Query result after update is good. screen shot 2018-09-10 at 06 23 22

  3. But the oid was stored as string in 1st doc, compared to 2nd doc which was stored during creation. screen shot 2018-09-10 at 06 02 26

Any advise on how to make Update input also stores as ObjectId? Thank you.

arackaf commented 6 years ago

How is indukOrganisasiId defined in the schema you made for mongo-graphql-starter? Ie, the code here:

https://github.com/arackaf/mongo-graphql-starter#how-do-you-use-it

Did you use MongoIdType? If so, then the value you send should be cast as ObjectId before saved. If it's defined like that, but the wrapping is not happening, then this is definitely a bug. Let me know

ekajogja commented 6 years ago

Yes, I used MongoIdType screenshot_2018-09-12-16-58-54 2 screenshot_2018-09-12-17-00-08 2

arackaf commented 6 years ago

Hm ok thanks - I’ll have a look

arackaf commented 6 years ago

Hey! Version 0.6.24 is out, which should fix this. Thanks, and let me know if you see further issues!