URQL Computed Exchange
An URQL exchange to compute data using resolvers and entities.
Installation
$ npm i urql-computed-exchange
Usage
First, create your entities and their resolvers:
// entities.js; const Pokemon =
Then, add it to the list of exchanges in URQL when setting up the client:
// client.js ;; ; const client = ; ;
Finally, use the @computed
directive when declaring your GraphQL queries. Don't forget to indicate the corresponding type
:
// App.js ;;; const PokemonQuery = gql` query PokemonQuery { pokemon(name: "charmander") { id name numberOfEvolutions @computed(type: Pokemon) } }`; const App = { const res = ; if resfetching return 'Loading...'; return <pre> JSON </pre> ;}; ;