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

Type Error Using New Apollo #171

Open
guilhermeccrz opened this issue Nov 25, 2021 · 2 comments
Open

Type Error Using New Apollo #171

guilhermeccrz opened this issue Nov 25, 2021 · 2 comments

Comments

@guilhermeccrz
Copy link

guilhermeccrz commented Nov 25, 2021

The code above works when run dev, but when try to build, types are incorrect right in the () => {, what should i do?

"Argument of type '() => ApolloClient' is not assignable to parameter of type 'InitApolloClient'.
Type 'ApolloClient' is missing the following properties from type 'ApolloClient': store, writeData, initQueryManager"

import withApollo from "next-with-apollo";
import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client";

const cache = new InMemoryCache();

export default withApollo(
  () => {
    return new ApolloClient({
      uri: process.env.API_URL,
      cache: cache,
      name: "react-web-client",
      version: "1.3",
      queryDeduplication: false,
      defaultOptions: {
        watchQuery: {
          fetchPolicy: "cache-and-network",
        },
      },
    });
  },
  {
    render: ({ Page, props }) => {
      if (process.env.NODE_ENV === "test") {
        return <Page />;
      }

      return (
        <ApolloProvider client={props.apollo}>
          <Page />
        </ApolloProvider>
      );
    },
  }
);
@tiwari-ai-harsh
Copy link

Be sure to name your file with .tsx not .ts.

@tiwari-ai-harsh
Copy link

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