Skip to content

Commit

Permalink
On schema change, revalidate all documents (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycouet authored Jan 31, 2023
1 parent 34f2dc3 commit 3872a56
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-llamas-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

on schema change, revalidate all document. No need to restart vite to pick up changes.
19 changes: 11 additions & 8 deletions packages/houdini/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,17 +744,20 @@ let pendingConfigPromise: Promise<Config> | null = null
export async function getConfig({
configPath = DEFAULT_CONFIG_PATH,
noSchema,
forceReload,
...extraConfig
}: PluginConfig & { noSchema?: boolean } = {}): Promise<Config> {
if (_config) {
return _config
}
}: PluginConfig & { noSchema?: boolean; forceReload?: boolean } = {}): Promise<Config> {
// if we force a reload, we will bypass this part
if (!forceReload) {
if (_config) {
return _config
}

// if we have a pending promise, return the result of that
if (pendingConfigPromise) {
return await pendingConfigPromise
// if we have a pending promise, return the result of that
if (pendingConfigPromise) {
return await pendingConfigPromise
}
}

// there isn't a pending config so let's make one to claim
let resolve: (cfg: Config | PromiseLike<Config>) => void = () => {}
let reject = (message?: any) => {}
Expand Down
4 changes: 3 additions & 1 deletion packages/houdini/src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export default function (opts?: PluginConfig): Plugin[] {
quiet: true,
async watchFile(filepath: string) {
// load the config file
const config = await getConfig(opts)
let config = await getConfig(opts)

// we need to watch some specific files
const schemaPath = path.join(path.dirname(config.filepath), config.schemaPath!)
if (minimatch(filepath, schemaPath)) {
// if it's a schema change, let's reload the config
config = await getConfig({ ...opts, forceReload: true })
return true
}

Expand Down

0 comments on commit 3872a56

Please sign in to comment.