Skip to content
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

Request payload has no file content #40

Closed
codeashian opened this issue Sep 22, 2020 · 1 comment
Closed

Request payload has no file content #40

codeashian opened this issue Sep 22, 2020 · 1 comment

Comments

@codeashian
Copy link

codeashian commented Sep 22, 2020

Hi!

I have an issue when posting a file using apollo-client (I am posting to apollo-server-lambda). The POST request looks like this, in other words, it's empty where the file content should be (I think?)

{"1":["variables.file"]}
------WebKitFormBoundaryms9IIBb8QTb29vwl
Content-Disposition: form-data; name="1"; filename="74b233b0.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryms9IIBb8QTb29vwl--

The file sent to the server looks like this:

File {
  lastModified: 1598943888000,
  lastModifiedDate: Tue Sep 01 2020 09:04:48 GMT+0200 (Central European Summer Time){},
  name: "IMG_2439.JPG",
  size: 3955743,
  type: "image/jpeg",
  webkitRelativePath: ",
  __proto__: File
}

I'm using apollo-client-server like this:

  ....
  return new ApolloClient({
    ssrMode: typeof window === "undefined",
    link: createUploadLink({
      uri: "my-uri",
      headers: {
        authorization: `Bearer ${token}`,
      },
    }),
    cache: new InMemoryCache(),
  });

And here's my typedefs

gql`
  mutation createPerson($person: PersonInput!, $file: Upload!) : String
`

And the mutation query looks like this:

  createPerson({
      variables: { person: person, file: image },
      update: updateCache,
    });

I don't think I can google my problem more than I have. I would really appreciate som help <3

@codeashian codeashian changed the title Request payload has no unique, arbitrary field name. Request payload has no file content Sep 22, 2020
@jaydenseric
Copy link
Owner

Closing because this issue is more a usage question about an implementation of the GraphQL multipart request spec, whereas this repo is about documenting the spec itself.

I have an issue

What exactly is the issue? Is there an error message, and is it on the client or server?

it's empty where the file content should be (I think?)

Probably the data is there; the Chrome network inspector just hides the huge binary blob of data. Here is an example that is working:

Screen Shot 2020-09-23 at 12 03 26 am

Screen Shot 2020-09-23 at 12 06 29 am

I'm using apollo-client-server like this:

Did you mean to say apollo-upload-client?

Note that graphql-upload doesn't officially support AWS Lambda; as a platform AWS Lambda isn’t very friendly to file uploads because it doesn't stream in requests. You can read more about it here:

jaydenseric/graphql-upload#155 (comment)

Despite this, apollo-server-lambda does support the GraphQL multipart request spec. If you think you have found a bug with it it's best to raise an issue in their repo :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants