How would you do file uploads in a React-Relay app?

后端 未结 5 1221
时光说笑
时光说笑 2020-12-30 03:45

A file upload seems like a mutation. It\'s often accompanied by other data. But it\'s a big binary blob, so I\'m not sure how GraphQL can deal with it. How would you inte

5条回答
  •  一整个雨季
    2020-12-30 04:07

    While you can definitely implement uploading files to your GraphQL API endpoint, it's considered to be an anti-pattern (you will bump into issues with max file size etc.).

    A better alternative would be obtaining a signed URL from your GraphQL API for uploading a file directly from the client-side app to Amazon S3, Google Cloud Storage etc.

    If the server-side code needs to save URL in the database once the upload is complete, it can subscribe to this event directly. Check object change notification in Google Cloud as an example.

提交回复
热议问题