Skip to content

Commit

Permalink
Bring back getDescription export
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sashko Stubailo committed Dec 19, 2017
1 parent 81a88eb commit 0eba510
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ export {
buildASTSchema,
// Build a GraphQLSchema from a GraphQL schema language document.
buildSchema,
// Get the description from a schema AST node.
getDescription,
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
// language AST.
extendSchema,
Expand Down
7 changes: 6 additions & 1 deletion src/utilities/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import type {
EnumValueDefinitionNode,
InputObjectTypeDefinitionNode,
DirectiveDefinitionNode,
StringValueNode,
Location,
} from '../language/ast';

import type { DirectiveLocationEnum } from '../language/directiveLocation';
Expand Down Expand Up @@ -475,7 +477,10 @@ function getDeprecationReason(
* Provide true to use preceding comments as the description.
*
*/
function getDescription(node, options: ?Options): void | string {
export function getDescription(
node: { +description?: StringValueNode, +loc?: Location },
options: ?Options,
): void | string {
if (node.description) {
return node.description.value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export { getOperationAST } from './getOperationAST';
export { buildClientSchema } from './buildClientSchema';

// Build a GraphQLSchema from GraphQL Schema language.
export { buildASTSchema, buildSchema } from './buildASTSchema';
export { buildASTSchema, buildSchema, getDescription } from './buildASTSchema';

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

0 comments on commit 0eba510

Please sign in to comment.