-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File upload with apollo-upload-client #730
Comments
Hi @matthewcarlreetz! Sorry this one got lost a bit over the weekend. Two quick things:
Thanks for trying out Redwood! |
It's been a while, but let me share what I've found out along the same route, for future reference. On usage regarding Backgroundgraphql-upload issues with apollo-server RedwoodJSAmong various packages provided by apollo-server, redwood uses apollo-server-lambda. The packages share a common package named why no Now, all these are just an explanation for background info. The actual reason why If you read the ApolloServer code in apollo-server-core, you can find out that it tries to provide the upload feature carefully, anticipating whether the user wants it. It checks if any of upload configurations were passed in, and whether the user has their own idea of what their resolvers should be. If not, it gently provides their suggested set of resolvers, including graphql-upload. And this is where it doesn't work with redwoodjs out of the box. Redwood has its own interpretation of 'resolvers', which is implemented in Solution The solution is simple. All you need to do is provide two things by yourself. a) The So for instance, you can // api/src/graphql/images.sdl.js
export const schema = gql`
scalar Upload
type Mutation {
singleUpload(file: Upload!): Boolean
}
` // api/src/services/images/images.js
import { GraphQLUpload } from 'graphql-upload'
export const Upload = GraphQLUpload This is the default usage implemented in graphql-upload, where apollo-server is doing the same thing. It's just written in redwood style. Others -- file size limit Being a beginner myself to both apollo and redwood, I've spent several days figuring this out -- with various The current implementation of rw api-server (worked with v0.24.0, but seems to be same in 25) uses express and body-parser packages. The whole point of using graphql-upload was to upload files with multipart form request. It means that we are actually transferring file contents via forms. Current redwood has not considered about this, and while it does provide a handler for parsing I don't know if redwood has plans for letting the user customize the express server app. |
@jangxyz Thanks for the well written explanation/walkthrough. Correct me if I'm wrong, but since the Of course one can choose to use another provider than Netlify if upload functionality is needed and Netlify's lambda limits are too restrictive. But before going down that route I wanted to better understand the problem and the constraints. |
I think so, though frankly I can't say I have much experience on lambda functions. I do understand Lambda functions in general have limitations in running time and resources. Since I don't think it's possible to draw a concrete line on the shape of the server, providing a default preset and leaving it open to the user will be a feasible solution. |
@jangxyz huge thanks for an excellent write-up! I'd like to make sure this ends up somewhere that's accessible for people to find. @jtoar thoughts here about where this might go as a supplement to existing docs? And/or maybe this becomes a Cookbook of it's own. Also a decent option --> becomes a forum post. |
Awesome writeup @jangxyz! Are you interested in making a cookbook out of it? How to upload files with GraphQL sounds like a great topic, especially because we have a file upload cookbook using a 3rd party service, the merits of both methods could be compared. We also just need a lot more GraphQL-related docs. Echoing @thedavidprice, I'd definitely love to see this on the forums at least. As you said, you spent several days figuring this out, and caching these kinds of responses in a place where they can be found and built upon is a must! |
Thank you for the feedback. I'd be happy to share it with rest of the world, but currently I consider the findings to be incomplete. I've been thinking of writing about how to do uploads without using a 3rd party service, and post it on the forum. I see two possible approaches:
I'm poking around with Redwood in my spare time, so I can't guarantee any due dates. Perhaps it would be better to post the understandings up to now first, and then try with the tutorials later on..? |
@peterp I think your input on a. and b. above would be useful |
@peterp ping |
Hi all! I think this is a good next step and should happen in the Forums. There is a lot of value here @jangxyz very much including the questions and "dead ends". Definitely a valuable topic overall. |
Right. I'll move the issue to the forum. |
@jangxyz I'll keep a lookout for it. Once done, let's link to the Forum post here and close out this issue. Thanks in advance! |
Hey @jangxyz, let me know if I can help you with that forum topic if you're still interested! There's definitely a lot of great information in there that we'd love to make more findable |
I see that apollo upload client is in my
yarn.lock
file, but when trying to useUpload
inposts.sdl.js
I getIs there some config that I'm missing? Can I somehow configure the apollo client terminating link?
Thank you
The text was updated successfully, but these errors were encountered: