Something went wrong. Try again.
Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
Something went wrong. Try again.
583 B · 20 lines
TypeScript
at main
123456789101112131415161718192021import type { Client } from '@urql/core';import { createContext, useContext } from 'solid-js';
export const Context = createContext<Client>();export const Provider = Context.Provider;
export type UseClient = () => Client;export const useClient: UseClient = () => { const client = useContext(Context);
if (process.env.NODE_ENV !== 'production' && client === undefined) { const error = "No client has been specified using urql's Provider. please create a client and add a Provider.";
console.error(error); throw new Error(error); }
return client!;};