| 19 | } |
| 20 | |
| 21 | function makeClient() { |
| 22 | const apiOrigin = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080' |
| 23 | const httpLink = new HttpLink({ |
| 24 | uri: `${apiOrigin}/graphql`, |
| 25 | fetchOptions: { cache: 'no-cache' }, |
| 26 | }) |
| 27 | |
| 28 | return new NextSSRApolloClient({ |
| 29 | cache: new NextSSRInMemoryCache(), |
| 30 | link: |
| 31 | typeof window === 'undefined' |
| 32 | ? ApolloLink.from([ |
| 33 | new SSRMultipartLink({ |
| 34 | stripDefer: true, |
| 35 | }), |
| 36 | httpLink, |
| 37 | ]) |
| 38 | : httpLink, |
| 39 | }) |
| 40 | } |
| 41 | |
| 42 | export function ApolloWrapper({ children }: React.PropsWithChildren) { |
| 43 | return ( |