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

Uncaught TypeError: Cannot read properties of undefined (reading 'call') upon build project. #311

Closed
StefanusChristian opened this issue Jul 6, 2023 · 2 comments

Comments

@StefanusChristian
Copy link

StefanusChristian commented Jul 6, 2023

Hi, my team has develop upload feature in our project using apollo-upload-client and it works without problem. But when we build the project and run it, it only show blank white screen and gives console error:

Uncaught TypeError: Cannot read properties of undefined (reading 'call')

The error from my code was when I'm using the createUploadLink. Can confirm when replacing it with createHttpLink from @apollo/client, the build run as it should.

After further tracing it, it was caused by the '@apollo/client/core' require in createUploadLink.js. It might because of the ApolloLink or Observable.

Screenshots Screen Shot 2023-07-06 at 5 50 26 PM Screen Shot 2023-07-06 at 6 08 09 PM
Code snippet of createUploadLink usage
const httpLink = createUploadLink({ // If change with createHttpLink, build will works
  uri: API_URL,
  credentials: 'same-origin',
});
const splitLink = split(
  ({ query }) => {
    const definition = getMainDefinition(query);

    return (
      definition.kind === 'OperationDefinition' &&
      definition.operation === 'subscription'
    );
  },
  wsLink,
  httpLink,
);

export const client = new ApolloClient({
  link: from([errorLink, authLink, splitLink]),
});

I'm developing my project using react-native-web and here's some of the library we use:

  • "expo": "^47.0.0",
  • @apollo/client: "^3.6.9"
  • "graphql": "15.8.0"
  • "react": "18.1.0"
  • "react-dom": "18.1.0"
  • "react-native": "0.70.5"
@jaydenseric
Copy link
Owner

If you do this in a CJS module in your project, does it work?

const { ApolloLink, Observable } = require("@apollo/client/core");

We need to figure out where the issue lies; with your project's build setup, with the @apollo/client package, or if it's something which needs to be fixed in apollo-upload-client.

The state of maintenance of this package is a bit in limbo because I want to work on and support the newer version currently in the next branch (see changes here), but can't progress that work due to an upstream @apollo/client issue:

apollographql/apollo-client#9890

Although it's not closed yet, it looks like they might be making progress in the last couple of weeks:

apollographql/apollo-client#10994

So I might resume work here when I next get some spare time.

@jaydenseric
Copy link
Owner

Closing due to no response, and also because it seems no other users are experiencing similar errors. If it turns out to be a bug here (and not a project or React Native related issue) we can reopen.

@jaydenseric jaydenseric closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2023
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