0

I've began to learn graphql (adding relay here), so i followed up the steps to have relay running, i created my first query:

function fetchQuery(operation, variables) {
  return fetch("http://localhost:3000/graphql", {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      query: operation.text,
      variables
    })
  }).then(response => {
    return response.json();
  });
}

const modernEnvironment = new Environment({
  network: Network.create(fetchQuery),
  store: new Store(new RecordSource())
});

class ClientList extends React.PureComponent {
  render() {
    return (
      <QueryRenderer
        envieronment={modernEnvironment}
        query={graphql`
          query ClientListQuery {
            clients {
              name
              cnpj
              ie
            }
          }
        `}
        variables={{}}
        render={({ error, props }) => {
          console.log("props", props);
          return <h1>hi</h1>;
        }}
      />
    );
  }
}

But it fails, with the following error on console:

Uncaught TypeError: Cannot read property 'unstable_internal' of undefined at fetchQueryAndComputeStateFromProps (ReactRelayQueryRenderer.js:214) at new ReactRelayQueryRenderer (ReactRelayQueryRenderer.js:74) at constructClassInstance (react-dom.development.js:11447) at updateClassComponent (react-dom.development.js:13144) at beginWork (react-dom.development.js:13824) at performUnitOfWork (react-dom.development.js:15863) at workLoop (react-dom.development.js:15902) at HTMLUnknownElement.callCallback (react-dom.development.js:100) at Object.invokeGuardedCallbackDev (react-dom.development.js:138) at invokeGuardedCallback (react-dom.development.js:187)

Thanks.

PlayMa256
  • 6,603
  • 2
  • 34
  • 54
  • 1
    Possible duplicate of [Detecting an undefined object property](https://stackoverflow.com/questions/27509/detecting-an-undefined-object-property) – marekful Aug 02 '18 at 14:22
  • Not really, because i don't want to detect anything inside relay, somehow it threw an error on relay, and it has no signs of what has throw it. I cannot debug relay source-code, so it is not in my realm. And also, that does not answer this question. – PlayMa256 Aug 02 '18 at 14:23

0 Answers0