Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ async function main() {
main()
```

### Using vanilla JavaScript instead of TypeScript

GraphClient CLI generates the client artifacts as TypeScript files by default but you can configure CLI to generate JavaScript and JSON files together with additional TypeScript definition files by using `--fileType js` or `--fileType json`.

`js` flag generates all files as JavaScript files with ESM Syntax and `json` flag generates source artifacts as JSON files while entrypoint JavaScript file with old CommonJS syntax because only CommonJS supports JSON files as modules.

Unless you use CommonJS(`require`) specifically, we'd recommend you to use `js` flag.

`graphclient --fileType js`

- [An example for JavaScript usage in CommonJS syntax with JSON files](/examples/javascript-cjs/)
- [An example for JavaScript usage in ESM syntax](/examples/javascript-esm/)

#### The Graph Client DevTools

The Graph Client CLI comes with a built-in GraphiQL so you can experiemnt with queries in real time.
Expand Down
8 changes: 0 additions & 8 deletions examples/apollo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,5 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
setImmediate = (fn) => setTimeout(fn)
process = {
env: {
DEBUG: 1,
},
}
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/apollo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
define: {
process: JSON.stringify({
env: {
DEBUG: 1,
},
}),
},
})
8 changes: 0 additions & 8 deletions examples/execute/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,5 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
setImmediate = (fn) => setTimeout(fn)
process = {
env: {
DEBUG: 1,
},
}
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/execute/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
define: {
process: JSON.stringify({
env: {
DEBUG: 1,
},
}),
},
})
8 changes: 0 additions & 8 deletions examples/react-query/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,5 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
setImmediate = (fn) => setTimeout(fn)
process = {
env: {
DEBUG: 1,
},
}
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/react-query/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
define: {
process: JSON.stringify({
env: {
DEBUG: 1,
},
}),
},
})
8 changes: 0 additions & 8 deletions examples/urql/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,5 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
setImmediate = (fn) => setTimeout(fn)
process = {
env: {
DEBUG: 1,
},
}
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/urql/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
define: {
process: JSON.stringify({
env: {
DEBUG: 1,
},
}),
},
})