Skip to content

Document file upload handling for GraphQL #913

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

Closed
wants to merge 1 commit into from
Closed

Document file upload handling for GraphQL #913

wants to merge 1 commit into from

Conversation

lukasluecke
Copy link

This should cover what's needed to use file uploads with a GraphQL API (and with a link to a client implementation for Apollo).

@lukasluecke
Copy link
Author

I'm not sure if we should split this whole "page" between REST and GraphQL, as to not mix them in the resource annotation, and then having to cover both for every step of the process.

@lukasluecke
Copy link
Author

lukasluecke commented Oct 4, 2019

Also the EventSubscriber for setting the resolved URL will not work with GraphQL, but I think we can fix that separately, by just replacing the whole thing with a custom normalizer (that should work for both REST and GraphQL, right?).

(see #916)

@alanpoulain
Copy link
Member

Thank you for working on this @lukasluecke!
For the other GraphQL features, we have already split the whole page between REST and GraphQL. We only reference the REST part when the code is exactly the same. So I think we should do the same for this feature.


final class CreateMediaObjectResolver implements MutationResolverInterface
{
public function __invoke($item, array $context): MediaObject
Copy link
Member

Choose a reason for hiding this comment

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

Missing @param.

Copy link
Author

Choose a reason for hiding this comment

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

See my comment below - it's the same as the existing REST example.

Copy link
Member

Choose a reason for hiding this comment

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

The REST __invoke doesn't need a PHPDoc (since it's already typehinted), but it's useful here.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, makes sense. We do not use the $item here, but I'll describe that as well 👍

@lukasluecke
Copy link
Author

@alanpoulain Should I split it into a separate page as part of this PR, or do we want to handle that afterwards? So we‘d just add a „Handling File Upload“ page under the GraphQL section? And maybe add a link in the „original“ for discoverability?

@alanpoulain
Copy link
Member

The GraphQL page is rapidly growing, so I was thinking of splitting it into multiple pages, but it will probably be done after #884 (\cc @bpolaszek).

In the meantime, you should add a section Handling File Upload in the GraphQL page with the GraphQL specific code and reference the REST part when the code is the same. We should avoid duplication as much as possible.

In the future, it will be great to have the same page for all the possible configurations (REST/GraphQL/ORM/MongoDB ODM) with some selectors like the selector for the version, but it's a lot of work...

@alanpoulain
Copy link
Member

Any update on this @lukasluecke?

@lukasluecke
Copy link
Author

@alanpoulain Will try to finish this tomorrow 🙂

@alanpoulain
Copy link
Member

@lukasluecke I can take this over if you're okay with it.

@alanpoulain
Copy link
Member

Closed in favor of: #973.
Thank you @lukasluecke!

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.

2 participants