railbird-gql/graphql/client.tsx

29 lines
532 B
TypeScript
Raw Normal View History

2024-01-06 23:58:54 -07:00
import React, { ReactNode } from "react";
2024-01-06 23:48:47 -07:00
import {
ApolloClient,
InMemoryCache,
ApolloProvider,
HttpLink,
from,
} from "@apollo/client";
import { API_URI } from "@env";
2024-01-06 23:58:54 -07:00
type Props = {
children: ReactNode;
};
const ClientProvider: React.FC<Props> = ({ children }) => {
const httpLink = new HttpLink({
uri: API_URI,
});
2024-01-06 23:48:47 -07:00
2024-01-06 23:58:54 -07:00
const client = new ApolloClient({
link: from([httpLink]),
cache: new InMemoryCache(),
});
2024-01-06 23:48:47 -07:00
return <ApolloProvider client={client}>{children}</ApolloProvider>;
};
2024-01-06 23:58:54 -07:00
export default ClientProvider;