Pkmmte
06/01/2018, 11:42 PMallUsers -> users
or
updateUser(*stuff*) -> updateUser(data: *stuff*)virtualirfan
06/01/2018, 11:52 PMPkmmte
06/01/2018, 11:57 PMvirtualirfan
06/02/2018, 12:45 AMrelay, you might be able to write a migration script that creates the handlers using prisma bindings with forwardTo where appropriate and then query calls otherwise filling in the data: and where: fields. IOW, use the entire generated schema file from graph.cool as your new prisma schema and try to autogen the handlers.Pkmmte
06/02/2018, 1:05 AMforwardTo made me find this post:
https://github.com/prismagraphql/prisma-binding/issues/48
Given that I'm already using custom resolvers, I may be able to do things this way. It could work nicely for queries, but mutations might be problematic as I'd essentially be overriding them with themselves. (ex: updateArticle() delegates to updateArticle(data) which may end up calling itself again and never end)
I'll give it a try! How would I autogen the handlers on Prisma? I just started learning about Prisma last week.virtualirfan
06/02/2018, 1:21 AMupdateArticle() in the application's schema would call the updateArticle(data: args) in the Prisma service so there shouldn't be a loop.
Re: autogen, I figured you'd write a shell script or choose your favorite scripting language and iterate over all the types in the original graph.cool schema and generate custom resolvers.virtualirfan
06/02/2018, 1:25 AMPkmmte
06/02/2018, 1:29 AMmergeSchemas from the graphql-tools package to create resolvers on my API Gateway. I wonder if that'll work this way.
Luckily, no. I plan on doing so in the future, but I'm migrating to Prisma first to avoid future migration nightmares such as this. 🙂Pkmmte
06/05/2018, 10:45 PMif (req.body && req.body.query && !req.body.query.includes("(data:")) {
req.body.query = req.body.query.replace(/(mutation{\D*\()(.*)(?=\))/g, '$1data: {$2}');
}
It's dirty, but I only need it temporarily until we update our clients to use the correct syntax.