Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

feat(submission): add uploadProgress subscription resolver #368

Merged
merged 14 commits into from
Aug 17, 2018

Conversation

mihaildu
Copy link
Contributor

re #312

console.log('new subscription!!')
setTimeout(() => {
console.log('published new data')
pubsub.publish(ON_UPLOAD_PROGRESS, { uploadProgress: 10 })
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is the uploadProgress resolver, shouldn't you publish 10 rather than {uploadProgress: 10}?

In the long term, it's probably better to change the schema so uploadProgress returns an object rather than a number, to make it easier to extend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You actually have to return it like that. This code is here just to debug and see if it works or not, but I tested this with GraphiQL and after 8 seconds I get back the right stuff and it doesn't complain.

This link has some subscription implementation https://github.com/apollographql/graphql-subscriptions

@mihaildu mihaildu changed the title WIP: feat(submission): add uploadProgress subscription resolver feat(submission): add uploadProgress subscription resolver Aug 17, 2018
@mihaildu mihaildu changed the title feat(submission): add uploadProgress subscription resolver WIP: feat(submission): add uploadProgress subscription resolver Aug 17, 2018
@mihaildu mihaildu changed the title WIP: feat(submission): add uploadProgress subscription resolver feat(submission): add uploadProgress subscription resolver Aug 17, 2018
const dropzoneContentWrapper = makeCheerioWrapper({
conversion: { converting: true },
})
expect(dropzoneContentWrapper.text()).toBe(manuscriptUploading)
})

it('displays uploading even if there are errors', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to skip these? If so, please leave a comment to explain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, same as my previous comment, tests needs updating to account for percentage of file upload. Would skip for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -10,6 +14,8 @@ const path = require('path')
const crypto = require('crypto')
const Joi = require('joi')

const { ON_UPLOAD_PROGRESS } = asyncIterators
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it confusing that this ON_UPLOAD_PROGRESS is a string but the other thing called ON_UPLOAD_PROGRESS is a graphql operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, one is client side and the other server side. They had similar examples in apollo as far as I remember.

const manuscript = await Mutation.uploadManuscript(
{},
{ id, file },
file.size,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? Shouldn't file size be passed in the second parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't remember what happened here, pretty sure I tested a while ago. This will fail anyway now because you need to subscribe to uploadProgress before you upload a file. I would skip for now and fix the test later since merging this seems like a higher priority.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{...props}
/>
<Subscription subscription={ON_UPLOAD_PROGRESS}>
{({ data: uploadData, loading: uploadLoading }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if this request fails? Does the progress just stay at zero? If so, I think that's fine. Just would like to make sure it doesn't fail in any more major way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just played with this and if the initial subscription fails then the page does not load at all. The error doesn't seem to be captured in the error render prop as described here https://www.apollographql.com/docs/react/advanced/subscriptions.html#render-prop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hem-brahmbhatt hem-brahmbhatt mentioned this pull request Aug 20, 2018
3 tasks
@hem-brahmbhatt hem-brahmbhatt deleted the 312-push-messages branch August 22, 2018 10:57
hem-brahmbhatt added a commit that referenced this pull request Aug 22, 2018
hem-brahmbhatt added a commit that referenced this pull request Aug 22, 2018
…solver

Revert "Merge pull request #368 from elifesciences/312-push-messages"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants