Skip to content

Commit 74da857

Browse files
author
Enda Phelan
committed
style(JSDoc): document private functions with @internal tag
Closes #2183
1 parent 21de98e commit 74da857

16 files changed

+84
-6
lines changed

src/__tests__/starWarsData.js

+8
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ function getCharacter(id) {
122122

123123
/**
124124
* Allows us to query for a character's friends.
125+
*
126+
* @internal
125127
*/
126128
export function getFriends(character: Character): Array<Promise<Character>> {
127129
// Notice that GraphQL accepts Arrays of Promises.
@@ -130,6 +132,8 @@ export function getFriends(character: Character): Array<Promise<Character>> {
130132

131133
/**
132134
* Allows us to fetch the undisputed hero of the Star Wars trilogy, R2-D2.
135+
*
136+
* @internal
133137
*/
134138
export function getHero(episode: number): Character {
135139
if (episode === 5) {
@@ -142,13 +146,17 @@ export function getHero(episode: number): Character {
142146

143147
/**
144148
* Allows us to query for the human with the given id.
149+
*
150+
* @internal
145151
*/
146152
export function getHuman(id: string): Human {
147153
return humanData[id];
148154
}
149155

150156
/**
151157
* Allows us to query for the droid with the given id.
158+
*
159+
* @internal
152160
*/
153161
export function getDroid(id: string): Droid {
154162
return droidData[id];

src/execution/execute.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ function buildResponse(
244244
/**
245245
* Essential assertions before executing to provide developer feedback for
246246
* improper use of the GraphQL library.
247+
*
248+
* @internal
247249
*/
248250
export function assertValidExecutionArguments(
249251
schema: GraphQLSchema,
@@ -267,6 +269,8 @@ export function assertValidExecutionArguments(
267269
* execute, which we will pass throughout the other execution methods.
268270
*
269271
* Throws a GraphQLError if a valid execution context cannot be created.
272+
*
273+
* @internal
270274
*/
271275
export function buildExecutionContext(
272276
schema: GraphQLSchema,
@@ -465,6 +469,8 @@ function executeFields(
465469
* CollectFields requires the "runtime type" of an object. For a field which
466470
* returns an Interface or Union type, the "runtime type" will be the actual
467471
* Object type returned by that field.
472+
*
473+
* @internal
468474
*/
469475
export function collectFields(
470476
exeContext: ExecutionContext,
@@ -641,6 +647,9 @@ function resolveField(
641647
);
642648
}
643649

650+
/**
651+
* @internal
652+
*/
644653
export function buildResolveInfo(
645654
exeContext: ExecutionContext,
646655
fieldDef: GraphQLField<mixed, mixed>,
@@ -664,8 +673,12 @@ export function buildResolveInfo(
664673
};
665674
}
666675

667-
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
668-
// function. Returns the result of resolveFn or the abrupt-return Error object.
676+
/**
677+
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
678+
* function. Returns the result of resolveFn or the abrupt-return Error object.
679+
*
680+
* @internal
681+
*/
669682
export function resolveFieldValueOrError(
670683
exeContext: ExecutionContext,
671684
fieldDef: GraphQLField<mixed, mixed>,
@@ -1192,6 +1205,8 @@ export const defaultFieldResolver: GraphQLFieldResolver<
11921205
* are allowed, like on a Union. __schema could get automatically
11931206
* added to the query type, but that would require mutating type
11941207
* definitions, which would cause issues.
1208+
*
1209+
* @internal
11951210
*/
11961211
export function getFieldDef(
11971212
schema: GraphQLSchema,

src/execution/values.js

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type CoercedVariableValues =
4141
* Note: The returned value is a plain Object with a prototype, since it is
4242
* exposed to user code. Care should be taken to not pull values from the
4343
* Object prototype.
44+
*
45+
* @internal
4446
*/
4547
export function getVariableValues(
4648
schema: GraphQLSchema,
@@ -153,6 +155,8 @@ function coerceVariableValues(
153155
* Note: The returned value is a plain Object with a prototype, since it is
154156
* exposed to user code. Care should be taken to not pull values from the
155157
* Object prototype.
158+
*
159+
* @internal
156160
*/
157161
export function getArgumentValues(
158162
def: GraphQLField<mixed, mixed> | GraphQLDirective,

src/jsutils/Path.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export type Path = {|
77

88
/**
99
* Given a Path and a key, return a new Path containing the new key.
10+
*
11+
* @internal
1012
*/
1113
export function addPath(prev: $ReadOnly<Path> | void, key: string | number) {
1214
return { prev, key };

src/language/__tests__/parser-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { kitchenSinkQuery } from '../../__fixtures__';
66

77
export const name = 'Parse kitchen sink';
88
export const count = 1000;
9+
10+
/**
11+
* @internal
12+
*/
913
export function measure() {
1014
parse(kitchenSinkQuery);
1115
}

src/language/blockString.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
66
*
77
* This implements the GraphQL spec's BlockStringValue() static algorithm.
8+
*
9+
* @internal
810
*/
911
export function dedentBlockStringValue(rawString: string): string {
1012
// Expand a block string's raw value into independent lines.
@@ -30,8 +32,9 @@ export function dedentBlockStringValue(rawString: string): string {
3032
// Return a string of the lines joined with U+000A.
3133
return lines.join('\n');
3234
}
33-
34-
// @internal
35+
/**
36+
* @internal
37+
*/
3538
export function getBlockStringIndentation(
3639
lines: $ReadOnlyArray<string>,
3740
): number {
@@ -71,6 +74,8 @@ function isBlank(str) {
7174
* Print a block string in the indented block form by adding a leading and
7275
* trailing blank line. However, if a block string starts with whitespace and is
7376
* a single-line, adding a leading blank line would strip that whitespace.
77+
*
78+
* @internal
7479
*/
7580
export function printBlockString(
7681
value: string,

src/language/lexer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ export type Lexer<TOptions> = {
9393
...
9494
};
9595

96-
// @internal
96+
/**
97+
* @internal
98+
*/
9799
export function isPunctuatorTokenKind(kind: TokenKindEnum) {
98100
return (
99101
kind === TokenKind.BANG ||

src/type/definition.js

+3
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,9 @@ function fieldsToFieldsConfig(fields) {
822822
}));
823823
}
824824

825+
/**
826+
* @internal
827+
*/
825828
export function argsToArgsConfig(
826829
args: $ReadOnlyArray<GraphQLArgument>,
827830
): GraphQLFieldConfigArgumentMap {

src/utilities/__tests__/buildASTSchema-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const schemaAST = parse(bigSchemaSDL);
1010

1111
export const name = 'Build Schema from AST';
1212
export const count = 10;
13+
14+
/**
15+
* @internal
16+
*/
1317
export function measure() {
1418
buildASTSchema(schemaAST, { assumeValid: true });
1519
}

src/utilities/__tests__/buildClientSchema-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { bigSchemaIntrospectionResult } from '../../__fixtures__';
66

77
export const name = 'Build Schema from Introspection';
88
export const count = 10;
9+
10+
/**
11+
* @internal
12+
*/
913
export function measure() {
1014
buildClientSchema(bigSchemaIntrospectionResult.data, { assumeValid: true });
1115
}

src/utilities/__tests__/introspectionFromSchema-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const schema = buildSchema(bigSchemaSDL, { assumeValid: true });
1313

1414
export const name = 'Execute Introspection Query';
1515
export const count = 10;
16+
17+
/**
18+
* @internal
19+
*/
1620
export function measure() {
1721
execute(schema, queryAST);
1822
}

src/validation/__tests__/harness.js

+9
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ export const testSchema = new GraphQLSchema({
370370
],
371371
});
372372

373+
/**
374+
* @internal
375+
*/
373376
export function expectValidationErrorsWithSchema(
374377
schema: GraphQLSchema,
375378
rule: ValidationRule,
@@ -380,10 +383,16 @@ export function expectValidationErrorsWithSchema(
380383
return expect(errors);
381384
}
382385

386+
/**
387+
* @internal
388+
*/
383389
export function expectValidationErrors(rule: ValidationRule, queryStr: string) {
384390
return expectValidationErrorsWithSchema(testSchema, rule, queryStr);
385391
}
386392

393+
/**
394+
* @internal
395+
*/
387396
export function expectSDLValidationErrors(
388397
schema: ?GraphQLSchema,
389398
rule: SDLValidationRule,

src/validation/__tests__/validateGQL-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const queryAST = parse(getIntrospectionQuery());
1313

1414
export const name = 'Validate Introspection Query';
1515
export const count = 50;
16+
17+
/**
18+
* @internal
19+
*/
1620
export function measure() {
1721
validate(schema, queryAST);
1822
}

src/validation/__tests__/validateInvalidGQL-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const queryAST = parse(`
2424

2525
export const name = 'Validate Invalid Query';
2626
export const count = 50;
27+
28+
/**
29+
* @internal
30+
*/
2731
export function measure() {
2832
validate(schema, queryAST);
2933
}

src/validation/__tests__/validateSDL-benchmark.js

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const sdlAST = parse(bigSchemaSDL);
1010

1111
export const name = 'Validate SDL Document';
1212
export const count = 10;
13+
14+
/**
15+
* @internal
16+
*/
1317
export function measure() {
1418
validateSDL(sdlAST);
1519
}

src/validation/validate.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ export function validate(
8282
return errors;
8383
}
8484

85-
// @internal
85+
/**
86+
* @internal
87+
*/
8688
export function validateSDL(
8789
documentAST: DocumentNode,
8890
schemaToExtend?: ?GraphQLSchema,

0 commit comments

Comments
 (0)