mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Merge pull request #19591 from APIs-guru/executeArgs
[GraphQL] Overloading of 'graphql' and 'execute' functions
This commit is contained in:
13
types/graphql/execution/execute.d.ts
vendored
13
types/graphql/execution/execute.d.ts
vendored
@@ -36,6 +36,16 @@ export interface ExecutionResult {
|
||||
errors?: GraphQLError[];
|
||||
}
|
||||
|
||||
export type ExecutionArgs = {
|
||||
schema: GraphQLSchema,
|
||||
document: DocumentNode,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: {[key: string]: any},
|
||||
operationName?: string,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any>
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements the "Evaluating requests" section of the GraphQL specification.
|
||||
*
|
||||
@@ -43,7 +53,10 @@ export interface ExecutionResult {
|
||||
*
|
||||
* If the arguments to this function do not result in a legal execution context,
|
||||
* a GraphQLError will be thrown immediately explaining the invalid input.
|
||||
*
|
||||
* Accepts either an object with named arguments, or individual arguments.
|
||||
*/
|
||||
export function execute(args: ExecutionArgs): Promise<ExecutionResult>;
|
||||
export function execute(
|
||||
schema: GraphQLSchema,
|
||||
document: DocumentNode,
|
||||
|
||||
1
types/graphql/execution/index.d.ts
vendored
1
types/graphql/execution/index.d.ts
vendored
@@ -2,6 +2,7 @@ export {
|
||||
execute,
|
||||
defaultFieldResolver,
|
||||
responsePathAsArray,
|
||||
ExecutionArgs,
|
||||
ExecutionResult
|
||||
} from './execute';
|
||||
|
||||
|
||||
28
types/graphql/graphql.d.ts
vendored
28
types/graphql/graphql.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
import { Source } from './language/source';
|
||||
import { GraphQLFieldResolver } from './type/definition';
|
||||
import { GraphQLSchema } from './type/schema';
|
||||
import { ExecutionResult } from './execution/execute';
|
||||
|
||||
@@ -10,9 +12,11 @@ import { ExecutionResult } from './execution/execute';
|
||||
* may wish to separate the validation and execution phases to a static time
|
||||
* tooling step, and a server runtime step.
|
||||
*
|
||||
* Accepts either an object with named arguments, or individual arguments:
|
||||
*
|
||||
* schema:
|
||||
* The GraphQL type system to use when validating and executing a query.
|
||||
* requestString:
|
||||
* source:
|
||||
* A GraphQL language formatted string representing the requested operation.
|
||||
* rootValue:
|
||||
* The value provided as the first argument to resolver functions on the top
|
||||
@@ -24,14 +28,30 @@ import { ExecutionResult } from './execution/execute';
|
||||
* The name of the operation to use if requestString contains multiple
|
||||
* possible operations. Can be omitted if requestString contains only
|
||||
* one operation.
|
||||
* fieldResolver:
|
||||
* A resolver function to use when one is not provided by the schema.
|
||||
* If not provided, the default field resolver is used (which looks for a
|
||||
* value or method on the source value with the field's name).
|
||||
*/
|
||||
export function graphql(
|
||||
export function graphql(args: {
|
||||
schema: GraphQLSchema,
|
||||
requestString: string,
|
||||
source: string | Source,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: {
|
||||
[key: string]: any
|
||||
},
|
||||
operationName?: string
|
||||
operationName?: string,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any>
|
||||
}): Promise<ExecutionResult>;
|
||||
export function graphql(
|
||||
schema: GraphQLSchema,
|
||||
source: string | Source,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: {
|
||||
[key: string]: any
|
||||
},
|
||||
operationName?: string,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any>
|
||||
): Promise<ExecutionResult>;
|
||||
|
||||
1
types/graphql/index.d.ts
vendored
1
types/graphql/index.d.ts
vendored
@@ -30,6 +30,7 @@ export {
|
||||
defaultFieldResolver,
|
||||
responsePathAsArray,
|
||||
getDirectiveValues,
|
||||
ExecutionArgs,
|
||||
ExecutionResult,
|
||||
} from './execution';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user