Fork me on GitHub
#graphql
<
2019-04-11
>
hlship16:04:19

There's a reason that we parse the query in one interceptor, and execute it in a later interceptor. There's a point in the middle where you can identify what the operation is. Our code at Walmart uses that opportunity to apply auth, and whitelist what operations a given API key is allowed to access.

orestis20:04:53

Good pointer! I guess this would be the place to also add logging etc right?

donaldball17:04:55

I’m simply building my authorization checks for mutations atop the mutations’ resolver fns, though if there grew to be a bunch of them, separate interceptors would be easier to validate. But my question was at a slight remove from that: I wanted a query that could tell me if a given mutation (with some subset of args) might be authorized. I now have a :may query which takes a mutation name and an json string map of args and returns a boolean, which is reasonable, if a little annoying what with the map smuggling.