-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication/Authorization/Bussiness logic #11
Comments
Hi @ugros, These are all things that I want to tackle at some point, I don't have clearly defined solutions yet but I can at least give you an idea. It seems like the project could eventually become a kind of self hosted Graph.cool or Scaphold.io, so when in doubt I'm more than happy to follow in their very clever foot steps!
Unfortunately I can't tell you when any of this will get done – this isn't my day job! But know that I'm very open to suggestions, pull requests and discussion! |
Hello, @dpeek, thanks for the answer!
I don't think I understand. Is this already implemented? I currently don't have time to analyze the code, and make a reasonable pull request, so I'll atleast suggest a dgraphQL API I would like to see :) Hook API: import { mutationHook, resolverHook } from 'dgraphql'
Basically, schema/mutation would be still generated from schema string. Parameters for hooks: Hook should return either:
Currently, the schema (type string) is supplied to DgraphQL client.
Other things (like parsing bearer token and autoinjecting current user to the context) seem like a lot of work, but hopefully hooks wouldn't be so much work for you and this would allow us to solve majority of the problems above (at least to some degree). Anyway, thanks for the great work so far. I've analyzed a lot of graphQL projects/starter kits and this one is as close to what I'd ultimately want to work with as possible. ;) |
Could be a JWT verification between the mutations and the queries. And some API gateway take care of craft of create the tokens. |
If we're talking about ACL in general, mentioning Graph.cool service, one has to look no further than their "permission queries". Those things are so powerful there is basically nothing you can't do with them. Would like to hear what others think. |
Hello,
I like how easy it is to get a working GraphQL backend-data service with this project.
I'd like to test this on a small production project, but before I do, I'd like to find a way to solve some common issues:
1. Authentication
I guess this could be implemented as an express (connect-type) authentication middleware, that would first read JWT, make a dgraph query for a user, and then put authenticated user to the graphql context.
2. Authorization
Let's say we have an authenticated user (and his role) in a graphql context. How would I restrict certain users from reading/manipulating data that should be restricted to them?
I know I can make my own mutations/queries with custom logic, but I would loose all the nice features of the auto-generated queries/mutations.
3. Bussiness logic
Let's say I wan't to send an email after creating a user (after performing a createUser mutation). Where would I put this "send email" logic?
I really have no clue how I would solve this. Maybe some kind to extend some of the auto-generated queries/mutations with custom "hooks"?
Thanks for any suggestion or answer!
The text was updated successfully, but these errors were encountered: