VulcanJS / Vulcan-Starter

VulcanJS starter repo. Use as a base for your own VulcanJS projects.
MIT License
127 stars 88 forks source link

Example-forum 1.12.3: GraphQL error: Cannot read property 'postedAt' of undefined #80

Closed calinn closed 6 years ago

calinn commented 6 years ago

When I'm going to insert a new post or edit a post, after I clicked submit button, it shows:

TypeError: Cannot read property 'postedAt' of undefined
W20180903-17:00:33.205(-5)? (STDERR)     at Object.onCreate (packages/example-forum/lib/modules/posts/schema.js:62:17)
W20180903-17:00:33.205(-5)? (STDERR)     at Promise.asyncApply (packages/vulcan:lib/lib/server/mutators.js:93:43)
W20180903-17:00:33.206(-5)? (STDERR)     at C:\Users\Carlos\AppData\Local\.meteor\packages\promise\0.11.1\npm\node_modules\meteor-promise\fiber_pool.js:43:40
W20180903-17:00:33.206(-5)? (STDERR)  => awaited here:
W20180903-17:00:33.207(-5)? (STDERR)     at Function.Promise.await (C:\Users\Carlos\AppData\Local\.meteor\packages\promise\0.11.1\npm\node_modules\meteor-promise\promise_server.js:56:12)
W20180903-17:00:33.207(-5)? (STDERR)     at Promise.asyncApply (packages/vulcan:core/lib/modules/default_mutations.js:58:9)
W20180903-17:00:33.207(-5)? (STDERR)     at C:\Users\Carlos\AppData\Local\.meteor\packages\promise\0.11.1\npm\node_modules\meteor-promise\fiber_pool.js:43:40
SachaG commented 6 years ago

Are you using the latest versions of both Vulcan core packages and the Starter repo?

adalidda commented 6 years ago

I got the same bug using the latest build of Vulcan core and starter repo (master branch).

Thank You

calinn commented 6 years ago

Yes, i'm using vulcan:core 1.12.3. In fact, I only update vulcan-starter and vulcan:core repo (master branch) when I can find both latest same versions to update.

I have to do the followings changes in example-forum 1.12.3 to run my proyect

onCreate: ({document: post, currentUser}) => onCreate: ({newDocument: post, currentUser}) onUpdate: ({data, post}) => onUpdate: ({data, document: post}) onCreate: ({post}) => onCreate: ({newDocument: post}) onCreate: ({document, currentUser}) => onCreate: ({newDocument: document, currentUser})

I based on: https://github.com/VulcanJS/Vulcan/blob/f0fb423b3f88740db6354e4bcebed15c241c785e/packages/vulcan-lib/lib/server/mutators.js#L94

https://github.com/VulcanJS/Vulcan/blob/f0fb423b3f88740db6354e4bcebed15c241c785e/packages/vulcan-lib/lib/server/mutators.js#L205

is that correct?