小编jen*_*gel的帖子

使用 TypeORM 使用 IAM 凭证连接到 Amazon RDS PostgresQL 代理

我试图弄清楚如何使用 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)

postgresql proxy amazon-rds typeorm amazon-rds-proxy

8
推荐指数
1
解决办法
1979
查看次数

使用 graphql-upload、apollo-server-fastify 和 NestJS 代码优先方法上传文件

使用以下包/技术组合(及其相应的依赖项未列出)从服务器上的客户端接收文件上传的正确实现是什么:

  • 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 graphql apollo-server nestjs fastify

5
推荐指数
1
解决办法
880
查看次数

跳过参数在来自@apollo/react-hooks 的 useQuery 钩子中被忽略

问题:

你好,所以我在我的 ReactJS 应用程序上使用 apollo-client 已经有一段时间了。我刚刚注意到,有时当我使用useQuery钩子时,执行完全忽略skip参数,并继续onCompleted(尽管没有任何数据)。有趣的是,它也没有向我的端点发出 API 请求。但是,如果我只是设置skip为 false,那么一切正常(如预期)。

此外,每次我使用useQuerywith时都不会发生这种情况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

5
推荐指数
1
解决办法
3102
查看次数