在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屋!