Create Apollo Provider
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user