-
Notifications
You must be signed in to change notification settings - Fork 222
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
File Upload #128
Comments
Hi, yes it is possible, you must use request to get your file in your mutation resolver, you can inject it using the object request in the expression language... |
@mcg-web Could you provide an example? |
Here an example using relay mutation:
RootMutation:
type: object
config:
fields:
uploadFile:
builder: "Relay::Mutation"
builderConfig:
inputType: UploadFileInput
payloadType: UploadFilePayload
mutateAndGetPayload: "@=mutation('upload_file', [request, value['title']])"
UploadFilePayload:
type: relay-mutation-payload
config:
fields:
files: {type: "[String!]!" }
UploadFileInput:
type: relay-mutation-input
config:
fields:
title: {type: "String!"}
public function uploadFile(\Symfony\Component\HttpFoundation\Request $request, $title)
{
/** @var \Symfony\Component\HttpFoundation\FileBag; $requestFiles */
$requestFiles = $request->files;
if (!$requestFiles->has('myFile')) {
throw new \Overblog\GraphQLBundle\Error\UserError(sprintf('File "%s" is required.', 'myFile')));
}
/** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
$file = $requestFiles->get('myFile');
// here do some work on your uploaded file
return [$title];
} @ooflorent done! |
done here |
The link was not available anymore, here is the updated link of the documentation: https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/upload-files.md (in particular, see this link for usage with apollo-upload-client) |
Is there a way to upload files through graphql?
Does the bundle manage multipart request?
Here is a related proposal for Apollo: apollographql/apollo#65.
The text was updated successfully, but these errors were encountered: