Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/hungry-monkeys-shine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphprotocol/hypergraph": patch
---

fixes loading the initial schema in typesync

19 changes: 12 additions & 7 deletions packages/hypergraph/src/cli/services/Typesync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,18 @@ export class TypesyncSchemaStreamBuilder extends Effect.Service<TypesyncSchemaSt
yield* kv.set(MAPPING_FILE_PATH_STORAGE_KEY, mappingFilePath.value);
}

return currentSchemaStream(schemaFilePath, mappingFilePath).pipe(
Stream.concat(watchSchemaStream(schemaFilePath, mappingFilePath)),
Stream.map((stream) => {
const jsonData = JSON.stringify(stream);
const sseData = `data: ${jsonData}\n\n`;
return encoder.encode(sseData);
}),
return Stream.concat(
// This is a workaround because the browser doesn't send a message until the second message is sent.
// We are sending an empty message, because then the actual first message will be the real second message and the browsers receives it.
Stream.succeed(encoder.encode('data: {"types":[]}\n\n')),
currentSchemaStream(schemaFilePath, mappingFilePath).pipe(
Stream.concat(watchSchemaStream(schemaFilePath, mappingFilePath)),
Stream.map((stream) => {
const jsonData = JSON.stringify(stream);
const sseData = `data: ${jsonData}\n\n`;
return encoder.encode(sseData);
}),
),
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded empty message should be extracted to a constant or generated using the same logic as the actual messages to maintain consistency and avoid magic strings.

Copilot uses AI. Check for mistakes.

);
});

Expand Down
Loading