我现在正在开发一个项目,该项目有多个 TypeScript 微服务在同一数据库上执行操作。在每个微服务中,我们都使用 Prisma 客户端来执行数据库操作。我遇到的问题是我们需要schema.prisma在每个微服务中复制文件并为每个服务生成 Prisma 客户端。有没有一种方法可以在单独的项目中管理我们的数据库,同时在微服务之间共享生成的客户端,而无需schema.prisma在每个项目中重复?
我正在使用 GraphQLClient fromgraphql-request向我的服务器发送请求。我正在尝试通过执行以下操作来上传文件:
const graphQLClient = new GraphQLClient('http://localhost:4000/graphql', {
credentials: 'include',
mode: 'cors',
});
const source = gql`
mutation uploadImage($file: Upload!) {
uploadImage(file: $file)
}
`;
const file: RcFile = SOME_FILE; // RcFile (from antd) extends File
await graphQLClient.request<{uploadImage: boolean}>(source, { file });
Run Code Online (Sandbox Code Playgroud)
但是,当我以这种方式向服务器发送请求时,出现以下错误:
GraphQLError: Variable \"$file\" got invalid value {}; Upload value invalid
Run Code Online (Sandbox Code Playgroud)
这是我的请求在控制台中的样子:
operations: {
"query":"\n mutation uploadProfileImage($file: Upload!){\n uploadProfileImage(file: $file)\n }\n",
"variables":{"file":null}
}
map: {"1":["variables.file"]}
1: (binary)
Run Code Online (Sandbox Code Playgroud)
其他人遇到过这个问题吗?我似乎无法将文件上传到我的后端。