Apollo server express与Apollo federation一起实施

Apollo server express与Apollo federation一起实施,express,graphql,apollo-server,apollo-federation,Express,Graphql,Apollo Server,Apollo Federation,是否有人成功地实现了apollo express服务器(作为网关)和graphQL服务器联盟 我的身份验证方法是通过网关上的REST端点提供的,因此我将apollo express服务器作为顶层运行,但在尝试查询数据时,它不会从其他服务返回任何信息。当我切换到让网关作为一个Apollo服务器运行时,它就可以正常工作,并且可以从连接到它的Apollo联盟的服务中获取数据。但这意味着我必须忽略身份验证的实现以及与服务一起使用的其他REST端点 当前设置: const main=async()=>{

是否有人成功地实现了apollo express服务器(作为网关)和graphQL服务器联盟

我的身份验证方法是通过网关上的REST端点提供的,因此我将apollo express服务器作为顶层运行,但在尝试查询数据时,它不会从其他服务返回任何信息。当我切换到让网关作为一个Apollo服务器运行时,它就可以正常工作,并且可以从连接到它的Apollo联盟的服务中获取数据。但这意味着我必须忽略身份验证的实现以及与服务一起使用的其他REST端点

当前设置:

const main=async()=>{
试一试{
常量app=express();
应用程序使用(函数(_req,res,next){
res.header(“访问控制允许源代码”,`${config.frontend_url}`);
res.header('Access-Control-Allow-Methods',“GET,HEAD,OPTIONS,POST,PUT”);
res.header(“访问控制允许凭据”、“true”);
res.header('Access-Control-Allow-Headers',“Access-Control-Allow-Origin,Access-Control-Allow-Headers,Origin,Accept,X-Request-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization”);
next();
});
使用(cookieParser());
应用程序使用(cookieSession)({
最大值:24*60*60*1000,
keys:[config.cookieKey]
}));
app.use('/auth',loginRouter);
常量服务列表=[
{name:“service”,url:config.service_url+“/graphql”},
{name:“service”,url:config.service_url+“/graphql”},
]
const gateway=新网关({
服务列表,
});
const{schema,executor}=wait gateway.load();
//const schema=wait createSchema();
应用程序使用(
“/graphql”,
支票代币,
graphqlHTTP(请求=>({
模式,
graphiql:是的,
上下文:req
}))
);
应用程序使用(“/”,(((请求,回复)=>{
res.sendStatus(200);
}));
constApolloServer=newApolloServer({schema,executor,playway:true,tracing:false,subscriptions:false})如有;
apolloServer.applyMiddleware({app});
app.listen(config.port,()=>{
console.log(`