Closed mschipperheyn closed 5 years ago
as far as i know associations work only with passing in a sequelize association. its not enough to only associate via graphql fields Like here in Line 7 https://github.com/mickhansen/graphql-sequelize/blob/master/examples/graphql-yoga/src/models/User.js or another example here https://github.com/brianschardt/node_graphql_apollo_template/blob/master/src/graphql/user/user.map.ts
@bullsei Yes, did that of course. Sorry, my code example was incomplete: I will adjust the original post
So, it turns out my code was incomplete. I needed to add a type primitive as a root resolver.
User: {
pets: (parent, args, context, info) => {
return parent.getPets();
},
},
So, it turns out my code was incomplete. I needed to add a type primitive as a root resolver.
User: { pets: (parent, args, context, info) => { return parent.getPets(); }, },
Thanks a lot! That works perfect for me! 🙌
I'm trying to follow the example, but associations are not picked up.
When I look up
no pet related query is executed.
pets
is an empty array. I was assuming I could use a string based schema definition like in the example repo and didn't implement the manual schema definition like on the homepage. (I expectgraphql-sequelize
to figure out the associations for me).