added basic houdini graphql client incl. test query

This commit is contained in:
Samuel Andert 2023-07-29 15:09:21 +02:00
parent 414705e0b4
commit fa5764c303
12 changed files with 8849 additions and 111 deletions

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
$houdini

9
.graphqlrc.yaml Normal file
View File

@ -0,0 +1,9 @@
projects:
default:
schema:
- ./schema.graphql
- ./$houdini/graphql/schema.graphql
documents:
- '**/*.gql'
- '**/*.svelte'
- ./$houdini/graphql/documents.gql

13
houdini.config.js Normal file
View File

@ -0,0 +1,13 @@
/// <references types="houdini-svelte">
/** @type {import('houdini').ConfigFile} */
const config = {
"watchSchema": {
"url": "https://graphql.andert.me/api/graphql"
},
"plugins": {
"houdini-svelte": {}
}
}
export default config

View File

@ -38,7 +38,9 @@
"typescript": "^5.1.6",
"vite": "^4.4.7",
"vitest": "^0.32.4",
"zod": "^3.21.4"
"zod": "^3.21.4",
"houdini": "^1.2.8",
"houdini-svelte": "^1.2.8"
},
"type": "module",
"dependencies": {

File diff suppressed because it is too large Load Diff

8154
schema.graphql Normal file

File diff suppressed because it is too large Load Diff

15
src/client.ts Normal file
View File

@ -0,0 +1,15 @@
import { HoudiniClient } from '$houdini';
export default new HoudiniClient({
url: 'https://graphql.andert.me/api/graphql'
// uncomment this to configure the network call (for things like authentication)
// for more information, please visit here: https://www.houdinigraphql.com/guides/authentication
// fetchParams({ session }) {
// return {
// headers: {
// Authentication: `Bearer ${session.token}`,
// }
// }
// }
})

View File

@ -0,0 +1,6 @@
query queryTest {
repoGet(owner: "samuelandert.eth", repo: "learn") {
id
name
}
}

View File

@ -1,5 +1,9 @@
<script>
<script lang="ts">
import Composite from '$lib/core/Composite.svelte';
import type { PageData } from './$houdini';
export let data: PageData;
$: ({ queryTest } = data);
let composite = {
id: 'test',
@ -26,4 +30,6 @@
};
</script>
<!-- {JSON.stringify($queryTest.data, null, 2)} -->
<Composite {composite} />

View File

@ -1,14 +1,22 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
adapter: adapter(),
alias: {
$houdini: './$houdini',
}
},
ssr: {
// Other SSR options...
dynamicImportShim: false
},
preprocess: vitePreprocess(),
};
export default config;

View File

@ -9,16 +9,21 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"types": ["jest", "node"]
"types": [
"jest",
"node"
],
"rootDirs": [
".",
"./.svelte-kit/types",
"./$houdini/types"
]
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.svelte",
"tests/**/*.ts"
, "tests/provider.test.js" ]
// 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
"tests/**/*.ts",
"tests/provider.test.js"
]
}

View File

@ -1,3 +1,7 @@
import houdini from 'houdini/vite'
import { sveltekit } from '@sveltejs/kit/vite'
import { defineConfig } from 'vite'
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import * as fs from 'fs';
@ -52,6 +56,7 @@ function getRecursiveDataFiles(dir) {
export default defineConfig({
plugins: [
houdini(),
sveltekit(),
{
name: 'components-resolver',