jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 131 forks source link

createReadStream is not present in uploaded image #248

Closed BraveEvidence closed 3 years ago

BraveEvidence commented 3 years ago

I am using node v14.17.0,"apollo-server-express": "^2.25.0", "graphql-upload": "^12.0.0"

I am trying to upload an image but i dont get createReadStream from the image which i upload from graphiql. I am using Altair graphiql

Here is my index.js

const app = express();

app.use(
  graphqlUploadExpress({
    maxFileSize: 30000000,
    maxFiles: 20,
  })
);

const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: contextMiddleware,
  uploads: false,
});

server.applyMiddleware({ app });

app.listen(PORT, () => {
  console.log("Success");
});

In my typedefs i have mentioned

gql`
  scalar Upload

and my resolvers have

Upload: GraphQLUpload,

I have tried following this issue https://github.com/apollographql/apollo-server/issues/3508 but it doesn't seem to work for me

My uploaded image contains following {"filename":"download123.jpg","mimetype":"image/jpeg","encoding":"7bit"}

jaydenseric commented 3 years ago

I can't tell what's wrong with your project, sorry to hear you've been finding it tricky getting set up. graphql-upload is actually a pretty simple integration and it's usually problems relating to Apollo that trip people up; in such situations please refer to Apollo for help.