I'm also with file uploads. Examples in yoga look ...
# orm-help
t
I'm also with file uploads. Examples in yoga look great, but IRL there are some not very good things in part of inputs. Is there a better way, than like this? https://www.prisma.io/forum/t/proper-datamodel-for-file-uploads/3569
m
I think a lot of it will come down to how you want to store the files. Did you have a methodology in mind?
t
Upload them to S3
How to handle incoming files that's a separate topic. The problem is with schemas, because Yoga server requires file fields inputs to be typed
Upload
- and this is the problematic part
m
You don't have to use the built in types. I just create my own, like:
Copy code
type Media {
    id: ID! @unique
    createdAt: DateTime!
    updatedAt: DateTime!
    filename: String!
    localSource: String!
    uploadUri: String
    bucket: String
    key: String
    region: String
    owner: User
}
t
Hm. And how do you handle multipart file requests?
m
I let S3 handle that using signed URLs
So basically the user lets me know that he or she has a file to upload. I generate a signed URL on the server side as part of the mutation and return that data to the user.
The user then says, 'Ok, I see that URL' and makes a post request.
File never touches my GraphQL server
t
Ah. That's kinda nasty hack ))
m
I'm not sure I would consider it a hack. 🙂
t
Well.. in any case I've got the idea, thank you, but it is better to utilize multipart graphql I think
m
As long as your server has enough RAM to mitigate the potential memory bottleneck at scale.