PHP code example of dre1080 / wp-graphql-upload
1. Go to this page and download the library: Download dre1080/wp-graphql-upload library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dre1080 / wp-graphql-upload example snippets
register_graphql_mutation(
'upload', [
'inputFields' => [
'file' => [
'type' => ['non_null' => 'Upload'],
],
],
'outputFields' => [
'text' => [
'type' => 'String',
'resolve' => function ($payload) {
return $payload['text'];
},
],
],
'mutateAndGetPayload' => function ($input) {
if (!function_exists('wp_handle_sideload')) {