Skip to content

Commit 8173c24

Browse files
Sashko Stubailoleebyron
Sashko Stubailo
authored andcommitted
Bring back getDescription export (#1165)
We were using this in graphql-tools with [email protected], would be nice to get it exported again! Update buildASTSchema.js Fix formatting Add types for getDescription Export getDescription from the root
1 parent 63a9488 commit 8173c24

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ export {
315315
buildASTSchema,
316316
// Build a GraphQLSchema from a GraphQL schema language document.
317317
buildSchema,
318+
// Get the description from a schema AST node.
319+
getDescription,
318320
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
319321
// language AST.
320322
extendSchema,

src/utilities/buildASTSchema.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import type {
3535
EnumValueDefinitionNode,
3636
InputObjectTypeDefinitionNode,
3737
DirectiveDefinitionNode,
38+
StringValueNode,
39+
Location,
3840
} from '../language/ast';
3941

4042
import type { DirectiveLocationEnum } from '../language/directiveLocation';
@@ -475,7 +477,10 @@ function getDeprecationReason(
475477
* Provide true to use preceding comments as the description.
476478
*
477479
*/
478-
function getDescription(node, options: ?Options): void | string {
480+
export function getDescription(
481+
node: { +description?: StringValueNode, +loc?: Location },
482+
options: ?Options,
483+
): void | string {
479484
if (node.description) {
480485
return node.description.value;
481486
}

src/utilities/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export { getOperationAST } from './getOperationAST';
4545
export { buildClientSchema } from './buildClientSchema';
4646

4747
// Build a GraphQLSchema from GraphQL Schema language.
48-
export { buildASTSchema, buildSchema } from './buildASTSchema';
48+
export { buildASTSchema, buildSchema, getDescription } from './buildASTSchema';
4949

5050
// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.
5151
export { extendSchema } from './extendSchema';

0 commit comments

Comments
 (0)