我们已经实现了模式拼接,其中GraphQL服务器从两个远程服务器获取模式并将它们拼接在一起.当我们只使用Query和Mutations时,一切都运行正常,但现在我们有一个用例,我们甚至需要缝合订阅,远程模式已经通过它实现了auth.
我们很难搞清楚如何通过网关将connectionParams中收到的授权令牌从客户端传递到远程服务器.
这就是我们如何反省架构:
API网关代码:
const getLink = async(): Promise<ApolloLink> => {
const http = new HttpLink({uri: process.env.GRAPHQL_ENDPOINT, fetch:fetch})
const link = setContext((request, previousContext) => {
if (previousContext
&& previousContext.graphqlContext
&& previousContext.graphqlContext.request
&& previousContext.graphqlContext.request.headers
&& previousContext.graphqlContext.request.headers.authorization) {
const authorization = previousContext.graphqlContext.request.headers.authorization;
return {
headers: {
authorization
}
}
}
else {
return {};
}
}).concat(http);
const wsLink: any = new WebSocketLink(new SubscriptionClient(process.env.REMOTE_GRAPHQL_WS_ENDPOINT, {
reconnect: true,
// There is no way to update connectionParams dynamically without resetting connection
// connectionParams: () => …
Run Code Online (Sandbox Code Playgroud) apollo graphql apollo-server graphql-subscriptions graphql-tools
我是Selenium的新手.我只想将密钥发送到用户名文本框并一次发送一个tab键,以便文本框可以检查用户名的可用性.
这是代码:
driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName");
driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys(Keys.TAB);
Run Code Online (Sandbox Code Playgroud)
但是这个没有用.
请帮我.
我正在关注 https://www.graph.cool/docs/1.0/quickstart/backend/typescript/typescript-rohd6ipoo4 for graphcool 并且我收到错误
{
"errors": [
{
"code": 3016,
"requestId": "api:api:cjc7gf91e002v0180uq2hqace",
"message": "Project not found: 'my-app@dev'"
}]}
Run Code Online (Sandbox Code Playgroud)
用于查询和变异。我是 graphcool 的新手,所以不知道为什么会这样。我正在按照上述链接中提供的步骤进行操作。
Graphql 服务器:
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: req => ({
...req,
db: new Graphcool({
endpoint: 'http://localhost:60000/my-app/dev',
secret: 'mysecret123',
}),
}),
})
$ graphcool info
Service Name: my-app
dev (cluster: `local`)
HTTP: http://localhost:60000/my-app/dev
Websocket: ws://localhost:60000/my-app/dev
Run Code Online (Sandbox Code Playgroud)