Skip to content

Apollo context #59

@AaronNGray

Description

@AaronNGray

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions