Skip to content

Commit c770519

Browse files
committed
chore(heureka): codegen integration
1 parent 43fc5b7 commit c770519

File tree

8 files changed

+4624
-109
lines changed

8 files changed

+4624
-109
lines changed

apps/heureka-next/codegen.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { CodegenConfig } from "@graphql-codegen/cli"
2+
import * as dotenv from "dotenv"
3+
4+
// Load environment variables from .env file
5+
dotenv.config()
6+
const schemaUrl = ""
7+
8+
const config: CodegenConfig = {
9+
schema: schemaUrl,
10+
documents: "src/**/*.graphql",
11+
12+
generates: {
13+
"src/generated/graphql.tsx": {
14+
plugins: ["typescript", "typescript-operations", "typescript-react-apollo"],
15+
config: {
16+
withHooks: true,
17+
withHOC: false,
18+
withComponent: false,
19+
},
20+
},
21+
},
22+
}
23+
24+
export default config

apps/heureka-next/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dev": "vite",
1818
"build": "vite build",
1919
"build:static": "vite build --mode static",
20+
"generate:types": "graphql-codegen --config codegen.ts",
2021
"serve": "vite preview",
2122
"test": "vitest run",
2223
"lint": "eslint",
@@ -31,6 +32,11 @@
3132
"react-dom": "18.3.1"
3233
},
3334
"devDependencies": {
35+
"@apollo/client": "^3.11.10",
36+
"@graphql-codegen/cli": "^5.0.3",
37+
"@graphql-codegen/typescript": "^4.1.2",
38+
"@graphql-codegen/typescript-operations": "^4.4.0",
39+
"@graphql-codegen/typescript-react-apollo": "^4.3.2",
3440
"@cloudoperators/juno-config": "*",
3541
"@testing-library/jest-dom": "6.6.3",
3642
"@testing-library/react": "16.2.0",

apps/heureka-next/src/App.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ import React from "react"
77
import { AppShellProvider } from "@cloudoperators/juno-ui-components"
88
import { ErrorBoundary } from "./components/ErrorBoundary"
99
import { Shell } from "./components/Shell"
10+
import { ApolloProvider } from "@apollo/client"
11+
import { client } from "./apollo-client"
1012

1113
export type AppProps = {
1214
theme?: "theme-dark" | "theme-light"
1315
embedded?: boolean
1416
}
1517

1618
export const App = (props: AppProps) => (
17-
<AppShellProvider theme={`${props.theme ? props.theme : "theme-dark"}`}>
18-
<ErrorBoundary>
19-
<Shell {...props} />
20-
</ErrorBoundary>
21-
</AppShellProvider>
19+
<ApolloProvider client={client}>
20+
<AppShellProvider theme={`${props.theme ? props.theme : "theme-dark"}`}>
21+
<ErrorBoundary>
22+
<Shell {...props} />
23+
</ErrorBoundary>
24+
</AppShellProvider>
25+
<App />
26+
</ApolloProvider>
2227
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ApolloClient, InMemoryCache } from "@apollo/client"
2+
3+
export const client = new ApolloClient({
4+
uri: "",
5+
cache: new InMemoryCache(),
6+
})

apps/heureka-next/src/components/Services/Services.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,19 @@
44
*/
55

66
import React from "react"
7+
import { useGetServicesQuery } from "../../generated/graphql"
78

8-
export const Services = () => <div>render services here...</div>
9+
export const Services = () => {
10+
const { data, loading, error } = useGetServicesQuery()
11+
if (loading) return <p>Loading...</p>
12+
if (error) return <p>Error</p>
13+
14+
return (
15+
<div>
16+
{data?.Services?.edges?.map((service) => {
17+
console.log("TEST NAME", service?.node.ccrn)
18+
return <p>{service?.node.ccrn}</p>
19+
})}
20+
</div>
21+
)
22+
}

0 commit comments

Comments
 (0)