Skip to content
Draft
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
8 changes: 8 additions & 0 deletions .chronus/changes/graphql-regen-auto-accessor-docs-2026-9-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@typespec/graphql"
---

Regenerate the decorator signatures to pick up the doc comments now emitted for auto decorator
accessors.
27 changes: 27 additions & 0 deletions .chronus/changes/json-schema-auto-decorators-2026-9-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
changeKind: deprecation
packages:
- "@typespec/json-schema"
---

The metadata-only decorators of this library are now declared as `auto dec`, so the compiler
synthesizes their implementation and provides typed accessors. This affects `@baseUri`, `@id`,
`@oneOf`, `@multipleOf`, `@contains`, `@minContains`, `@maxContains`, `@uniqueItems`,
`@minProperties`, `@maxProperties`, `@contentEncoding`, `@contentMediaType`, `@contentSchema` and
`@prefixItems`.

Nothing changes for TypeSpec authors. For JavaScript consumers, the `$baseUri`-style implementation
functions and their `BaseUriDecorator`-style signature types are deprecated: they are no longer what
the compiler invokes. Use the generated `set*` accessor to apply a decorator programmatically:

```ts
// Before
context.call($minContains, target, 2);

// After
import { setMinContains } from "@typespec/json-schema";
setMinContains(program, target, 2);
```

Applying one of these decorators twice on the same declaration now reports a `duplicate-decorator`
warning. The last application still wins.
15 changes: 15 additions & 0 deletions .chronus/changes/tspd-auto-accessor-docs-2026-9-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
changeKind: fix
packages:
- "@typespec/tspd"
---

Document the generated auto decorator accessors with the description of the decorator they read or
write, so libraries re-exporting them satisfy api-extractor's `ae-undocumented` rule.

```ts
/** Mark a model as a GraphQL input type in the emitted schema. */
export function isInputType(program: Program, target: Model): boolean {
return hasAutoDecorator(program, "TypeSpec.GraphQL.inputType", target);
}
```
9 changes: 9 additions & 0 deletions .chronus/changes/tspd-honor-library-config-2026-9-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
changeKind: fix
packages:
- "@typespec/tspd"
---

Honor the library's own `tspconfig.yaml` when generating signatures and reference documentation, so
libraries that opt into a compiler feature (such as `auto-decorators`) no longer report errors during
`gen-extern-signature` and `doc`.
52 changes: 52 additions & 0 deletions packages/graphql/generated-defs/TypeSpec.GraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,40 +184,92 @@ export type TypeSpecGraphQLDecorators = {
specifiedBy: SpecifiedByDecorator;
};

/**
* Mark a model as a GraphQL input type in the emitted schema.
*
* This decorator is applied automatically by the mutation engine when it produces
* a model that is used in input position. The emitter uses this to emit the model
* as an `input` type rather than an object `type`.
*/
export function isInputType(program: Program, target: Model): boolean {
return hasAutoDecorator(program, "TypeSpec.GraphQL.inputType", target);
}

/**
* Mark a model as a GraphQL input type in the emitted schema.
*
* This decorator is applied automatically by the mutation engine when it produces
* a model that is used in input position. The emitter uses this to emit the model
* as an `input` type rather than an object `type`.
*/
export function setInputType(program: Program, target: Model): void {
setAutoDecorator(program, "TypeSpec.GraphQL.inputType", target);
}

/**
* Mark a field, operation, or type as nullable in the emitted GraphQL schema.
*
* Applied automatically by the mutation engine when it strips `| null` from
* union types, and can also be applied directly in TypeSpec source.
*/
export function isNullable(
program: Program,
target: ModelProperty | Operation | Union | Model,
): boolean {
return hasAutoDecorator(program, "TypeSpec.GraphQL.nullable", target);
}

/**
* Mark a field, operation, or type as nullable in the emitted GraphQL schema.
*
* Applied automatically by the mutation engine when it strips `| null` from
* union types, and can also be applied directly in TypeSpec source.
*/
export function setNullable(
program: Program,
target: ModelProperty | Operation | Union | Model,
): void {
setAutoDecorator(program, "TypeSpec.GraphQL.nullable", target);
}

/**
* Mark a field or operation as having nullable array elements in the emitted GraphQL schema.
*
* Applied automatically by the mutation engine when it detects `Array<T | null>`
* patterns. Causes the emitter to emit `[T]` instead of `[T!]`.
*/
export function isNullableElements(program: Program, target: ModelProperty | Operation): boolean {
return hasAutoDecorator(program, "TypeSpec.GraphQL.nullableElements", target);
}

/**
* Mark a field or operation as having nullable array elements in the emitted GraphQL schema.
*
* Applied automatically by the mutation engine when it detects `Array<T | null>`
* patterns. Causes the emitter to emit `[T]` instead of `[T!]`.
*/
export function setNullableElements(program: Program, target: ModelProperty | Operation): void {
setAutoDecorator(program, "TypeSpec.GraphQL.nullableElements", target);
}

/**
* Mark a model as a `@oneOf` input object in the emitted GraphQL schema.
*
* This decorator is applied automatically by the mutation engine when it converts
* a union type in input context to a synthetic input object (since GraphQL unions
* are output-only). The emitter uses this to emit the `@oneOf` directive.
*/
export function isOneOf(program: Program, target: Model): boolean {
return hasAutoDecorator(program, "TypeSpec.GraphQL.oneOf", target);
}

/**
* Mark a model as a `@oneOf` input object in the emitted GraphQL schema.
*
* This decorator is applied automatically by the mutation engine when it converts
* a union type in input context to a synthetic input object (since GraphQL unions
* are output-only). The emitter uses this to emit the `@oneOf` directive.
*/
export function setOneOf(program: Program, target: Model): void {
setAutoDecorator(program, "TypeSpec.GraphQL.oneOf", target);
}
Loading
Loading