-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move from urql to houdini for graphql
- toasts now have a small border on the bottom for added visibility - with houdini came the removal of the local storage auth session token, meaning the source of truth for the session is now the cookie, happy days
- Loading branch information
Showing
56 changed files
with
1,086 additions
and
946 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ vite.config.ts.timestamp-* | |
|
||
.devcontainer/volumes | ||
.vercel | ||
|
||
$houdini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** @type {import('houdini').ConfigFile} */ | ||
const config = { | ||
schemaPath: '../api/src/_generated/nestjs-graphql/schema.gql', | ||
defaultCachePolicy: 'NetworkOnly', | ||
plugins: { | ||
'houdini-svelte': { | ||
framework: 'kit', | ||
client: './src/lib/houdini/client.ts', | ||
}, | ||
}, | ||
scalars: { | ||
DateTime: { | ||
type: 'Date', | ||
unmarshal(val) { | ||
return val ? new Date(val) : null; | ||
}, | ||
marshal(date) { | ||
return date && date.getTime(); | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
import type { Client } from '@urql/svelte'; | ||
/* eslint-disable @typescript-eslint/no-empty-interface */ | ||
|
||
import type { ClientUser } from './hooks.server'; | ||
import type { LayoutAlertData } from './lib/components/LayoutAlert/helper'; | ||
import type { ToastData } from './lib/components/ToastManager/helper'; | ||
import type { createHoudiniHelpers } from './lib/houdini/helper'; | ||
import type { Theme } from './lib/stores'; | ||
|
||
export interface AppLocals { | ||
gql: ReturnType<typeof createHoudiniHelpers>; | ||
sessionUser: ClientUser; | ||
theme?: Theme; | ||
} | ||
|
||
export interface AppPageData { | ||
sessionUser: ClientUser; | ||
layoutAlert: LayoutAlertData | undefined; | ||
toasts: ToastData[]; | ||
} | ||
|
||
export interface HoudiniSession { | ||
token?: string; | ||
} | ||
|
||
// See https://kit.svelte.dev/docs/types#app | ||
// for information about these interfaces | ||
declare global { | ||
namespace App { | ||
interface Locals { | ||
urql: Client; | ||
sessionUser: ClientUser; | ||
theme?: Theme; | ||
} | ||
interface PageData { | ||
sessionUser: ClientUser; | ||
layoutAlert: LayoutAlertData | undefined; | ||
toasts: ToastData[]; | ||
} | ||
interface Locals extends AppLocals {} | ||
interface PageData extends AppPageData {} | ||
// interface Error {} | ||
// interface Platform {} | ||
|
||
// Houdini | ||
interface Session extends HoudiniSession {} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { HoudiniClient } from '$houdini'; | ||
import { subscription } from '$houdini/plugins'; | ||
import { createClient as createWSClient } from 'graphql-ws'; | ||
import { getApiUrl } from '../utils'; | ||
|
||
const apiUrl = getApiUrl(); | ||
|
||
export default new HoudiniClient({ | ||
url: `${apiUrl.origin}/graphql`, | ||
fetchParams({ session }) { | ||
if (!session?.token) { | ||
return {}; | ||
} | ||
|
||
return { | ||
headers: { | ||
Authorization: `Bearer ${session.token}`, | ||
}, | ||
}; | ||
}, | ||
plugins: [ | ||
subscription(({ session }) => { | ||
const wsProtocol = apiUrl.protocol == 'https:' ? 'wss' : 'ws'; | ||
|
||
const wsClient = createWSClient({ | ||
url: `${wsProtocol}://${apiUrl.host}/graphql`, | ||
connectionParams() { | ||
if (!session?.token) { | ||
return {}; | ||
} | ||
|
||
return { | ||
Authorization: `Bearer ${session.token}`, | ||
}; | ||
}, | ||
}); | ||
|
||
return wsClient; | ||
}), | ||
], | ||
}); |
Oops, something went wrong.