Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript passport应用程序上未接收到Req和Res参数。使用()回调_Javascript_Node.js_Express_Graphql_Passport.js - Fatal编程技术网

Javascript passport应用程序上未接收到Req和Res参数。使用()回调

Javascript passport应用程序上未接收到Req和Res参数。使用()回调,javascript,node.js,express,graphql,passport.js,Javascript,Node.js,Express,Graphql,Passport.js,我正在express中间件上构建以下路径: app.use( "/graphql", passport.authenticate("jwt", { session: false }), appGraphQL() ); 该路由通过passport进行验证,然后调用我的GraphQL服务器 我的GraphQL服务器条目代码是: export default (req, res) => { console.log("RECEIVED PARAMETERS:")

我正在express中间件上构建以下路径:

app.use(
    "/graphql",
    passport.authenticate("jwt", { session: false }),
    appGraphQL()
);
该路由通过passport进行验证,然后调用我的GraphQL服务器

我的GraphQL服务器条目代码是:

export default (req, res) => {
    console.log("RECEIVED PARAMETERS:")
    console.log(req)
    console.log(res)

    return graphqlHTTP({
        schema: schema,
        graphiql: true,
        pretty: true,
        context: {
            resolvers: null, // Will add my resolvers here
            req: req,
            res: res
        },
        formatError: error => ({
            message: error.message,
            locations: error.locations,
            stack: error.stack,
            path: error.path
        })
    });
};
我得到null作为req和res参数


如何将req和res正确发送到GraphQL代码?

您正在立即执行appGraphQL


实际上,它正在执行,但需要执行才能处理我的GraphQL请求。我尝试过appGraphQLreq,res,但也没有成功…我忘了用箭头函数包装
app.use(
    "/graphql",
    passport.authenticate("jwt", { session: false }),
    (req,res) => appGraphQL(req,res)
);