Skip to content

Commit 5161de0

Browse files
committed
feat(graphql): wire up model registration in schema emitter
1 parent edae2a2 commit 5161de0

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

packages/graphql/src/schema-emitter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
createDiagnosticCollector,
33
navigateTypesInNamespace,
4+
UsageFlags,
45
type Diagnostic,
56
type DiagnosticCollector,
67
type EmitContext,
@@ -57,13 +58,14 @@ class GraphQLSchemaEmitter {
5758
this.registry.addEnum(node);
5859
},
5960
model: (node: Model) => {
60-
// Add logic to handle the model node
61+
// TODO: Determine usageFlag from mutation engine or usage tracking
62+
this.registry.addModel(node, UsageFlags.Output);
6163
},
6264
exitEnum: (node: Enum) => {
6365
this.registry.materializeEnum(node.name);
6466
},
6567
exitModel: (node: Model) => {
66-
// Add logic to handle the exit of the model node
68+
this.registry.materializeModel(node.name);
6769
},
6870
};
6971
}

packages/graphql/test/emitter.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ import { strictEqual } from "node:assert";
22
import { describe, it } from "vitest";
33
import { emitSingleSchema } from "./test-host.js";
44

5-
// For now, the expected output is a placeholder string.
6-
// In the future, this should be replaced with the actual GraphQL schema output.
7-
const expectedGraphQLSchema = `type Query {
5+
const expectedGraphQLSchema = `type Book {
6+
name: String
7+
page_count: String
8+
published: String
9+
price: String
10+
}
11+
12+
type Author {
13+
name: String
14+
books: String
15+
}
16+
17+
type Query {
818
"""
919
A placeholder field. If you are seeing this, it means no operations were defined that could be emitted.
1020
"""

0 commit comments

Comments
 (0)