Skip to content

Commit

Permalink
feat: add codegen and tenant query
Browse files Browse the repository at this point in the history
  • Loading branch information
MARCO MANCO s281564 authored and QcFe committed Jul 8, 2021
1 parent 8b6ea40 commit 9b81191
Show file tree
Hide file tree
Showing 14 changed files with 4,581 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
frontend/src/generated-types.tsx linguist-generated=true
2 changes: 1 addition & 1 deletion deploy/crownlabs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ frontend-app:
path: /
configuration:
backend:
apiServer: https://apiserver.example.com
graphql: https://graphql.example.com
oidc:
clientId: <client-id>
clientSecret: <client-secret>
Expand Down
12 changes: 12 additions & 0 deletions frontend/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
overwrite: true
schema: "https://graphql.preprod.crownlabs.polito.it/"
documents: './src/**/*.graphql'
generates:
src/generated-types.tsx:
config:
withComponent: true
preResolveTypes: true
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
2 changes: 1 addition & 1 deletion frontend/deploy/frontend-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{- include "frontend-app.labels" . | nindent 4 }}
data:
{{ .Values.configuration.fileName }}: |
window.REACT_APP_CROWNLABS_APISERVER_URL="{{ .Values.configuration.backend.apiServer }}";
window.REACT_APP_CROWNLABS_GRAPHQL_URL="{{ .Values.configuration.backend.graphql }}";
window.REACT_APP_CROWNLABS_OIDC_PROVIDER_URL="{{ .Values.configuration.oidc.providerUrl }}";
window.REACT_APP_CROWNLABS_OIDC_CLIENT_ID="{{ .Values.configuration.oidc.clientId }}";
window.REACT_APP_CROWNLABS_OIDC_CLIENT_SECRET="{{ .Values.configuration.oidc.clientSecret }}";
Expand Down
2 changes: 1 addition & 1 deletion frontend/deploy/frontend-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configuration:
mountPath: /usr/share/nginx/html
fileName: config.js
backend:
apiServer: https://apiserver.example.com
graphql: https://graphql.example.com
oidc:
clientId: <client-id>
clientSecret: <client-secret>
Expand Down
13 changes: 11 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"private": true,
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@apollo/client": "^3.3.20",
"@apollo/react-hooks": "^4.0.0",
"@craco/craco": "^6.1.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
Expand All @@ -16,6 +18,7 @@
"antd": "^4.15.2",
"antd-button-color": "^1.0.4",
"craco-less": "^1.17.1",
"graphql": "^15.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
Expand All @@ -31,7 +34,8 @@
"build-storybook": "build-storybook -s public -o build",
"prepare": "cd .. && husky install frontend/.husky",
"check-format-lint": "prettier --check **/*.{ts,tsx,js,jsx,json,css} && eslint . --ext .ts --ext .tsx --ext .js --ext .jsx --max-warnings=0",
"pre-commit": "lint-staged"
"pre-commit": "lint-staged",
"generate": "graphql-codegen --config codegen.yml"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -85,6 +89,7 @@
]
},
"devDependencies": {
"@graphql-codegen/cli": "1.21.6",
"@storybook/addon-actions": "^6.2.8",
"@storybook/addon-essentials": "^6.2.8",
"@storybook/addon-links": "^6.2.8",
Expand All @@ -100,7 +105,11 @@
"prettier": "^2.2.1",
"storybook-addon-themes": "^6.1.0",
"storybook-preset-craco": "^0.0.4",
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
"tailwindcss": "npm:@tailwindcss/postcss7-compat",
"@graphql-codegen/typescript": "1.22.4",
"@graphql-codegen/typescript-react-apollo": "2.2.8",
"@graphql-codegen/typescript-operations": "1.18.3",
"@graphql-codegen/introspection": "1.18.2"
},
"resolutions": {
"babel-loader": "8.1.0"
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// template to define env variables on container start
// for local development the app falls back to local environment variables

window.REACT_APP_CROWNLABS_APISERVER_URL = undefined;
window.REACT_APP_CROWNLABS_GRAPHQL_URL = undefined;
window.REACT_APP_CROWNLABS_OIDC_PROVIDER_URL = undefined;
window.REACT_APP_CROWNLABS_OIDC_CLIENT_ID = undefined;
window.REACT_APP_CROWNLABS_OIDC_CLIENT_SECRET = undefined;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './App.css';
import { PUBLIC_URL, REACT_APP_CROWNLABS_APISERVER_URL } from './env';
import { PUBLIC_URL, REACT_APP_CROWNLABS_GRAPHQL_URL } from './env';
import { BrowserRouter, Link, Route, Switch } from 'react-router-dom';

function App() {
Expand Down Expand Up @@ -32,7 +32,7 @@ function App() {
<Route path="/" exact>
<div className="p-10 m-10">
CrownLabs will get a new look!
<br /> Apiserver at {REACT_APP_CROWNLABS_APISERVER_URL}{' '}
<br /> GraphQL at {REACT_APP_CROWNLABS_GRAPHQL_URL}{' '}
</div>

<Link to="/active">Go to active</Link>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type envVarNames =
| 'REACT_APP_CROWNLABS_APISERVER_URL'
| 'REACT_APP_CROWNLABS_GRAPHQL_URL'
| 'REACT_APP_CROWNLABS_OIDC_PROVIDER_URL'
| 'REACT_APP_CROWNLABS_OIDC_CLIENT_ID'
| 'REACT_APP_CROWNLABS_OIDC_CLIENT_SECRET'
Expand All @@ -16,9 +16,6 @@ const getEnvVar = (envVarName: envVarNames) => {
return envVar;
};

export const REACT_APP_CROWNLABS_APISERVER_URL = getEnvVar(
'REACT_APP_CROWNLABS_APISERVER_URL'
);
export const REACT_APP_CROWNLABS_OIDC_PROVIDER_URL = getEnvVar(
'REACT_APP_CROWNLABS_OIDC_PROVIDER_URL'
);
Expand All @@ -31,4 +28,7 @@ export const REACT_APP_CROWNLABS_OIDC_CLIENT_SECRET = getEnvVar(
export const REACT_APP_CROWNLABS_OIDC_REDIRECT_URI = getEnvVar(
'REACT_APP_CROWNLABS_OIDC_REDIRECT_URI'
);
export const REACT_APP_CROWNLABS_GRAPHQL_URL = getEnvVar(
'REACT_APP_CROWNLABS_GRAPHQL_URL'
);
export const PUBLIC_URL = getEnvVar('PUBLIC_URL');
Loading

0 comments on commit 9b81191

Please sign in to comment.