Skip to content

Conversation

@FionaBronwen
Copy link

@FionaBronwen FionaBronwen commented Jan 5, 2026

Summary

Introduces ModelTypeMap for converting TypeSpec Models to GraphQL types, integrates it with the registry, and wires up the schema emitter to register and materialize models.

Changes

ModelTypeMap (src/type-maps/model.ts):

  • Extends TypeMap<Model, GraphQLObjectType | GraphQLInputObjectType>
  • Creates GraphQLObjectType for output types, GraphQLInputObjectType for input types during model materialization
  • Uses usageFlag in TSPContext to determine which type to create
  • Placeholder mapPropertyType() for future type resolution

Registry (src/registry.ts):

  • Added modelTypeMap alongside enumTypeMap
  • addModel(model, usageFlag) - registers a model with usage context
  • materializeModel(name) - lazily materializes to GraphQL type
  • materializeSchemaConfig() now includes models in output

Schema emitter (src/schema-emitter.ts):

  • model handler calls registry.addModel()
  • exitModel handler calls registry.materializeModel()
  • Models now appear in emitted GraphQL schema

Example output

type Book {
  name: String
  page_count: String
  published: String
  price: String
}

type Author {
  name: String
  books: String
}

Note: All fields map to String as placeholder - full model property type mapping is TODO.

@FionaBronwen FionaBronwen force-pushed the fionabronwen/enum-typemap branch from 54b3fd9 to e842ba5 Compare January 7, 2026 20:05
@FionaBronwen FionaBronwen force-pushed the fionabronwen/model-typemap branch from ca5538e to cee34c5 Compare January 7, 2026 20:05
@FionaBronwen FionaBronwen force-pushed the fionabronwen/enum-typemap branch from e842ba5 to 2400d78 Compare January 7, 2026 20:42
@FionaBronwen FionaBronwen force-pushed the fionabronwen/model-typemap branch from cee34c5 to f7a355e Compare January 7, 2026 20:43
@FionaBronwen FionaBronwen force-pushed the fionabronwen/enum-typemap branch from 2400d78 to 964a436 Compare January 7, 2026 21:15
@FionaBronwen FionaBronwen force-pushed the fionabronwen/model-typemap branch from f7a355e to fc918d4 Compare January 7, 2026 21:15
@FionaBronwen FionaBronwen force-pushed the fionabronwen/enum-typemap branch 2 times, most recently from a0c840c to f410002 Compare January 8, 2026 15:24
@FionaBronwen FionaBronwen force-pushed the fionabronwen/model-typemap branch from fc918d4 to 5161de0 Compare January 8, 2026 16:05
@FionaBronwen FionaBronwen marked this pull request as ready for review January 8, 2026 16:31
@FionaBronwen FionaBronwen removed the request for review from swatkatz January 8, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants