Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1import React from 'react'; 2import { Client, Provider, fetchExchange } from 'urql'; 3import { cacheExchange } from '@urql/exchange-graphcache'; 4import { relayPagination } from '@urql/exchange-graphcache/extras'; 5 6import PaginatedNpmSearch from './PaginatedNpmSearch'; 7 8const client = new Client({ 9 url: 'https://trygql.formidable.dev/graphql/relay-npm', 10 exchanges: [ 11 cacheExchange({ 12 resolvers: { 13 Query: { 14 search: relayPagination(), 15 }, 16 }, 17 }), 18 fetchExchange, 19 ], 20}); 21 22function App() { 23 return ( 24 <Provider value={client}> 25 <PaginatedNpmSearch /> 26 </Provider> 27 ); 28} 29 30export default App;