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

createUploadLink : TypeError: Object(...) is not a function #43

Closed
capsule5 opened this issue Nov 20, 2017 · 8 comments
Closed

createUploadLink : TypeError: Object(...) is not a function #43

capsule5 opened this issue Nov 20, 2017 · 8 comments

Comments

@capsule5
Copy link

capsule5 commented Nov 20, 2017

Hi,

With this setup:

import { createUploadLink } from "apollo-upload-client"
...

const client = new ApolloClient({
  link: createUploadLink({ uri: "http://localhost:3002/graphql" }),
  cache: new InMemoryCache(),
})

I got an error : TypeError: Object(...) is not a function coming from webpack_require

But with:

import { createHttpLink } from "apollo-link-http"
...

const client = new ApolloClient({
  link: createHttpLink({ uri: "http://localhost:3002/graphql" }),
  cache: new InMemoryCache(),
})

It works

Do I miss something?

@jaydenseric
Copy link
Owner

Are you using native ESM in node (.mjs)?

@capsule5
Copy link
Author

capsule5 commented Nov 20, 2017

@jaydenseric no just a regular create-react-app setup

@jaydenseric
Copy link
Owner

Strange. Does it work if you try:

import apolloUploadClient from "apollo-upload-client"

And:

const client = new ApolloClient({
  link: apolloUploadClient.createUploadLink({ uri: "http://localhost:3002/graphql" }),
  cache: new InMemoryCache(),
})

@capsule5
Copy link
Author

capsule5 commented Nov 20, 2017

Neither. I got TypeError: __WEBPACK_IMPORTED_MODULE_6_apollo_upload_client___default.a.createUploadLink is not a function

@jaydenseric
Copy link
Owner

Oh, if it's create-react-app there is a bug that has been patched to do with webpack being misconfigured to treat .mjs files as assets instead of JS files. I'll dig up a link for you.

@jaydenseric
Copy link
Owner

See #35 (comment) 🙂

@capsule5
Copy link
Author

Thanks a lot

@hamza121star
Copy link

Hi, i was reading up this thread and upon following it works. Now, when i push the code to a live link, the error gives : "Error! Network error: Unexpected token < in JSON at position 0" which is occurring due to this the createUploadLink function. This happens when i change "http://localhost:3000/graphql" to the live link of "http://my-website/graphql"

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

3 participants