init
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VITE_GRAPHQL_ENDPOINT=http://localhost:8080/query
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules/
|
||||||
|
.env
|
||||||
1
.npmrc
Normal file
1
.npmrc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
registry=https://package-mirror.liara.ir/repository/npm
|
||||||
23
README.md
Normal file
23
README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
### Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Serve
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx serve dist/
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx vite preview
|
||||||
|
```
|
||||||
2
dist/graphiql.css
vendored
Normal file
2
dist/graphiql.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/graphiql.js
vendored
Normal file
1
dist/graphiql.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
dist/index.html
vendored
Normal file
12
dist/index.html
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>GraphiQL</title>
|
||||||
|
<script type="module" crossorigin src="./graphiql.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="./graphiql.css">
|
||||||
|
</head>
|
||||||
|
<body style="margin: 0; padding: 0;">
|
||||||
|
<div id="root" style="height:100vh; margin: 0; padding: 0;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
11
index.html
Normal file
11
index.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>GraphiQL</title>
|
||||||
|
</head>
|
||||||
|
<body style="margin: 0; padding: 0;">
|
||||||
|
<div id="root" style="height:100vh; margin: 0; padding: 0;"></div>
|
||||||
|
<script type="module" src="main.jsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
28
main.jsx
Normal file
28
main.jsx
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import React from "react";
|
||||||
|
import ReactDOM from "react-dom/client";
|
||||||
|
import { GraphiQL } from "graphiql";
|
||||||
|
|
||||||
|
import "graphiql/graphiql.css";
|
||||||
|
|
||||||
|
const fetcher = async (params) => {
|
||||||
|
const res = await fetch(import.meta.env.VITE_GRAPHQL_ENDPOINT, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(params),
|
||||||
|
});
|
||||||
|
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
return (
|
||||||
|
<GraphiQL
|
||||||
|
fetcher={fetcher}
|
||||||
|
defaultEditorToolsVisibility={true}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
|
||||||
2606
package-lock.json
generated
Normal file
2606
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "graphi-vite",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {
|
||||||
|
"graphiql": "^4.1.2",
|
||||||
|
"react": "^19.2.4",
|
||||||
|
"react-dom": "^19.2.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"terser": "^5.46.1",
|
||||||
|
"vite": "^8.0.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
40
vite.config.js
Normal file
40
vite.config.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
base: "./",
|
||||||
|
|
||||||
|
build: {
|
||||||
|
target: "es2018",
|
||||||
|
|
||||||
|
cssCodeSplit: false,
|
||||||
|
minify: "terser",
|
||||||
|
|
||||||
|
terserOptions: {
|
||||||
|
compress: {
|
||||||
|
passes: 3,
|
||||||
|
drop_console: true,
|
||||||
|
drop_debugger: true
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
comments: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
manualChunks: undefined,
|
||||||
|
codeSplitting: false,
|
||||||
|
|
||||||
|
entryFileNames: "graphiql.js",
|
||||||
|
chunkFileNames: "graphiql.js",
|
||||||
|
|
||||||
|
assetFileNames: (assetInfo) => {
|
||||||
|
if (assetInfo?.name && assetInfo.name.endsWith(".css")) {
|
||||||
|
return "graphiql.css";
|
||||||
|
}
|
||||||
|
return "assets/[name][extname]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user