Skip to content
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

Execute some function before each query or mutation? #2609

Closed
rico345100 opened this issue Apr 25, 2019 · 1 comment
Closed

Execute some function before each query or mutation? #2609

rico345100 opened this issue Apr 25, 2019 · 1 comment

Comments

@rico345100
Copy link

Hello, thanks for making great stuff.

I'm making some kind of auth related stuffs. I want to check that the session exists in some queries, however I can't find any related feature that can implement this.

In Express(or Koa/Connect), I can do that with middleware, and I can check the session exists and when it is empty, response as unauthorized request before actual query.

In here, Apollo-Server, middleware is totally different thing, it seems more like "adaptor" or "plugin" stuff that can works with other types of HTTP server.

I don't care what you are calls it, however I just want to process before actual response. How do I execute the function before each query or mutation? Also in that function, is it possible to access "koa context" which session located?

@abernix
Copy link
Member

abernix commented Apr 26, 2019

These docs are in progress (#2008), but you should be able to do what you want with Apollo Server Request Pipeline plugin. You can view a preview of them here: https://deploy-preview-2008--apollo-server-docs.netlify.com/docs/apollo-server/features/plugins.html.

If you have any questions, the best place to ask would be on the Apollo community on Spectrum.chat since GitHub Issues are reserved for bugs.

Thanks!

@abernix abernix closed this as completed Apr 26, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants