is there anyone who has an example of uploading a ...
# prisma-whats-new
r
is there anyone who has an example of uploading a photo and linking it to an item in the db via mutation?
a
You could have a look at the file-proxy example. That executes a mutation when a file is uploaded, and should be a good starting point. https://github.com/graphcool/templates/tree/master/community/file-handling/file-proxy
r
that seems way more involved than I anticipated hah
a
Well, the example contains multiple variations, most of them including upload and download
r
so I guess its not just a matter of using both a mutation and axios call for example
well, I guess I have some reading to do
a
The issue is that hooks don't trigger for the File Type. otherwise, it would be easier. Also, the File API ignores additional form fields
r
right
Now, instead of the updateFile mutation, you would use the posted id of the item you want to link it to and execute the addXtoY mutation with the fileId and the nodeId of the item you want to link it too
r
right
I thought it was a matter of storing the uri
but I guess I was too simplistic in my thinking
a
Well, you can do that too. You can just use the File API from the client
That returns the ID of the new File node
And then call the mutation from the client
If that fits your usecase, that's easiest
r
Well its a matter of linking an image to a post
so I guess that would be enough?
a
Yes, I was overcomplicating for your use case
1. Create Post (get Id back) 2. Upload File (get Id back) 3. Call AddImageToPost(postId, fileId) 4. Done
r
perfect
thanks man 🙂