wesbos
04/03/2018, 7:14 PMnilan
04/03/2018, 7:23 PMdb
object to the context. Is this what you need?wesbos
04/03/2018, 7:23 PMwesbos
04/03/2018, 7:26 PMserver.context().db
?nilan
04/03/2018, 7:26 PMwesbos
04/03/2018, 7:27 PMwesbos
04/03/2018, 7:28 PMwesbos
04/03/2018, 7:28 PMschickling
04/03/2018, 7:30 PMschickling
04/03/2018, 7:31 PMserver.context().db
but rather use the injected context
argument (3rd argument)wesbos
04/03/2018, 7:31 PMwesbos
04/03/2018, 7:31 PMwesbos
04/03/2018, 7:31 PMschickling
04/03/2018, 7:32 PMwesbos
04/03/2018, 7:32 PMwesbos
04/03/2018, 7:33 PMschickling
04/03/2018, 7:33 PMcreateServer
fn?wesbos
04/03/2018, 7:33 PMlawjolla
04/03/2018, 7:50 PMdb
outside of the GraphQLServer
constructor so I could pass it to middlewarewesbos
04/03/2018, 7:51 PMwesbos
04/03/2018, 7:51 PMlawjolla
04/03/2018, 7:51 PMwesbos
04/03/2018, 7:51 PMlawjolla
04/03/2018, 7:51 PMgetUser
is just a function taking the middleware arguments and the databasewesbos
04/03/2018, 7:53 PMwesbos
04/03/2018, 7:56 PMlawjolla
04/03/2018, 8:00 PMinfo
object. I have to keep rereading the Nik's blog post. It's one of those where every time I read it, I get something new. https://blog.graph.cool/graphql-server-basics-demystifying-the-info-argument-in-graphql-resolvers-6f26249f613alawjolla
04/03/2018, 8:02 PMdb.query.users({}, '{ id }')
will give you just the id backlawjolla
04/03/2018, 8:03 PMinfo
, it will return whatever was queried, e.g. { users { id name email } }
wesbos
04/03/2018, 8:03 PMwesbos
04/03/2018, 8:03 PMlawjolla
04/03/2018, 8:04 PMlawjolla
04/03/2018, 8:04 PMposts
relations, you won't get any postswesbos
04/03/2018, 8:05 PMwesbos
04/03/2018, 8:05 PMwesbos
04/03/2018, 8:06 PMlawjolla
04/03/2018, 8:06 PMdb.query.user({...}, '{ id posts { id } }'
wesbos
04/03/2018, 8:06 PMlawjolla
04/03/2018, 8:07 PMwesbos
04/03/2018, 8:07 PMnilan
04/03/2018, 9:29 PM