Upload Image with nextjs #8623
Replies: 5 comments 2 replies
-
|
Can anyone help me please ? |
Beta Was this translation helpful? Give feedback.
-
|
Hi there @vincelux, Your mutation seems fine. The query would be similar. I think the problem is that you did not configure your client to handle uploads. Most of the graphql client libraries require some additional steps to enable that. See eg. https://gqlgen.com/reference/file-upload/ . You have curl example that let you try it through the console and also apollo example (need additional link). If you still struggle with that, make some simple public repo or codesandbox with your client code and share it so that we can have a look. |
Beta Was this translation helpful? Give feedback.
-
|
import Upload from 'graphql-upload/Upload.js'; const prepareFile = async (filename: string) => { |
Beta Was this translation helpful? Give feedback.
-
|
const UPLOAD_FILE = gql const [createMedia] = useMutation(UPLOAD_FILE); await createMedia({ |
Beta Was this translation helpful? Give feedback.
-
|
new ApolloClient({ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm looking to upload an image of a nextjs frontend page, I can't find the graphql query or an example graphql query in the documentation.
I looked through the examples, couldn't find any either.
My version looks like this:
const CREATE_IMAGE_MUTATION=gql
mutation CREATE_IMAGE_MUTATION($image: Upload, $altText: String) { createImage(data: { image: $image, altText: $altText }) { id image { id filesize width height extension url } altText } };I of course replaced 'upload' with 'ImageFieldInput', with no more success.
Could someone tell me the right solution please
Beta Was this translation helpful? Give feedback.
All reactions