在GraphQL Apollo Server v2.0中暴露HTTP GET API[英] Expose HTTP GET API in GraphQL Apollo Server v2.0

本文是小编为大家收集整理的关于在GraphQL Apollo Server v2.0中暴露HTTP GET API的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在使用Apollo Server v2.0(无中间件)作为我项目的一部分,我想添加对HTTP获取终点的支持以进行文件下载.有没有办法在不使用apollo-server-express的情况下公开API端点?

谢谢

推荐答案

否. apollo-server当前在引擎盖下使用express,而Express实例并未在ApolloServer实例上公开为属性.为了公开任何其他端点,您需要迁移到apollo-server-express或任何其他可用框架集成.由于API几乎相同,因此迁移相对无痛.

本文地址:https://www.itbaoku.cn/post/1938140.html

问题描述

I am using Apollo Server v2.0 (without middleware) as part of my project and I would like to add support for a HTTP GET endpoint to for file downloads. Is there a way to expose an API endpoint without using apollo-server-express?

Thank you

推荐答案

No. While apollo-server currently uses express under the hood, the Express instance is not exposed as a property on the ApolloServer instance. In order to expose any additional endpoints, you'd need to migrate to apollo-server-express or any of the other available framework integrations. The migration is relatively painless since the APIs are almost identical.