我正在尝试使用 Apollo Server 的Upload标量将文件直接发送到 S3。我的架构:
const { gql } = require('apollo-server-express')
module.exports = gql`
extend type Mutation {
createPicture(
name: String!
picture: Upload!
): Picture!
}
type Picture {
name: String!
picture: String!
}
`
Run Code Online (Sandbox Code Playgroud)
解析器:
const { combineResolvers } = require('graphql-resolvers')
const isAuthenticated = require('./auth')
const { uploadPhoto } = require('../services/picture')
module.exports = {
Mutation: {
createPicture: combineResolvers(
isAuthenticated,
async (
parent,
{ name, picture = null },
{ models, me }
) => {
const { …Run Code Online (Sandbox Code Playgroud) 我得到_tkinter.TclError: couldn't connect to display "localhost:10.0"SSH'ing时(含-X)到我的Ubuntu 16.04服务器,运行此脚本
from os import path
from wordcloud import WordCloud
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.use('Agg')
d = path.dirname(__file__)
text = open(path.join(d, 'words.txt')).read()
wordcloud = WordCloud().generate(text)
# Configure plot
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
# lower max_font_size
wordcloud = WordCloud(max_font_size=40).generate(text)
plt.figure()
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis("off")
plt.savefig("comments.png")
Run Code Online (Sandbox Code Playgroud)
此脚本使用 Wordcloud ( https://github.com/amueller/word_cloud/ )。words.txt是一堆我打算变成词云的词。应该发生的事情是云被保存为comments.png(但未显示)在我正在连接的服务器上。
我有一个BeforeInsertandAfterInsert钩子没有被调用。它所做的只是记录hook。我正在使用 Nestjs-graphql。
您可以运行此示例npm i,然后发送一个突变(playground 位于localhost:3000/graphql)body 处createUser(createInput:{password:"password" email:"test@test.com"})。它应该成功并记录hook。
钩子(没有记录任何内容):
@Entity('user')
export default class UserEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
@IsEmail()
email: string;
@Column()
@Length(7, 42)
password: string;
@BeforeInsert()
@AfterInsert()
async validate() {
console.log("hook")
}
}
Run Code Online (Sandbox Code Playgroud)
它是从服务中调用的。插入不会引发错误,并here2会被记录:
@Injectable()
export class UserService {
constructor(
@InjectRepository(UserEntity)
private readonly userRepository: Repository<UserEntity>,
) { }
async createNew(email: string, password: string): Promise<number> {
console.log("here2")
const hashedPassword = …Run Code Online (Sandbox Code Playgroud)