13 ms·
I don't think necessarily GraphQL is hard to understand as a concept. It's just difficult to figure out how to use it in an actual app context. How do I handle
by abhisuri97 8y ago
I don't think necessarily GraphQL is hard to understand as a concept. It's just difficult to figure out how to use it in an actual app context. How do I handle more complicated things such as authentication and, more importantly, what are acceptable and secure ways to structure your queries for auth (and things like that). I can certainly hack around with `context`, I just don't know what is actually good or not.
- sgrove 8y ago> I don't think necessarily GraphQL is hard to understand as a concept It was surprising to us as well! But working with lots of users who are new to GraphQL, there are a few speed bumps along the way before you get to "implementing GraphQL in production." You have to convince your GraphQL users that: 1. It won't take too long to understand 2. It will be worth the effort Anything you can do to make building a valid GraphQL query (both syntactically and semantically) faster helps with #1, and will get your users further along. Making it so that users can see success/data flowing in as quickly as possible helps with #2. From there, like you mentioned, there are lots of additional challenges, but for this post we're focusing on getting new users over the most initial hurdles.
- headcanon 8y agoI don't know what the stack you're working with looks like, but authentication can be done the same way as a REST API would - wherever you have your top-level handler that receives the HTTP request can accept/reject the request if it is invalid. So for example, you'd use the same express middleware you would normally if that was your stack. Its a bit simpler to wrap your head around from that perspective if you just think of it as any other POST request. Authorization, that is, allowing users access to some things but not others, is more complicated and of course bespoke to your application. The simple solution is to simply check context in individual resolvers, which ends up looking a lot like a normal Express/Flask/Sinatra app. There is a graphql-middleware package that helps structure "middleware" resolvers, and a graphql-shield package that helps with more complicated role-based logic.
- PostThisTooFast 8y agoI was excited about GraphQL; but it doesn't seem to handle the majority of queries I need to do, which involve joins. I know other people have encountered the same issue with GraphQL. What's the solution? Thanks!