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

Apollo context #59

Open
AaronNGray opened this issue Jul 30, 2021 · 0 comments
Open

Apollo context #59

AaronNGray opened this issue Jul 30, 2021 · 0 comments

Comments

@AaronNGray
Copy link

Is it still possible to use Apollo context option for authentication like DataLoader is still avalable through context IIRC seeing the code.

If so how do I do it as the following does not seem to be being called at all.

    app.use("/graphql", bodyParser.json(), vesper(schema, {
        setupContainer: async (container, action) => {
            console.log("setupContainer()");
            const request = action.request;
            const token:string = request.headers["token"] as string || "";

            if (token !== "") {
                const entityManager = getManager();
                const payload = jwt.verify(token, "secret");
                const currentUser = await entityManager.findOneOrFail(User, { id: payload["id"] });

                container.set(User, currentUser);
                console.log("this.currentUser = ", currentUser);
            }
        }
    }));

as the above does not seem to be doing anything a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant