mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-17 12:16:38 +08:00
Merge pull request #24169 from divyenduz/fix_graphql_typing_for_getDescription
make graphql typing for getDescription conform with graphql-js
This commit is contained in:
4
types/graphql/index.d.ts
vendored
4
types/graphql/index.d.ts
vendored
@@ -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,
|
||||
|
||||
21
types/graphql/type/schema.d.ts
vendored
21
types/graphql/type/schema.d.ts
vendored
@@ -61,6 +61,27 @@ export class GraphQLSchema {
|
||||
getDirective(name: string): GraphQLDirective;
|
||||
}
|
||||
|
||||
export type GraphQLSchemaValidationOptions = {
|
||||
/**
|
||||
* When building a schema from a GraphQL service's introspection result, it
|
||||
* might be safe to assume the schema is valid. Set to true to assume the
|
||||
* produced schema is valid.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
assumeValid?: boolean;
|
||||
|
||||
/**
|
||||
* If provided, the schema will consider fields or types with names included
|
||||
* in this list valid, even if they do not adhere to the specification's
|
||||
* schema validation rules.
|
||||
*
|
||||
* This option is provided to ease adoption and may be removed in a future
|
||||
* major release.
|
||||
*/
|
||||
allowedLegacyNames?: ReadonlyArray<string>;
|
||||
};
|
||||
|
||||
export interface GraphQLSchemaConfig {
|
||||
query: GraphQLObjectType;
|
||||
mutation?: GraphQLObjectType;
|
||||
|
||||
29
types/graphql/utilities/buildASTSchema.d.ts
vendored
29
types/graphql/utilities/buildASTSchema.d.ts
vendored
@@ -1,6 +1,17 @@
|
||||
import { DocumentNode, Location } from '../language/ast';
|
||||
import { DocumentNode, Location, StringValueNode } from '../language/ast';
|
||||
import { Source } from '../language/source';
|
||||
import { GraphQLSchema } from '../type/schema';
|
||||
import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema';
|
||||
|
||||
interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
|
||||
/**
|
||||
* Descriptions are defined as preceding string literals, however an older
|
||||
* experimental version of the SDL supported preceding comments as
|
||||
* descriptions. Set to true to enable this deprecated behavior.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
commentDescriptions?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes the ast of a schema document produced by the parse function in
|
||||
@@ -15,10 +26,18 @@ import { GraphQLSchema } from '../type/schema';
|
||||
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.
|
||||
* Given an ast node, returns its string description.
|
||||
*
|
||||
* Accepts options as a second argument:
|
||||
*
|
||||
* - commentDescriptions:
|
||||
* Provide true to use preceding comments as the description.
|
||||
*
|
||||
*/
|
||||
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
|
||||
|
||||
2
types/graphql/utilities/index.d.ts
vendored
2
types/graphql/utilities/index.d.ts
vendored
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user