
400 Bad Request while uploading file in Altair using graphql and apollo here is my code when I send a request to the server only in uploading file I get this kind of error: is there any way I could upload a file without getting this error
const { gql } = require('apollo-server-express');
export default gql`
scalar Upload
type User{
id: Int!
firstName: String!
lastName: String!
userName: String!
email: String!
createdAt: String!
updatedAt: String!
bio: String
avatar: String
}
type loginResult{
ok: Boolean!
token: String
Error: String
}
type editProfileResult{
ok: Boolean!
Error: String
}
type Mutation{
creatUser(
firstName: String!
lastName: String!
userName: String!
email: String!
password: String!
):User
logIn(userName: String!, password: String!):loginResult!
editProfile(firstName: String
lastName: String
userName: String
email: String
password: String
bio: String
avatar: Upload ):editProfileResult!
}
I had the same issue and figured that I should use the graphqlUploadExpress from graphql-upload in my node.js server.
import { graphqlUploadExpress } from 'graphql-upload/graphqlUploadExpress.mjs';
app.use(graphqlUploadExpress());
Using below worked for me!
import { graphqlUploadExpress } from 'graphql-upload/graphqlUploadExpress.mjs';
app.use(graphqlUploadExpress());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With