Open
Description
Basically, allow for mutations instead of just like this:
updateAvatar(userId: String!, file: [UploadedFile!]!): Avatar
Also like this:
updateAvatar(userId: String!, file: UploadedFile!): Avatar
- Clearer semantics.
- Better validation for mutations requiring only one file in a variable.
- It is sometimes easier to get a single
File
object to send as a mutation parameter:
handleSubmit = event => {
event.preventDefault()
const formData = new window.FormData(event.target)
this.props.mutate({
variables: {
userId: this.props.userId,
file: formData.get('avatar') // Instance of File (not FileList), from <input type='file' name='avatar' required />
}
}).then(({data}) => {
console.log('Avatar updated', data)
})
}
To get this to work, handle File
as well as FileList
here and here.
Metadata
Metadata
Assignees
Labels
No labels