Skip to content

Commit 3b30a64

Browse files
authored
docs: fix inline examples, deprecation descriptions, type category (#4757)
- Move public documentation sample blocks out of descriptions and into `@example` tags, including root package, parser option, type, schema, astFromValue, and stripIgnoredCharacters docs. - Update every public v16 `@deprecated` JSDoc block so the prose itself says the API is deprecated and points users to the replacement or migration path. - Rename the graphql/type Definitions JSDoc category to Types so the generated API docs use the clearer category name.
1 parent 8816d01 commit 3b30a64

18 files changed

Lines changed: 106 additions & 111 deletions

src/error/GraphQLError.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export class GraphQLError extends Error {
136136
* Creates a GraphQLError instance.
137137
* @param message - Human-readable error message.
138138
* @param options - Error metadata such as source locations, response path, original error, and extensions.
139+
* This positional-arguments constructor overload is deprecated. Use the
140+
* `GraphQLError(message, options)` overload instead.
139141
* @example
140142
* ```ts
141143
* // Create an error from AST nodes and response metadata.
@@ -178,8 +180,9 @@ export class GraphQLError extends Error {
178180
constructor(message: string, options?: GraphQLErrorOptions);
179181
/**
180182
* Creates a GraphQLError instance using the legacy positional constructor.
181-
* Prefer the `GraphQLErrorOptions` object overload, which keeps optional error
182-
* metadata in a single options bag.
183+
* This deprecated overload will be removed in v17. Prefer the
184+
* `GraphQLErrorOptions` object overload, which keeps optional error metadata
185+
* in a single options bag.
183186
* @param message - Human-readable error message.
184187
* @param nodes - AST node or nodes associated with this error.
185188
* @param source - Source document used to derive error locations.
@@ -409,9 +412,9 @@ export interface GraphQLFormattedError {
409412

410413
/**
411414
* Prints a GraphQLError to a string, representing useful location information
412-
* about the error's position in the source. This helper is retained for
413-
* backwards compatibility; call `error.toString()` instead because printError
414-
* will be removed in v17.
415+
* about the error's position in the source. This deprecated helper is retained
416+
* for backwards compatibility; call `error.toString()` instead because
417+
* printError will be removed in v17.
415418
* @param error - The error to format.
416419
* @returns The printed string representation.
417420
* @example
@@ -430,9 +433,9 @@ export function printError(error: GraphQLError): string {
430433

431434
/**
432435
* Given a GraphQLError, format it according to the rules described by the
433-
* Response Format, Errors section of the GraphQL Specification. This helper is
434-
* retained for backwards compatibility; call `error.toJSON()` instead because
435-
* formatError will be removed in v17.
436+
* Response Format, Errors section of the GraphQL Specification. This deprecated
437+
* helper is retained for backwards compatibility; call `error.toJSON()`
438+
* instead because formatError will be removed in v17.
436439
* @param error - The error to format.
437440
* @returns The JSON-serializable formatted error.
438441
* @example

src/execution/execute.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ function buildResponse(
481481

482482
/**
483483
* Essential assertions before executing to provide developer feedback for
484-
* improper use of the GraphQL library.
484+
* improper use of the GraphQL library. This deprecated internal helper will be
485+
* removed in v17; call `assertValidSchema()` and rely on TypeScript checks
486+
* instead.
485487
*
486488
* @deprecated will be removed in v17 in favor of assertValidSchema() and TS checks
487489
* @internal

src/execution/subscribe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ export async function createSourceEventStream(
284284
): Promise<AsyncIterable<unknown> | ExecutionResult>;
285285
/**
286286
* Creates the source event stream for a subscription operation using the legacy
287-
* positional argument overload. Use the args object overload instead; this
288-
* overload will be removed in the next major version.
287+
* positional argument overload. This deprecated overload will be removed in the
288+
* next major version; use the args object overload instead.
289289
* @param schema - GraphQL schema to use.
290290
* @param document - The parsed GraphQL document containing the subscription
291291
* operation.

src/language/ast.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,11 @@ export interface FragmentDefinitionNode {
552552
/** Name node identifying this AST node. */
553553
readonly name: NameNode;
554554
/**
555-
* Variable definitions declared by this legacy fragment definition.
555+
* Deprecated variable definitions declared by this legacy fragment
556+
* definition. This legacy fragment variable syntax will be removed in v17.
557+
* Move variable definitions to operations for spec-compliant documents; if
558+
* you need variables or arguments scoped to fragments, v17 has a more
559+
* complete experimental fragment-arguments feature.
556560
* @deprecated variableDefinitions will be removed in v17.0.0
557561
*/
558562
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;

src/language/directiveLocation.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ enum DirectiveLocation {
4646
export { DirectiveLocation };
4747

4848
/**
49-
* Legacy alias for the enum type representing directive location values. This
50-
* is retained for backwards compatibility; use `DirectiveLocation` instead
51-
* because DirectiveLocationEnum will be removed in v17.
52-
* @deprecated Please use `DirectiveLocation`. Will be removed in v17.
49+
* Deprecated legacy alias for the enum type representing directive location
50+
* values. This alias will be removed in v17. In v17, `DirectiveLocation` is
51+
* exported as the single public symbol for both the runtime object and the
52+
* corresponding TypeScript type.
53+
* @deprecated Will be removed in v17. In v17, use `DirectiveLocation` as both
54+
* the runtime value and the type.
5355
*/
5456
export type DirectiveLocationEnum = typeof DirectiveLocation;

src/language/kinds.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ enum Kind {
115115
export { Kind };
116116

117117
/**
118-
* Legacy alias for the enum type representing the possible kind values of AST
119-
* nodes. This is retained for backwards compatibility; use `Kind` instead
120-
* because KindEnum will be removed in v17.
121-
* @deprecated Please use `Kind`. Will be removed in v17.
118+
* Deprecated legacy alias for the enum type representing the possible kind
119+
* values of AST nodes. This alias will be removed in v17. In v17, `Kind` is
120+
* exported as the single public symbol for both the runtime object and the
121+
* corresponding TypeScript type.
122+
* @deprecated Will be removed in v17. In v17, use `Kind` as both the runtime
123+
* value and the type.
122124
*/
123125
export type KindEnum = typeof Kind;

src/language/parser.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,24 @@ export interface ParseOptions {
9797
maxTokens?: number | undefined;
9898

9999
/**
100-
* Allows legacy fragment variable definitions to be parsed.
101-
* @deprecated will be removed in the v17.0.0
102-
*
103-
* If enabled, the parser will understand and parse variable definitions
104-
* contained in a fragment definition. They'll be represented in the
105-
* `variableDefinitions` field of the FragmentDefinitionNode.
106-
*
107-
* The syntax is identical to normal, query-defined variables. For example:
100+
* Deprecated option that allows legacy fragment variable definitions to be
101+
* parsed. This legacy fragment variable syntax will be removed in v17. Move
102+
* variable definitions to operations for spec-compliant documents; if you
103+
* need variables or arguments scoped to fragments, v17 has a more complete
104+
* experimental fragment-arguments feature.
105+
* @example
106+
* The syntax is identical to normal, query-defined variables.
108107
*
109108
* ```graphql
110109
* fragment A($var: Boolean = false) on T {
111110
* ...
112111
* }
113112
* ```
113+
* @deprecated will be removed in the v17.0.0
114+
*
115+
* If enabled, the parser will understand and parse variable definitions
116+
* contained in a fragment definition. They'll be represented in the
117+
* `variableDefinitions` field of the FragmentDefinitionNode.
114118
*/
115119
allowLegacyFragmentVariables?: boolean;
116120

@@ -119,7 +123,7 @@ export interface ParseOptions {
119123
*
120124
* If enabled, the parser will parse directives on directive definitions.
121125
* This syntax is not part of the GraphQL specification and may change.
122-
*
126+
* @example
123127
* ```graphql
124128
* directive @foo @bar on FIELD
125129
* ```

src/language/tokenKind.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ enum TokenKind {
5555
export { TokenKind };
5656

5757
/**
58-
* Legacy alias for the enum type representing token kind values. This is
59-
* retained for backwards compatibility; use `TokenKind` instead because
60-
* TokenKindEnum will be removed in v17.
61-
* @deprecated Please use `TokenKind`. Will be removed in v17.
58+
* Deprecated legacy alias for the enum type representing token kind values.
59+
* This alias will be removed in v17. In v17, `TokenKind` is exported as the
60+
* single public symbol for both the runtime object and the corresponding
61+
* TypeScript type.
62+
* @deprecated Will be removed in v17. In v17, use `TokenKind` as both the
63+
* runtime value and the type.
6264
*/
6365
export type TokenKindEnum = typeof TokenKind;

src/language/visitor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ type ReducedField<T, R> = T extends null | undefined
9191
: R;
9292

9393
/**
94-
* Legacy visitor key map type retained for compatibility. Inline this mapped
95-
* type at use sites; ASTVisitorKeyMap will be removed in v17.
94+
* Deprecated visitor key map type retained for compatibility. Inline this
95+
* mapped type at use sites because ASTVisitorKeyMap will be removed in v17.
9696
* @deprecated Please inline it. Will be removed in v17
9797
*/
9898
export type ASTVisitorKeyMap = {
@@ -508,9 +508,9 @@ export function getEnterLeaveForKind(
508508

509509
/**
510510
* Given a visitor instance, if it is leaving or not, and a node kind, return
511-
* the function the visitor runtime should call. This compatibility helper
512-
* delegates to `getEnterLeaveForKind`; call `getEnterLeaveForKind` directly
513-
* because getVisitFn will be removed in v17.
511+
* the function the visitor runtime should call. This deprecated compatibility
512+
* helper delegates to `getEnterLeaveForKind`; call `getEnterLeaveForKind`
513+
* directly because getVisitFn will be removed in v17.
514514
* @param visitor - The visitor object to inspect.
515515
* @param kind - The AST node kind to resolve a handler for.
516516
* @param isLeaving - Whether to resolve the leave handler instead of the enter handler.

src/subscription/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import type { ExecutionArgs } from '../execution/execute';
1616

1717
/**
18-
* Legacy alias for ExecutionArgs retained by the subscription module. Use
19-
* `ExecutionArgs` directly instead because SubscriptionArgs will be removed in
20-
* v17.
18+
* Deprecated legacy alias for ExecutionArgs retained by the subscription
19+
* module. Use `ExecutionArgs` directly instead because SubscriptionArgs will be
20+
* removed in v17.
2121
*
2222
* ExecutionArgs has been broadened to include all properties within SubscriptionArgs.
2323
* The SubscriptionArgs type is retained for backwards compatibility.

0 commit comments

Comments
 (0)