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

Add isExtractableFile, appendFile, FormData options #179

Merged
merged 5 commits into from Mar 15, 2020

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Feb 23, 2020

Closes #172. Simply adding customization options for apollo-upload-client greatly facilitates creation of a link that can support schema stitching.

See one implementation at:

https://github.com/yaacovCR/graphql-tools-fork/blob/with-apollo-upload-client/src/links/createServerHttpLink.ts

@yaacovCR
Copy link
Contributor Author

Thoughts on this?

Copy link
Owner

@jaydenseric jaydenseric left a comment

Choose a reason for hiding this comment

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

Sorry to leave you hanging, I'm been absolutely flat out the last few days (1.5hrs sleep last night!). This approach is very close to what I had in mind. Could the Windows support related changes please be moved to a different PR? I'm not actually sure I'm keen to support Windows TBH; there can be quite extensive and nuanced things that need tweaking.

@yaacovCR
Copy link
Contributor Author

Done.

@yaacovCR
Copy link
Contributor Author

Except the part about making a separate PR, if you are not into merging, I will hold off for now on that. :)

@yaacovCR
Copy link
Contributor Author

Hope you are sleeping better!

No real rush, just giving you a reminder. :)

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Mar 9, 2020

@jaydenseric anything I need to do to update this?

@yaacovCR yaacovCR closed this Mar 9, 2020
@yaacovCR yaacovCR reopened this Mar 9, 2020
@jaydenseric
Copy link
Owner

I was working on documentation and changelog entries for it last night, and hope to finish it up sometime soon. I’ll take it from here :)

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Mar 9, 2020

Cool, thanks!

Copy link
Owner

@jaydenseric jaydenseric left a comment

Choose a reason for hiding this comment

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

Thanks for kicking this off 🙌

@jaydenseric jaydenseric merged commit e1bb6e7 into jaydenseric:master Mar 15, 2020
@jaydenseric
Copy link
Owner

A little more work needs to be done before this can be released - testing it out in with the example project revealed that the way FormData defaults to the global crashes Node.js during Next.js SSR, because the global is not defined.

Screen Shot 2020-03-17 at 9 08 54 am

@yaacovCR
Copy link
Contributor Author

I guess it used to work because the link was never used server-side. I would think that is just incorrect usage, because in theory the link could be used server-side and so FormData should be required to be defined when using SSR via polyfill or argument.

Not sure, though!

@yaacovCR
Copy link
Contributor Author

For backwards compatible, I guess FormData should be set to default at runtime rather than link creation, but that is not parallel to fetch, seems wrong.

@yaacovCR
Copy link
Contributor Author

Actually, i guess whatever, as long as fetch and FormData treated the same

@jaydenseric
Copy link
Owner

It's a tricky one! Either way the solution will be a little opinionated. It's probably ok for FormData to be treated differently to fetch, since very few people are uploading files in SSR and everyone already polyfills fetch.

I'm not totally against requiring FormData to be either polyfilled or specified in config like fetch, but if we choose that solution we need figure out and document the best way to do it so that useless polyfills don't make their way into people's client bundles.

@yaacovCR
Copy link
Contributor Author

I guess cross-fetch in the example is similarly required to be included, but not being used, I guess then the defaults for both should just be substituted at runtime, doubt significant increase in execution time/memory use.

@yaacovCR
Copy link
Contributor Author

Do you want me to modify PR?

@yaacovCR
Copy link
Contributor Author

I think runtime defaulting is least breaking change and that's the way I would go at this point.

@jaydenseric
Copy link
Owner

cross-fetch is done in such a way that node-fetch is eliminated from client bundles by the the sorts of bundlers/minifiers Next.js uses.

Do you want me to modify PR?

No, if you would like to work on a solution please do it as a new PR against master 👍

@jaydenseric
Copy link
Owner

To test it out with the examples project:

  1. Download or clone the project: https://github.com/jaydenseric/apollo-upload-examples
  2. Follow the setup instructions for API and app.
  3. Run the API.
  4. In the app directory, run npx install-from ~/local/path/to/apollo-upload-client/repo/dir. Run this anytime you test changes to the local apollo-upload-client files.
  5. Start the app, and test in the browser.

@yaacovCR
Copy link
Contributor Author

Not sure if this is windows thing:

C:\Users\Yaacov\Documents\github\apollo-upload-examples\app>npx install-from ....\apollo-upload-client
npx: installed 5 in 2.833s
(node:8816) UnhandledPromiseRejectionWarning: Error: spawn npm ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:8816) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8816) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

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.

Schema stitching support
2 participants