I think it would be good to give tutorial that is ...
# random
h
I think it would be good to give tutorial that is most needed in production such as auth, fileupload, multipart upload. I am looking for these three currently.
a
agree, I haven’t found a truly great example yet
are you using authentication with graphql or are you just verifying the token from the authorization header?
h
I am willing to provide jwt token and check in each stage when auth is needed like shown in the medium.
a
Yeah in m case I’d like to just verify the token and add the resolved user into the context
h
I don’t quite know how to achieve that if I understand correctly. Currently, I think you should check the permission inside the query.
If you find better idea I’d want to know either.
a
it is layered. In my case I want to first validate the authtoken itself before graphql gets involved. And then once that is achieved I’d like to run permission checks on queries based on custom directives
h
I see. So you want to achieve like what we normally used in node with jwt and set this in middleware of the express.
a
jep, right now I’m doing it in the context resolver when initializing apollo server
h
Someone tried to achieve things like that here https://www.prisma.io/forum/t/authentication-with-graphql-yoga-prisma-and-middleware/2285. However, I tried this and couldn’t get what I want.
but I don’t like that each query resolver has to call
ctx.user.then()...
h
Yeah this is almost the same approach as what I’ve shared.
a
yeah
I see that approach a lot
that might be interesting for you as well: https://github.com/maticzav/graphql-shield
h
Yeah I’ve seen that. However, I don’t quite like to add more stuff since I feel quite too much now lol.
Looks like this is what you are trying to achieve.
a
interesting, yeah with the exception that I don’t have to generate the tokens
thank you for sharing
👍 1
h
I would just stay for previous practice since I just want to move on to next thing.
a
yeah similar, at the same time I want to do it right as well
happy coding!
🙌 1
h
Check out graphql-shield from @matic
a
yeah we were talking about it, had no clue he’s here! Hiiii 🙌
h
We need tutorial for uploading file and multipart-upload which makes able to upload both the content and file together.