Skip to content

Commit

Permalink
Added graphql codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
rithik-b committed Dec 6, 2023
1 parent d5ec1e2 commit 0d122df
Show file tree
Hide file tree
Showing 7 changed files with 1,900 additions and 127 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ yarn-error.log*
.env

# rust
target/
target/
/apps/web/src/__generated__/
2 changes: 1 addition & 1 deletion apps/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
19 changes: 19 additions & 0 deletions apps/web/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CodegenConfig } from "@graphql-codegen/cli"

const config: CodegenConfig = {
schema: `${process.env.NEXT_PUBLIC_BEATFORGE_API_URL}/graphql`,
// this assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure
documents: ["src/**/*.{ts,tsx}"],
generates: {
"./src/__generated__/": {
preset: "client",
plugins: [],
presetConfig: {
gqlTagName: "gql",
},
},
},
ignoreNoDocuments: true,
}

export default config
13 changes: 12 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
"private": true,
"scripts": {
"dev": "next dev",
"prebuild": "pnpm compile",
"build": "next build",
"predev": "pnpm watch",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"compile": "env-cmd graphql-codegen",
"watch": "env-cmd graphql-codegen -w"
},
"dependencies": {
"@apollo/client": "^3.8.8",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"env-cmd": "^10.1.0",
"geist": "^1.2.0",
"graphql": "^16.8.0",
"lucide-react": "^0.294.0",
Expand All @@ -22,6 +27,9 @@
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/client-preset": "^4.1.0",
"@graphql-typed-document-node/core": "^3.2.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand All @@ -33,5 +41,8 @@
"prettier-plugin-tailwindcss": "^0.5.3",
"tailwindcss": "^3.3.0",
"typescript": "^5"
},
"peerDependencies": {
"@parcel/watcher": "^2.3.0"
}
}
6 changes: 3 additions & 3 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Home = () => {
return <main className=""></main>;
};
return <main className=""></main>
}

export default Home;
export default Home
3 changes: 2 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
"node_modules",
"src/__generated__"
]
}
Loading

0 comments on commit 0d122df

Please sign in to comment.