-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
141 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
module.exports = { | ||
// @ts-check | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
env: { | ||
API_URL: process.env.API_URL, | ||
WS_URL: process.env.WS_URL, | ||
}, | ||
output: 'export', | ||
experimental: { | ||
typedRoutes: true, | ||
}, | ||
typescript: { | ||
// We can ignore it because we have another job in the pipeline for static analysis | ||
ignoreBuildErrors: true, | ||
}, | ||
}; | ||
|
||
module.exports = nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
import { initApolloClient } from '../lib/apollo'; | ||
import { ApolloProvider } from '@apollo/client'; | ||
|
||
export const ApolloWrapper = ({ children }: { children: React.ReactNode }) => { | ||
const [client] = useState(initApolloClient); | ||
|
||
return <ApolloProvider client={client}>{children}</ApolloProvider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ApolloClient, InMemoryCache, split } from '@apollo/client'; | ||
import { registerApolloClient } from '@apollo/experimental-nextjs-app-support/rsc'; | ||
import { getMainDefinition } from '@apollo/client/utilities'; | ||
import { GraphQLWsLink } from '@apollo/client/link/subscriptions'; | ||
import { createClient } from 'graphql-ws'; | ||
import { HttpLink } from '@apollo/client/link/http'; | ||
|
||
export const { getClient } = registerApolloClient(() => { | ||
let apiUrl = process.env.API_URL; | ||
if (apiUrl === undefined && typeof window !== 'undefined') { | ||
apiUrl = `${window.location.protocol}//${window.location.host}/graphql`; | ||
} | ||
|
||
const httpLink = new HttpLink({ | ||
uri: apiUrl, | ||
credentials: 'same-origin', | ||
}); | ||
|
||
let wsUrl = process.env.WS_URL; | ||
if (wsUrl === undefined) { | ||
wsUrl = `${window.location.protocol === 'http:' ? 'ws' : 'wss'}://${ | ||
window.location.host | ||
}/graphql`; | ||
} | ||
|
||
const wsLink = new GraphQLWsLink( | ||
createClient({ | ||
url: wsUrl, | ||
}), | ||
); | ||
|
||
const link = split( | ||
// split based on operation type | ||
({ query }) => { | ||
const definition = getMainDefinition(query); | ||
return ( | ||
definition.kind === 'OperationDefinition' && definition.operation === 'subscription' | ||
); | ||
}, | ||
wsLink, | ||
httpLink, | ||
); | ||
|
||
return new ApolloClient({ | ||
cache: new InMemoryCache(), | ||
link, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { Metadata } from 'next'; | ||
import theme from '../theme'; | ||
import { AppRouterCacheProvider } from '@mui/material-nextjs/v13-appRouter'; | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import { Layout } from '../components/layout'; | ||
import { ApolloWrapper } from './ApolloWrapper'; | ||
|
||
export const metadata: Metadata = { | ||
title: 'GitLab Merger Bot', | ||
description: 'Welcome to Next.js', | ||
}; | ||
|
||
export default function RootLayout({ children }: { children: React.ReactElement }) { | ||
return ( | ||
<html lang='en'> | ||
<head> | ||
<meta | ||
name='viewport' | ||
content='minimum-scale=1, initial-scale=1, width=device-width' | ||
/> | ||
</head> | ||
<body style={{ backgroundColor: '#f8f8f8' }}> | ||
<ApolloWrapper> | ||
<AppRouterCacheProvider> | ||
<ThemeProvider theme={theme}> | ||
<CssBaseline /> | ||
|
||
<Layout>{children}</Layout> | ||
</ThemeProvider> | ||
</AppRouterCacheProvider> | ||
</ApolloWrapper> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.