@urql/preact
TypeScript icon, indicating that this package has built-in type declarations

4.0.4 • Public • Published

Installation

yarn add @urql/preact urql graphql
# or
npm install --save @urql/preact urql graphql

Usage

The usage is a 1:1 mapping of the React usage found here

small example:

import { createClient, dedupExchange, cacheExchange, fetchExchange, Provider, useQuery } from '@urql/preact';

const client = createClient({
  url: 'https://myHost/graphql',
  exchanges: [dedupExchange, cacheExchange, fetchExchange],
});

const App = () => (
  <Provider value={client}>
    <Dogs />
  </Provider>
);

const Dogs = () => {
  const [result] = useQuery({
    query: `{ dogs { id name } }`,
  });

  if (result.fetching) return <p>Loading...</p>;
  if (result.error) return <p>Oh no...</p>;

  return result.data.dogs.map(dog => <p>{dog.name} is a good boy!</p>);
};

Package Sidebar

Install

npm i @urql/preact

Weekly Downloads

449

Version

4.0.4

License

MIT

Unpacked Size

290 kB

Total Files

13

Last publish

Collaborators

  • scottianstewart
  • keithluchtel
  • ceceppa
  • robwalkerco
  • sarahformidable
  • scott-rippey
  • michaelmerrill
  • sarmeyer
  • mariano-formidable
  • ryan.roemer
  • formidable-owner
  • formidablelabs
  • carbonrobot
  • masiddee
  • philpl
  • andyrichardson
  • jdecroock
  • parkerziegler
  • npm-urql