本地环境:
我在应用程序中使用 Elastic 搜索,并且我希望能够在我的集成测试中使用 TestContainers。使用 ElasticSearch testcontainer 的 Play Framework 应用中的示例代码:
@BeforeAll
public static void setup() {
private static final ElasticsearchContainer ES = new ElasticsearchContainer();
ES.start();
}
Run Code Online (Sandbox Code Playgroud)
这在本地测试时有效,但我希望能够在 Docker 容器中运行它以在我的 CI 服务器上运行。在 Docker 容器内运行测试时出现此异常:
[warn] o.t.u.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /root/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /root/.docker/config.json (No such file or directory)
[warn] o.t.u.RegistryAuthLocator - Failure when attempting …Run Code Online (Sandbox Code Playgroud) 目前,当我使用 firebase 对用户进行身份验证时,我将他们的身份验证令牌存储在localStorage稍后用于连接到我的后端,如下所示:
const httpLink = new HttpLink({uri: 'http://localhost:9000/graphql'})
const authMiddleware = new ApolloLink((operation, forward) => {
// add the authorization token to the headers
const token = localStorage.getItem(AUTH_TOKEN) || null
operation.setContext({
headers: {
authorization: token ? `Bearer ${token}` : ''
}
})
return forward(operation)
})
const authAfterware = onError(({networkError}) => {
if (networkError.statusCode === 401) AuthService.signout()
})
function createApolloClient() {
return new ApolloClient({
cache: new InMemoryCache(),
link: authMiddleware.concat(authAfterware).concat(httpLink)
})
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,一旦令牌过期,我就无法刷新它。所以我尝试使用以下内容为 apollo 设置授权令牌:
const httpLink = new …Run Code Online (Sandbox Code Playgroud) 我开始从 Apollo Client 2.x 迁移到 3.x beta,但在使用 apollo 钩子和现已弃用的查询/变异组件时遇到了问题。
我正在使用这些软件包:
@apollo/client: 3.0.0-beta.4
@apollo/react-components: 3.1.3
Run Code Online (Sandbox Code Playgroud)
在这种情况下,使用 apollo 挂钩可以正常工作,但是使用查询组件时,出现以下错误:
Invariant Violation 无法在上下文中找到“客户端”或作为选项传入。将根组件包装在 中,或通过选项传递 ApolloClient 实例。
我创建了一个代码沙盒,在这里显示了这个问题:https ://codesandbox.io/s/react-example-9p9ym
我认为问题出在ApolloProvider我正在使用的源上,但如果我想使用新的测试版,同时仍然使用查询组件,我不确定从哪个包中获取它。
看到以下与游标分页结果相关的 SQL,但无法找到有关其部分工作原理的更多信息:
SELECT b.* FROM books b
WHERE (b.name, id) > (select b2.name, b2.id
from books b2
where b2.id = ?
)
ORDER BY b.name;
Run Code Online (Sandbox Code Playgroud)
当单个比较表达式中有多个列时会发生什么?我还没有找到任何其他这样的例子。
给定一个像这样的表结构:
id | name | amount | other1 | other2 | other3
Run Code Online (Sandbox Code Playgroud)
和示例数据,例如:
1 | a | 40 | unrelevant data | ...
2 | a | 80 | unrelevant data | ...
3 | b | 30 | unrelevant data | ...
4 | b | 50 | unrelevant data | ...
5 | c | 20 | unrelevant data | ...
6 | c | 30 | unrelevant data | ...
Run Code Online (Sandbox Code Playgroud)
我希望我的选择结果压缩行并对压缩的金额进行求和,就像这样,我不关心丢失的数据(表示不相关数据的行):
1 | a | 120 | …Run Code Online (Sandbox Code Playgroud) apollo ×2
postgresql ×2
sql ×2
apollo-link ×1
comparison ×1
docker ×1
firebase ×1
graphql ×1
group-by ×1
pagination ×1
react-apollo ×1
react-hooks ×1
reactjs ×1
sum ×1
where-clause ×1