railbird-gql/graphql/client.tsx
2024-01-08 00:21:36 -07:00

29 lines
532 B
TypeScript

import React, { ReactNode } from "react";
import {
ApolloClient,
InMemoryCache,
ApolloProvider,
HttpLink,
from,
} from "@apollo/client";
import { API_URI } from "@env";
type Props = {
children: ReactNode;
};
const ClientProvider: React.FC<Props> = ({ children }) => {
const httpLink = new HttpLink({
uri: API_URI,
});
const client = new ApolloClient({
link: from([httpLink]),
cache: new InMemoryCache(),
});
return <ApolloProvider client={client}>{children}</ApolloProvider>;
};
export default ClientProvider;