【发布时间】:2017-05-01 20:33:15
【问题描述】:
如何使用 Angular2 使用 npm apollo-client 添加自定义标头并在请求正文中引入其他自定义变量。我希望在我的 graphQL 查询中引入一个额外的自定义变量,例如请求正文中的默认“变量”对象以及自定义标头。我尝试使用 createNetworkInterface 的 applyMiddleware。
以下是预期的请求正文格式:
{
"query":"",
"variables":"{}",
"customVariable":"{}", //This is additional which wants to be introduced
"operationName":""
}
【问题讨论】:
-
你试过什么?在此处查看有关中间件的文档,他们可以按照您喜欢的方式修改请求:dev.apollodata.com/core/network.html#networkInterfaceMiddleware
标签: angular typescript xmlhttprequest graphql apollo-server