Urql: Cannot read property '__key' of undefined

Created on 27 Feb 2019  路  3Comments  路  Source: FormidableLabs/urql

Running a basic query with the useQuery() hook fails with the above error. The same query works using the <Query /> component.

Reproduction: https://codesandbox.io/s/9zl9v10xzr

Most helpful comment

Oh super sorry about that! I'll fix that up. Thanks for the heads up 鉂わ笍

All 3 comments

You're passing a string go useQuery but it accepts a couple of options :) please check the docs on the exact usage of this hook. The shortest intro can be found here: https://github.com/FormidableLabs/urql/blob/master/docs/getting-started.md#using-hooks

There's also a small API doc. The docs will all be available as a site soon. :)

Ohhh. Heads up @kitten, the example in root level README.md passes a string instead of an options object.

import { useQuery } from 'urql';

const YourComponent = () => {
  const [{ fetching, data }] = useQuery(`{ todos { id } }`);
  return fetching ? <Loading /> : <List data={data.todos} />;
};

Oh super sorry about that! I'll fix that up. Thanks for the heads up 鉂わ笍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frederikhors picture frederikhors  路  3Comments

maxzhuk0v picture maxzhuk0v  路  3Comments

davidhouweling picture davidhouweling  路  4Comments

dotansimha picture dotansimha  路  4Comments

Andrew-Talley picture Andrew-Talley  路  4Comments