Update gql config

This commit is contained in:
Hazem Krimi
2021-06-17 03:28:36 +01:00
parent 8a9aec133c
commit 402e6774cb
3 changed files with 40 additions and 11 deletions
View File
+14
View File
@@ -0,0 +1,14 @@
overwrite: true
schema: 'https://astrobuild-support-service.herokuapp.com'
documents: 'src/graphql/*.api.support.ts'
config:
withHOC: false
scalars:
Date: Date
enumsAsTypes: true
withHooks: true
generates:
src/graphql/types.support.ts:
plugins:
- 'typescript'
- 'typescript-operations'
+26 -11
View File
@@ -6,6 +6,8 @@ import {
createHttpLink,
ApolloProvider,
} from '@apollo/client';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
import { setContext } from '@apollo/client/link/context';
import { ThemeProvider } from 'styled-components';
import { BrowserRouter } from 'react-router-dom';
@@ -14,10 +16,16 @@ import App from './App';
import GlobalStyles from './GlobalStyles';
import reportWebVitals from './reportWebVitals';
const httpLink = createHttpLink({
const stripePromise = loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');
const httpLinkMain = createHttpLink({
uri: process.env.REACT_APP_GRAPHQL_API,
});
const httpLinkSupport = createHttpLink({
uri: process.env.REACT_APP_GRAPHQL_SUPPORT_API,
});
const authLink = setContext((_, { headers }) => {
const token = localStorage.getItem('token');
@@ -29,21 +37,28 @@ const authLink = setContext((_, { headers }) => {
};
});
const client = new ApolloClient({
link: authLink.concat(httpLink),
export const clientMain = new ApolloClient({
link: authLink.concat(httpLinkMain),
cache: new InMemoryCache(),
});
export const clientSupport = new ApolloClient({
link: authLink.concat(httpLinkSupport),
cache: new InMemoryCache(),
});
ReactDOM.render(
<React.StrictMode>
<ApolloProvider client={client}>
<ThemeProvider theme={theme}>
<BrowserRouter>
<App />
<GlobalStyles />
</BrowserRouter>
</ThemeProvider>
</ApolloProvider>
<Elements stripe={stripePromise}>
<ApolloProvider client={clientMain}>
<ThemeProvider theme={theme}>
<BrowserRouter>
<App />
<GlobalStyles />
</BrowserRouter>
</ThemeProvider>
</ApolloProvider>
</Elements>
</React.StrictMode>,
document.getElementById('root')
);