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

Upload fails with DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead. #2105

Closed
optunetobi opened this issue Dec 17, 2018 · 3 comments

Comments

@optunetobi
Copy link

optunetobi commented Dec 17, 2018

Using node 8.11.4 with [email protected]:

(STDERR) (node:19126) DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.

It seems that this was due to changes since [email protected], as the version before worked without an Error.

Assuming the breaking change was only intended for node versions before 8.5, then my report means that 8.11.4 is affected by this probably. #2054

(Update: my bad, 8.11.4 is good 👍 )

@abernix
Copy link
Member

abernix commented Dec 17, 2018

Could you please provide a small, runnable reproduction of your particular problem? (CodeSandbox is great for this). Or at the very least, an example of one of your resolvers?

Basically: This warning message should be just that: a warning. According to the both the issue you linked (#2054 (review)) and the official CHANGELOG for graphql-upload, stream should still be available and still work properly, but would be deprecated in a future version.

@jaydenseric
Copy link

This is working as intended; @optunetobi please migrate to the new API in your mutation resolvers:

- const { stream, filename, mimetype } = await upload
+ const { createReadStream, filename, mimetype } = await upload
+ const stream = createReadStream()

If you don't, it will still work for now but you will see this deprecation warning:

screen shot 2018-10-29 at 10 03 43 pm

As @abernix pointed out, this API change happened in graphql-upload v7 and was necessary to fix a whole bunch of issues, the most obvious being that you can now use a single Upload as a variable that can be used as input for multiple mutations in one request. Previously, consuming the stream in one resolver would interfere with consuming the same stream in another.

phamhongphuc pushed a commit to phamhongphuc/uit.open.source.project that referenced this issue Dec 20, 2018
@optunetobi
Copy link
Author

optunetobi commented Dec 21, 2018

@abernix thank you for your feedback and explanation. Unfortunately it broke my resolver code in my case, or I was misattributing this warning as an error as I passed the stream to another cloud-storage uploader, which then failed without error to console (I may have forgotten a catch).

@jaydenseric thank you for the detailed explanation, I could fix it now. (with your provided diff)

Vultraz added a commit to Vultraz/keystone-5 that referenced this issue Oct 24, 2019
Fixes this warning: DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.
See apollographql/apollo-server#2105 (comment)
Vultraz added a commit to Vultraz/keystone-5 that referenced this issue Oct 24, 2019
Fixes this warning: DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.
See apollographql/apollo-server#2105 (comment)
Vultraz added a commit to Vultraz/keystone-5 that referenced this issue Oct 24, 2019
Fixes this warning: DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.
See apollographql/apollo-server#2105 (comment)
Vultraz added a commit to Vultraz/keystone-5 that referenced this issue Oct 24, 2019
Fixes this warning: DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.
See apollographql/apollo-server#2105 (comment)
Vultraz added a commit to Vultraz/keystone-5 that referenced this issue Oct 24, 2019
Fixes this warning: DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.
See apollographql/apollo-server#2105 (comment)
Vultraz added a commit to Vultraz/keystone-5 that referenced this issue Oct 25, 2019
Fixes this warning: DeprecationWarning: File upload property ‘stream’ is deprecated. Use ‘createReadStream()’ instead.
See apollographql/apollo-server#2105 (comment)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants