在 GraphQL Apollo Server v2.0 中公开 HTTP GET API [英] Expose HTTP GET API in GraphQL Apollo Server v2.0
问题描述
我使用 Apollo Server v2.0(不带中间件)作为我项目的一部分,我想添加对 HTTP GET 端点的支持以进行文件下载.有没有办法在不使用 apollo-server-express 的情况下公开 API 端点?
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?
谢谢
推荐答案
没有.虽然 apollo-server
目前在幕后使用 express
,但 Express 实例并未作为 ApolloServer
实例的属性公开.为了公开任何其他端点,您需要迁移到 apollo-server-express
或任何其他可用的框架集成.迁移相对轻松,因为 API 几乎相同.
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.
这篇关于在 GraphQL Apollo Server v2.0 中公开 HTTP GET API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!