make graphql typing for getDescription conform with graphql-js

This commit is contained in:
Divyendu Singh
2018-03-09 13:45:28 +05:30
parent fe94393d6a
commit c96aea88fe
3 changed files with 16 additions and 3 deletions

View File

@@ -12,6 +12,7 @@
// Tim Griesser <https://github.com/tgriesser>
// Dylan Stewart <https://github.com/dyst5422>
// Alessio Dionisi <https://github.com/adnsio>
// Divyendu Singh <https://github.com/divyenduz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -100,6 +101,9 @@ export {
// Build a GraphQLSchema from a GraphQL schema language document.
buildSchema,
// Get the description of an AST node
getDescription,
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
// language AST.
extendSchema,

View File

@@ -1,7 +1,13 @@
import { DocumentNode, Location } from '../language/ast';
import { DocumentNode, Location, StringValueNode } from '../language/ast';
import { Source } from '../language/source';
import { GraphQLSchema } from '../type/schema';
type BuildSchemaOptions = {
assumeValid?: boolean;
allowedLegacyNames?: ReadonlyArray<string>;
commentDescriptions?: boolean;
};
/**
* This takes the ast of a schema document produced by the parse function in
* src/language/parser.js.
@@ -18,7 +24,10 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema;
* Given an ast node, returns its string description based on a contiguous
* block full-line of comments preceding it.
*/
export function getDescription(node: { loc?: Location }): string;
export function getDescription(
node: { description?: StringValueNode; loc?: Location },
options: BuildSchemaOptions
): string;
/**
* A helper function to build a GraphQLSchema directly from a source

View File

@@ -27,7 +27,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';