Skip to content

Conversation

@sandervanhooft
Copy link
Collaborator

Also see issue #3. My initial work on this. Got the checking to work, but adding the array to the request body fails. I've not tested appending only a File to the body.

@HriBB
Copy link
Owner

HriBB commented Dec 7, 2016

Hmmm ... can we detect variable type from mutation? For example ...

const ADD_PROFILE_PICTURE = gql`
  mutation addProfilePicture($id: Int!, $file: UploadedFile!) {
    addProfilePicture(id: $id, file: $file) {
      id type filename url
    }
  }`

or

const ADD_GALLERY_PICTURES = gql`
  mutation addGalleryPictures($id: Int!, $files: [UploadedFile!]!) {
    addGalleryPictures(id: $id, files: $files) {
      id type filename url
    }
  }`

But we still need to check for File or FileList somehow ... ahh too late, need to get some sleep. Let's discuss this tomorrow.

Array.from(v).forEach(f => body.append(key, f))
} else if (isArrayOfFiles(v)) {
for (var file in v) {
return body.append(key, file); // this part seems buggy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return here will cause only the first file to get appended

}
if (request.variables[key] instanceof File) {
return true;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is off here

return true;
}
if (this.isArrayOfFiles(request.variables[key])) {
return true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this file doesn't use semicolons, probably following Standard Style

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

Successfully merging this pull request may close these issues.

3 participants