-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement autoCodeGen vite plugin option #1385
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 6625779 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for houdini-docs-next canceled.
|
✅ Deploy Preview for houdinigraphql canceled.
|
2e26c1e
to
d152a99
Compare
Okay, The first change in a file site the dev server was started still triggers a reload because we don't know the documents yet, but as the devserver stays up, subsequent changes to the same file only trigger a full-page reload when a graphql document changes! |
I removed my console.logs, but it looks like this: # the quiet option for watchAndRun seems to be removed from kitql-watch-and-run...
Watch-and-Run ✔ Watch change 100ms
# changeing code in a svelte file
codegen? /home/uwun/projects.local/churros/packages/app/src/routes/(app)/events/[id]/edit/managers/+page.svelte
{
absolutePath: '/home/uwun/projects.local/churros/packages/app/src/routes/(app)/events/[id]/edit/managers/+page.svelte',
documents: {
PageEventEditManager_ManagerUpdates: 'subscription PageEventEditManager_ManagerUpdates($event: LocalID!) {\n' +
' event(id: $event) {\n' +
' managers {\n' +
' user {\n' +
' uid\n' +
' }\n' +
' usedInvite {\n' +
' usesLeft\n' +
' unusable\n' +
' }\n' +
' ...PageEventEditManagers_ItemManager\n' +
' }\n' +
' }\n' +
' }',
AddEventManager: 'mutation AddEventManager($user: UID!, $event: LocalID!, $power: EventManagerPowerLevel!) {\n' +
' upsertEventManager(user: $user, event: $event, powerlevel: $power) {\n' +
' ... on MutationUpsertEventManagerSuccess {\n' +
' data {\n' +
' id\n' +
' ...List_EventManagers_insert\n' +
' }\n' +
' }\n' +
' ...MutationErrors\n' +
' }\n' +
' }',
CreateEventManagerInvite: 'mutation CreateEventManagerInvite(\n' +
' $event: LocalID!\n' +
' $power: EventManagerPowerLevel!\n' +
' $capacity: Capacity!\n' +
' $expiresAt: DateTime\n' +
' ) {\n' +
' upsertEventManagerInvite(\n' +
' event: $event\n' +
' input: { capacity: $capacity, expiresAt: $expiresAt, powerlevel: $power }\n' +
' ) {\n' +
' ... on MutationUpsertEventManagerInviteSuccess {\n' +
' data {\n' +
' id\n' +
' ...List_EventManagerInvites_insert @prepend\n' +
' }\n' +
' }\n' +
' ...MutationErrors\n' +
' }\n' +
' }'
}
}
Skipped codegen for /home/uwun/projects.local/churros/packages/app/src/routes/(app)/events/[id]/edit/managers/+page.svelte since graphql documents did not change
# changeing a mutation store definition in that same file
Watch-and-Run ✔ Watch change 100ms
codegen? /home/uwun/projects.local/churros/packages/app/src/routes/(app)/events/[id]/edit/managers/+page.svelte
{
absolutePath: '/home/uwun/projects.local/churros/packages/app/src/routes/(app)/events/[id]/edit/managers/+page.svelte',
documents: {
PageEventEditManager_ManagerUpdates: 'subscription PageEventEditManager_ManagerUpdates($event: LocalID!) {\n' +
' event(id: $event) {\n' +
' managers {\n' +
' user {\n' +
' uid\n' +
' }\n' +
' usedInvite {\n' +
' usesLeft\n' +
' unusable\n' +
' }\n' +
' ...PageEventEditManagers_ItemManager\n' +
' }\n' +
' }\n' +
' }',
AddEventManager: 'mutation AddEventManager($user: UID!, $event: LocalID!, $power: EventManagerPowerLevel!) {\n' +
' upsertEventManager(user: $user, event: $event, powerlevel: $power) {\n' +
' ... on MutationUpsertEventManagerSuccess {\n' +
' data {\n' +
' id\n' +
' localID\n' +
' ...List_EventManagers_insert\n' +
' }\n' +
' }\n' +
' ...MutationErrors\n' +
' }\n' +
' }',
CreateEventManagerInvite: 'mutation CreateEventManagerInvite(\n' +
' $event: LocalID!\n' +
' $power: EventManagerPowerLevel!\n' +
' $capacity: Capacity!\n' +
' $expiresAt: DateTime\n' +
' ) {\n' +
' upsertEventManagerInvite(\n' +
' event: $event\n' +
' input: { capacity: $capacity, expiresAt: $expiresAt, powerlevel: $power }\n' +
' ) {\n' +
' ... on MutationUpsertEventManagerInviteSuccess {\n' +
' data {\n' +
' id\n' +
' ...List_EventManagerInvites_insert @prepend\n' +
' }\n' +
' }\n' +
' ...MutationErrors\n' +
' }\n' +
' }'
}
}
Regenerating runtime because /home/uwun/projects.local/churros/packages/app/src/routes/(app)/events/[id]/edit/managers/+page.svelte changed |
15cbc95
to
2dda139
Compare
2dda139
to
ebd937b
Compare
d518d3a
to
01786e8
Compare
* @param source the source code | ||
* @returns an object mapping document names to their content | ||
*/ | ||
export function extractDocuments(source: string): Record<string, string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should rely on a shared function with the collectDocuments part of the codegen pipeline. Plugins can define their own logic for what it means to extract a document out of a file and we need to make sure we're picking them up.
] | ||
|
||
const codegen = async (_server: ViteDevServer | undefined, absolutePath: string | null) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to its own file?
} else if (fileContents) { | ||
const previousDocuments = extractedDocuments[absolutePath] | ||
if (!previousDocuments) { | ||
// To prevent full-page reloads every time we change something in a new document, just don't reload. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be confusing - if the file changes, we should generate. Waiting til a second update will feel clunky if someone is putting a quick demo together where they are copying and pasting entire file contents
To help everyone out, please make sure your PR does the following:
pnpm run tests
andcd integration && pnpm run tests
pnpm changeset