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

feat: support GraphQL Upload Spec #175

Merged
merged 9 commits into from
Aug 28, 2020

Conversation

lynxtaa
Copy link
Contributor

@lynxtaa lynxtaa commented Jul 12, 2020

First of all, thanks for this awesome library!

This PR adds support for GraphQL Multipart Request Spec and solves #132

Not sure if I should continue working on this PR (add tests, documentation) because the issue is closed

Copy link

@artursvonda artursvonda left a comment

Choose a reason for hiding this comment

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

Looks ok. Would love to see this get merged and released.

Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

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

Thanks @lynxtaa!

Not sure if I should continue working on this PR (add tests, documentation) because the issue is closed

Issue re-opened.

Let's get this merged soon. Please add some tests and update the README (mention this feature, add an example).

const { clone, files } = extractFiles({ query, variables }, '', isExtractableFileEnhanced)

if (files.size > 0) {
const form = new FormData()

Choose a reason for hiding this comment

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

I'm using graphql-request in node env and tried using this implementation on the server in environment where FormData is not available. We might need to use something like https://www.npmjs.com/package/form-data for compatibility with Node env.

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 think Form-Data should be polyfilled just like fetch, but I'll add readable error if form-data is not defined and improve documentation

Choose a reason for hiding this comment

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

Yeah, that's fair. Would be great if documentation would explain how to set this up for node.js.

Copy link
Member

Choose a reason for hiding this comment

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

Am ok if we need another polyfill. We don't currently mention anything about the fetch polyfill in the docs. What needs to be said about the form-data polyfill?

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've added documentation

@lynxtaa
Copy link
Contributor Author

lynxtaa commented Aug 19, 2020

Thanks @lynxtaa!

Not sure if I should continue working on this PR (add tests, documentation) because the issue is closed

Issue re-opened.

Let's get this merged soon. Please add some tests and update the README (mention this feature, add an example).

I need help with tests, not sure how can I test multipart requests

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Aug 19, 2020

@lynxtaa best is probably some integration testing. Some generated files in a tmp dir during test and then upload to temp GraphQL server (express GraphQL maybe).

Open to simpler if possible. Want confidence though.

@lynxtaa
Copy link
Contributor Author

lynxtaa commented Aug 27, 2020

@lynxtaa best is probably some integration testing. Some generated files in a tmp dir during test and then upload to temp GraphQL server (express GraphQL maybe).

Open to simpler if possible. Want confidence though.

Added integration testing with Apollo Server.
Maybe all current tests should be rewritten and use this server instead of __helpers.ts but I think it's out of scope of this PR.

Copy link
Member

@jasonkuhrt jasonkuhrt 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 the test @lynxtaa. One more comment then I think we can merge.

README.md Outdated Show resolved Hide resolved
Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

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

LGTM!

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