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

Error: Could not find "client" #45

Closed
dcjones1 opened this issue Jul 12, 2019 · 3 comments
Closed

Error: Could not find "client" #45

dcjones1 opened this issue Jul 12, 2019 · 3 comments

Comments

@dcjones1
Copy link

I'm trying to integrate this into a project I'm working on but I keep getting the following error:

Could not find "client" in the context or passed in as an option. Wrap the root component in an , or pass an ApolloClient instance in via options.

I've followed along exactly with the example you built but still get the error. Any idea what might be causing this? Here's some of my code. Apollo looks the exact same as what you have, I have a test page.

import React, { FunctionComponent } from 'react';
import TestComponent from '../components/TestComponent';
import withData from '../Apollo';

export default withData((props: any) => {
  return (
    <TestComponent />
  )
})
import React, { FunctionComponent } from 'react';
import { useQuery } from '@apollo/react-hooks';
import { gql } from 'apollo-boost';

const MY_QUERY = gql`QUERY INSIDE HERE`

const TestComponent: FunctionComponent = () => {
  const { data } = useQuery(MY_QUERY, {
    notifyOnNetworkStatusChange: true,
  });

  if (data) {
    return (
      <div>
        <div>I'll map through data here.</div>
      </div>
    );
  } else {
    return <div>Loading...</div>;
  }
};

export default TestComponent;
@ZhiXiao-Lin
Copy link

I'm trying to integrate this into a project I'm working on but I keep getting the following error:

Could not find "client" in the context or passed in as an option. Wrap the root component in an , or pass an ApolloClient instance in via options.

I've followed along exactly with the example you built but still get the error. Any idea what might be causing this? Here's some of my code. Apollo looks the exact same as what you have, I have a test page.

import React, { FunctionComponent } from 'react';
import TestComponent from '../components/TestComponent';
import withData from '../Apollo';

export default withData((props: any) => {
  return (
    <TestComponent />
  )
})
import React, { FunctionComponent } from 'react';
import { useQuery } from '@apollo/react-hooks';
import { gql } from 'apollo-boost';

const MY_QUERY = gql`QUERY INSIDE HERE`

const TestComponent: FunctionComponent = () => {
  const { data } = useQuery(MY_QUERY, {
    notifyOnNetworkStatusChange: true,
  });

  if (data) {
    return (
      <div>
        <div>I'll map through data here.</div>
      </div>
    );
  } else {
    return <div>Loading...</div>;
  }
};

export default TestComponent;

I had the same problem as you. I tried to replace the default version of "next-apollo": "^2.1.3" with "next-apollo": "^3.0.0-beta.5" and it worked.

@dcjones1
Copy link
Author

That's my exact issue. Thanks!

@adamsoffer
Copy link
Owner

Thanks @ZhiXiao-Lin. Heads up, I just published v3.0.0.

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