Create Apollo Provider

This commit is contained in:
2024-01-06 23:58:54 -07:00
parent 491ca28ab2
commit f797c98d45
4 changed files with 138 additions and 21 deletions

View File

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