Я пытаюсь использовать скалярный сервер Upload
сервера Apollo для прямой отправки файлов на 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!
}
`
Resolver:
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 { createReadStream, filename, mimetype, encoding } = await picture
// Does not get past this line
const stream = createReadStream()
uploadPhoto(stream, filename)
const pictureModel = models.Picture.create({
name,
picture
})
return pictureModel
}
)
}
}
Но мой код ошибки вроде этого:
internal/util.js:55
function deprecated(...args) {
^
RangeError: Maximum call stack size exceeded
at ReadStream.deprecated [as open] (internal/util.js:55:22)
at ReadStream.open ([truncated]/node_modules/fs-capacitor/lib/index.js:90:11)
at _openReadFs (internal/fs/streams.js:123:12)
at ReadStream.<anonymous> (internal/fs/streams.js:116:3)
at ReadStream.deprecated [as open] (internal/util.js:70:15)
at ReadStream.open ([truncated]/node_modules/fs-capacitor/lib/index.js:90:11)
at _openReadFs (internal/fs/streams.js:123:12)
at ReadStream.<anonymous> (internal/fs/streams.js:116:3)
at ReadStream.deprecated [as open] (internal/util.js:70:15)
at ReadStream.open ([truncated]/node_modules/fs-capacitor/lib/index.js:90:11)
at _openReadFs (internal/fs/streams.js:123:12)
at ReadStream.<anonymous> (internal/fs/streams.js:116:3)
at ReadStream.deprecated [as open] (internal/util.js:70:15)
at ReadStream.open ([truncated]/node_modules/fs-capacitor/lib/index.js:90:11)
at _openReadFs (internal/fs/streams.js:123:12)
at ReadStream.<anonymous> (internal/fs/streams.js:116:3)
at ReadStream.deprecated [as open] (internal/util.js:70:15)
at ReadStream.open ([truncated]/node_modules/fs-capacitor/lib/index.js:90:11)
at _openReadFs (internal/fs/streams.js:123:12)
at ReadStream.<anonymous> (internal/fs/streams.js:116:3)
at ReadStream.deprecated [as open] (internal/util.js:70:15)
at ReadStream.open ([truncated]/node_modules/fs-capacitor/lib/index.js:90:11)
Примечание: я уверен, что изображение было отправлено правильно, так как filename
правильно