1. Simple File Upload Mutation
  2. same input array file uploads
  3. multiple input uploads
  4. multiple input uploads with input
  5. same input array file uploads with input

1.Simple File Upload Mutation

php artisan lighthouse:mutation Upload
Upload.php
public function __invoke($_, array $args)

{

\Log::info( $args[‘file’]);

$file = $args[‘file’];

// TODO implement the resolver

}

extend type Mutation @guard {

“A Test Mutation to upload single”

upload(file: Upload!): String!

}

In Altair

mutation($fileff:Upload!){
upload(file:$fileff)
}

php artisan lighthouse:mutation Upload

2.same input array file uploads
extend type Mutation @guard {

“A Test Mutation to upload single input multiple files”

uploadMultiFilee(logoImageFile: [Upload]!): String

}

php artisan lighthouse:mutation UploadMultiFilee

UploadMultiFilee.php

public function __invoke($_, array $args)

{

\Log::info($args);

$uploadedone = $args[‘logoImageFile’][0];

$uploadedtwo = $args[‘logoImageFile’][1];

$uploadedthree = $args[‘logoImageFile’][2];

$uploadedfour = $args[‘logoImageFile’][3];

$uploadedone->storePublicly(‘uploads’);

$uploadedtwo->storePublicly(‘uploads’);

$uploadedthree->storePublicly(‘uploads’);

$uploadedfour->storePublicly(‘uploads’);

return “uploadedone:”.$uploadedone.” and uploadedtwo:”.$uploadedtwo.”uploadedthree:”.$uploadedthree.”uploadedfour:”.$uploadedfour;

// TODO implement the resolver

}

In Altair :

--

--