aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-09-28 16:40:08 -0700
committerFuwn <[email protected]>2024-09-28 16:40:12 -0700
commit802dcc9f5a4b2f0824e2600cd080d33691056d16 (patch)
tree23c194f2410e21009981a8e475e703bd210b5b4e
parentfeat(html): update analytics url (diff)
downloaddue.moe-802dcc9f5a4b2f0824e2600cd080d33691056d16.tar.xz
due.moe-802dcc9f5a4b2f0824e2600cd080d33691056d16.zip
feat(api): set up graphql api
-rw-r--r--.eslintignore10
-rw-r--r--.gitignore4
-rw-r--r--.graphqlrc.yaml10
-rw-r--r--.prettierignore10
-rwxr-xr-xbun.lockbbin236752 -> 367541 bytes
-rw-r--r--houdini.config.js9
-rw-r--r--package.json1
-rw-r--r--src/graphql/client.ts3
-rw-r--r--src/graphql/hello/index.ts4
-rw-r--r--src/graphql/hello/resolvers.ts10
-rw-r--r--src/graphql/hello/schema.graphql3
-rw-r--r--src/graphql/server.ts7
-rw-r--r--src/routes/graphql/+server.ts1
-rw-r--r--svelte.config.js4
-rw-r--r--tsconfig.json11
-rw-r--r--vite.config.ts3
16 files changed, 79 insertions, 11 deletions
diff --git a/.eslintignore b/.eslintignore
index a92e9442..2af08fd4 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -24,5 +24,15 @@ package-lock.json
# Vercel
.vercel
+# Vite
+vite.config.*.timestamp-*
+
# Trigger.dev
.trigger
+
+# direnv
+.direnv
+
+# GraphQL
+/.sveltekit-graphql
+/$houdini
diff --git a/.gitignore b/.gitignore
index 4e9c03f0..aed123d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,7 @@ vite.config.*.timestamp-*
# direnv
.direnv
+
+# GraphQL
+/.sveltekit-graphql
+/$houdini
diff --git a/.graphqlrc.yaml b/.graphqlrc.yaml
new file mode 100644
index 00000000..dc5adfeb
--- /dev/null
+++ b/.graphqlrc.yaml
@@ -0,0 +1,10 @@
+projects:
+ default:
+ schema:
+ - ./src/graphql/**/*.graphql
+ - ./$houdini/graphql/schema.graphql
+ documents:
+ - './src/**/*.gql'
+ - './src/**/*.svelte'
+ - './src/**/*.ts'
+ - ./$houdini/graphql/documents.gql
diff --git a/.prettierignore b/.prettierignore
index a92e9442..2af08fd4 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -24,5 +24,15 @@ package-lock.json
# Vercel
.vercel
+# Vite
+vite.config.*.timestamp-*
+
# Trigger.dev
.trigger
+
+# direnv
+.direnv
+
+# GraphQL
+/.sveltekit-graphql
+/$houdini
diff --git a/bun.lockb b/bun.lockb
index 3f8c2a5c..8ff1fb56 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
diff --git a/houdini.config.js b/houdini.config.js
new file mode 100644
index 00000000..31abe6d4
--- /dev/null
+++ b/houdini.config.js
@@ -0,0 +1,9 @@
+import { createHoudiniConfig } from 'sveltekit-graphql/config';
+
+const config = createHoudiniConfig({
+ scalars: {
+ // You can define custom scalars here
+ }
+});
+
+export default config;
diff --git a/package.json b/package.json
index a573503a..d714c14c 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"svelte-preprocess": "^5.1.3",
+ "sveltekit-graphql": "^0.4.3",
"sveltekit-rate-limiter": "^0.4.2",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
diff --git a/src/graphql/client.ts b/src/graphql/client.ts
new file mode 100644
index 00000000..367b8381
--- /dev/null
+++ b/src/graphql/client.ts
@@ -0,0 +1,3 @@
+import { HoudiniClient } from '$houdini';
+
+export default new HoudiniClient({ url: '/graphql' });
diff --git a/src/graphql/hello/index.ts b/src/graphql/hello/index.ts
new file mode 100644
index 00000000..925a7ece
--- /dev/null
+++ b/src/graphql/hello/index.ts
@@ -0,0 +1,4 @@
+import typeDefs from './schema.graphql?raw';
+import { resolvers } from './resolvers';
+
+export default { typeDefs, resolvers };
diff --git a/src/graphql/hello/resolvers.ts b/src/graphql/hello/resolvers.ts
new file mode 100644
index 00000000..f882765f
--- /dev/null
+++ b/src/graphql/hello/resolvers.ts
@@ -0,0 +1,10 @@
+import type { WithIndex } from '../$types';
+import type { Resolvers } from './$types';
+
+export const resolvers: WithIndex<Resolvers> = {
+ Query: {
+ hello() {
+ return 'Hello SvelteKit!';
+ }
+ }
+};
diff --git a/src/graphql/hello/schema.graphql b/src/graphql/hello/schema.graphql
new file mode 100644
index 00000000..d3dba234
--- /dev/null
+++ b/src/graphql/hello/schema.graphql
@@ -0,0 +1,3 @@
+type Query {
+ hello: String!
+}
diff --git a/src/graphql/server.ts b/src/graphql/server.ts
new file mode 100644
index 00000000..ad3ea146
--- /dev/null
+++ b/src/graphql/server.ts
@@ -0,0 +1,7 @@
+import { createSchema, createServer } from 'sveltekit-graphql';
+import helloModule from './hello';
+
+const schema = createSchema([helloModule]);
+const server = createServer(schema);
+
+export default server;
diff --git a/src/routes/graphql/+server.ts b/src/routes/graphql/+server.ts
new file mode 100644
index 00000000..f8e47dc5
--- /dev/null
+++ b/src/routes/graphql/+server.ts
@@ -0,0 +1 @@
+export { default as GET, default as POST, default as OPTIONS } from '$graphql/server';
diff --git a/svelte.config.js b/svelte.config.js
index 91510173..0bb1f8ad 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -18,7 +18,9 @@ const config = {
adapter: adapter(),
alias: {
$stores: './src/stores',
- $styles: './src/styles'
+ $styles: './src/styles',
+ $graphql: './src/graphql',
+ $houdini: './$houdini'
}
},
split: true
diff --git a/tsconfig.json b/tsconfig.json
index a34c1174..a45f7467 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,17 +9,10 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
-
- // https://github.com/sveltejs/svelte/blob/master/packages/svelte/tsconfig.json
"stripInternal": true,
-
"noImplicitThis": true,
"noUnusedLocals": true,
- "noUnusedParameters": true
+ "noUnusedParameters": true,
+ "rootDirs": [".", "./.svelte-kit/types", "./.sveltekit-graphql/types", "./$houdini/types"]
}
-
- // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
- //
- // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
- // from the referenced tsconfig.json - TypeScript does not merge them in
}
diff --git a/vite.config.ts b/vite.config.ts
index 2737c408..3914dcb4 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,9 +1,10 @@
import { sveltekit } from '@sveltejs/kit/vite';
+import sveltekitGql from 'sveltekit-graphql/vite';
import { defineConfig } from 'vite';
// import { webSocketServer } from '$lib/websocket';
export default defineConfig({
- plugins: [sveltekit() /* webSocketServer */],
+ plugins: [sveltekitGql(), sveltekit() /* webSocketServer */],
server: {
// https: {
// key: Bun.env.PUBLIC_ANILIST_REDIRECT_URI?.includes('192.168')