我试图弄清楚如何使用 TypeORM 在 lambda 函数中连接到 RDS PG 代理(因此建立连接没有问题)。我能够使用 Lambda 函数成功连接到 RDS 实例 - 但是,当我将信息指向代理(更改 Lambda 函数内的环境变量)时,我遇到了以下错误:
{
"errorType": "Error",
"errorMessage": "read ECONNRESET",
"code": "ECONNRESET",
"errno": "ECONNRESET",
"syscall": "read",
"stack": [
"Error: read ECONNRESET",
" at TCP.onStreamRead (internal/stream_base_commons.js:205:27)"
]
}
Run Code Online (Sandbox Code Playgroud)
这是用于创建与 TypeORM 连接的代码:
const config = getDBConfig();
connection = await createConnection(config);
// Retrieve database connection options
const getDBConfig = (): ConnectionOptions => {
// Use IAM-based authentication to connect
const signer = new RDS.Signer({
region: "us-east-1",
username: process.env.USERNAME,
hostname: process.env.HOSTNAME,
port: …
Run Code Online (Sandbox Code Playgroud) 使用以下包/技术组合(及其相应的依赖项未列出)从服务器上的客户端接收文件上传的正确实现是什么:
graphql-upload
apollo-server-fastify
@nestjs/platform-fastify
(代码优先方法)理想情况下,我们正在尝试使用 NestJS GraphQL Code First 技术(除了多个文件而不是一个文件)来实现以下内容(来自apollo 服务器文件上传)
const { ApolloServer, gql } = require('apollo-server');
const typeDefs = gql`
type File {
filename: String!
mimetype: String!
encoding: String!
}
type Query {
uploads: [File]
}
type Mutation {
singleUpload(file: Upload!): File!
}
`;
const resolvers = {
Query: {
uploads: (parent, args) => {},
},
Mutation: {
singleUpload: (parent, args) => {
return args.file.then(file => {
//Contents of Upload scalar: https://github.com/jaydenseric/graphql-upload#class-graphqlupload
//file.stream …
Run Code Online (Sandbox Code Playgroud) 你好,所以我在我的 ReactJS 应用程序上使用 apollo-client 已经有一段时间了。我刚刚注意到,有时当我使用useQuery
钩子时,执行完全忽略skip
参数,并继续onCompleted
(尽管没有任何数据)。有趣的是,它也没有向我的端点发出 API 请求。但是,如果我只是设置skip
为 false,那么一切正常(如预期)。
此外,每次我使用useQuery
with时都不会发生这种情况skip
,它似乎适用于某些而不是其他。
为什么 apollo 忽略skip
参数并onCompleted
立即使用空数据执行?有没有修复(除了useLazyQuery
)?
const userQuery = useQuery(GET_USER, {
variables: {
value: userId,
},
skip: true,
onCompleted: props => {
console.log(`props => `, props)
const {
user: { type, role, firstName, lastName, permissions },
} = props;
setValue('firstName', firstName);
setValue('lastName', lastName);
setValue(
'type',
userTypes.find(({ value }) => value === type),
);
setValue( …
Run Code Online (Sandbox Code Playgroud) apollo reactjs react-apollo apollo-client react-apollo-hooks
reactjs ×2
amazon-rds ×1
apollo ×1
fastify ×1
graphql ×1
nestjs ×1
postgresql ×1
proxy ×1
react-apollo ×1
typeorm ×1