Upload File showing empty array #328
Replies: 2 comments
-
@jordanlewis9 Hey! Did you resolve this? Im stuck on the same problem. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey @jordanlewis9, At a glance, nothing is popping out at me. Only thing I can think of is an issue with a different part of your ApolloClient config or a race condition with your reducer. If you or @neff1337 are able to share an example reproduction (using the latest versions of WPGraphQL, GF, etc ), I'd be happy to dive in and take a look. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I'm having an issue with the Upload functionality of the plugin, and I've tried just about everything to no avail.
I'm running a Gatsby front-end utilizing Apollo Upload Client. Here is my dependency list:
Here is my apolloClient.js:
I'm using React Context to store form values in, and upon submit, inserting those as variables to the mutation. Here is my dispatch function for File Uploads:
And then how I'm storing those values in Context:
So theoretically, the File Object should be in state in an array as a value of fileUploadValues. And it shows up as that whenever I log state to the console. Here is the mutation sending the form values back to WP:
And lastly, the function to submit the mutation:
My WP install is just Local by Flywheel, using PHP 7.4, MySQL 8.0.16, server nginx, WP version 6.0.3.
The relevant WP plugins I'm using are:
Advanced Custom Fields PRO 6.0.3
Gravity Forms 2.6.7
WP Gatsby 2.3.3
WP GraphQL 1.12.0
WPGraphQL for ACF 0.5.2
WPGraphql for Gravity Forms 0.11.5
WPGraphQL Upload 0.1
I've tried 3 main methods. The method laid out above returns an Internal Server Error, with debug message of:
"Variable "$fieldValues" got invalid value [{"id":1,"nameValues":{"first":"Jordan","last":"Lewis"}},{"id":3,"fileUploadValues":[[]]}]; Expected type Upload at value[1].fileUploadValues[0]; Could not get uploaded file, be sure to conform to GraphQL multipart request specification. Instead got: []"
FWIW, the location of the error says "Line 1 Column 35". It seems like there is an empty array inside of the array, instead of the File object inside of the array, as is expected. I'm not sure if something is turning the object into an empty array, for whatever reason, or if the File natively turns into this blank array? The console.log statement before executing the mutation shows the following for the File Object:
The other 2 methods I've tried include making the Upload object myself, which would submit the entry with all of the fields filled out, except the file would not be attached or copied over (living nowhere on WP). The other method has been not wrapping the File Object in an array, IE:
This does submit the entry, but completely omits the uploaded file, and the entry does not know that there ever was a file that was supposed to be uploaded with it. Any help is greatly appreciated, thanks!
Beta Was this translation helpful? Give feedback.
All reactions