Skip to content

Add TypeSpec representation for the facets pattern#587

Open
J-Mumo wants to merge 4 commits into
microsoft:vNextfrom
J-Mumo:graph-facets-typespec-example
Open

Add TypeSpec representation for the facets pattern#587
J-Mumo wants to merge 4 commits into
microsoft:vNextfrom
J-Mumo:graph-facets-typespec-example

Conversation

@J-Mumo

@J-Mumo J-Mumo commented Jun 22, 2026

Copy link
Copy Markdown

Summary

Adds the TypeSpec representation of the facets API design pattern, completing the documentation deliverable (Phase 6) of microsoftgraph/typespec-msgraph#1061. The @facet decorator has shipped in @microsoft/typespec-msgraph v1.1.0; this PR documents how to author the pattern.

Changes

  • graph/patterns/facets.md — new Facets in TypeSpec section that models the existing driveItem CSDL example in TypeSpec (audio/file/folder/image/video as @facet nullable @complex properties), lists the linter rules, and shows the compiled CSDL.
  • graph/GuidelinesGraph.md — adds a TypeSpec representation column to the modeling-variants comparison table and a pointer to the new section.

Note on CSDL output

@facet is an authoring/lint-only marker: it emits no CSDL annotation, so a facet property compiles to a standard nullable complex-typed <Property> — identical to a hand-authored facet. This was verified by compiling the example with the TypeSpec compiler (v1.9.0) + @microsoft/typespec-msgraph.

🤖 AI-assisted authoring (GitHub Copilot).

Mary Njenga and others added 2 commits June 8, 2026 16:28
Documents how the facets API design pattern is authored in TypeSpec using
the @facet decorator from @microsoft/typespec-msgraph (issue
microsoftgraph/typespec-msgraph#1061, Phase 6):

- facets.md: new "Facets in TypeSpec" section with a driveItem example
  (audio/file/folder/image/video as @facet nullable @complex properties),
  the linter rules, and the compiled CSDL (a standard nullable complex
  property -- @facet is authoring/lint-only and emits no CSDL annotation).
- GuidelinesGraph.md: add a "TypeSpec representation" column to the
  modeling-variants comparison table and a pointer to the new section.
@J-Mumo J-Mumo requested a review from a team as a code owner June 22, 2026 16:47
- Type hierarchy: @abstract + extends
- Flat bag: @flatBag + @variant
- Facets: left blank pending separate work

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Merges marynjenga/graph-patterns (PR microsoft#588) into the facets branch and
resolves the GuidelinesGraph.md conflict where both branches rewrote the
modeling-variants comparison table.

Reconciled the shared 'TypeSpec representation' column so all three rows are
correct against @microsoft/typespec-msgraph v1.1.0 (verified by compiling
canaries):
- Type hierarchy -> `@abstract` + `extends`
- Facets         -> `@facet` on a nullable `@complex` property
- Flat bag       -> `@flatBag` + `@variant`

The prior facets-branch cell ('plain entity properties (no dedicated
decorator)') was incorrect -- @flatBag/@variant ship in v1.1.0 -- and Mary's
'Facets = —' cell was incomplete since @facet ships as well. The merged table
captures both decorator sets.
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