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!
}
Using below worked for me!
import { graphqlUploadExpress } from 'graphql-upload/graphqlUploadExpress.mjs';
app.use(graphqlUploadExpress());
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';
app.use(graphqlUploadExpress());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.