Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blog/working-with-file-uploads-using-altair-graphql/ #3

Open
utterances-bot opened this issue Oct 8, 2020 · 12 comments
Open

blog/working-with-file-uploads-using-altair-graphql/ #3

utterances-bot opened this issue Oct 8, 2020 · 12 comments

Comments

@utterances-bot
Copy link

Working with file uploads using Altair GraphQL · XKoji.dev

It’s no news that GraphQL is still the new kid on the block and has come to stay (don’t worry REST APIs still have their place 😄). As the GraphQL community…

https://www.xkoji.dev/blog/working-with-file-uploads-using-altair-graphql/

Copy link

Thank you so much for writing this and creating altair. I was able to figure out the file upload to work on one of my projects.

Copy link
Contributor

imolorhe commented Oct 8, 2020

Awesome! Glad it helped.

Copy link

Thank you creating Altair it's really awesome one of the reasons I used is because it provides way to upload files but when the window opens for choosing the in file explorer we can't see the normal file explorer interface like texts are in form of squares I'm using Manjaro distro

Copy link
Contributor

Hey! Sorry to hear that. You can create an issue in the repo with more details including screenshots so we can discuss it in more details 🙂 https://github.com/imolorhe/altair/issues

Copy link

if I want send other formdata how can I write graphql with Altair?
mutation($file:[Upload]){
createDocument(multipartBody:$file){
documentName
fileDownloadUrl
}
}
like this only upload file

Copy link
Contributor

@wangxinru how do you mean other form data? Is this other form data supported in the GraphQL spec? The file upload implementation is a specific spec for file upload support. I'm not aware of any other form data related specifications.

Copy link

Thanks for sharing!

Copy link

Great docs!
Im just not sure how to name the "file name" input if my mutation accepts an object containing the file as a parameter?

input MemberInput {
fullName: String!
description: String!
image: Upload
}

mutation CreateMember($input: MemberInput!) {
createMember(input: $input) {
id
fullName
imageId
description
createdAt
}
}

@imolorhe
Copy link
Contributor

imolorhe commented Aug 1, 2021

@Justas-Kaulakis you would have to split out your input object. Following the example you shared,

input MemberInput {
  fullName: String!
  description: String!
  image: Upload
}

mutation CreateMember($fullName: String!, $description: String!, $image: Upload) {
  createMember(input: {
    fullName: $fullName,
    description: $description,
    image: $image
  }) {
    id
    fullName
    imageId
    description
    createdAt
  }
}

Copy link

Unhandled Rejection (Error): Validation error of type VariableTypeMismatch: Variable type 'Upload' doesn't match expected type '[Upload]' @ 'createUploadCoverImage'

When I use this , I get this error

@imolorhe
Copy link
Contributor

@webDeveloper-619 you're mixing the Upload type with the list form [Upload] which is used for multiple uploads. You can try using the little toggle button beside the file name to switch between single file mode Upload and multiple file mode [Upload]

Copy link

Can you please share how the SDL looks like in the case of file upload. I created a custom scalar type and defined that with MultipartFile and getting 422 unprocessed entity error when trying to hit from Altair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants