From 4cc499b5a60c8d85101c604ca457a212a4ff0a26 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 11 Jun 2020 16:19:04 +0300 Subject: [PATCH] ExecutionResult: add 'extensions' field --- src/execution/execute.d.ts | 8 +++++++- src/execution/execute.js | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/execution/execute.d.ts b/src/execution/execute.d.ts index f927d9082dc..834e2fcb164 100644 --- a/src/execution/execute.d.ts +++ b/src/execution/execute.d.ts @@ -43,11 +43,17 @@ export interface ExecutionContext { * * - `errors` is included when any errors occurred as a non-empty array. * - `data` is the result of a successful execution of the query. + * - `extensions` is reserved for implementors to extend the protocol however they see fit, + * and hence there are no additional restrictions on its contents. */ -export interface ExecutionResult { +export interface ExecutionResult< + TData = { [key: string]: any }, + TExtensions = { [key: string]: any } +> { errors?: ReadonlyArray; // TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229 data?: TData | null; + extensions?: TExtensions; } export interface ExecutionArgs { diff --git a/src/execution/execute.js b/src/execution/execute.js index 821b6e403f5..4dff1ff3cef 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -109,10 +109,13 @@ export type ExecutionContext = {| * * - `errors` is included when any errors occurred as a non-empty array. * - `data` is the result of a successful execution of the query. + * - `extensions` is reserved for implementors to extend the protocol however they see fit, + * and hence there are no additional restrictions on its contents. */ export type ExecutionResult = {| errors?: $ReadOnlyArray, data?: ObjMap | null, + extensions?: ObjMap, |}; export type ExecutionArgs = {|