Skip to content

Commit 335385e

Browse files
committed
feat: added extensions support for afterAll
1 parent f6a4250 commit 335385e

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/afterAllExecutor.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ governing permissions and limitations under the License.
1212

1313
import { GraphQLError } from 'graphql/error';
1414
import getAfterAllHookHandler from './handleAfterAllHooks';
15-
import type {
16-
HookConfig,
17-
GraphQLData,
18-
GraphQLError as GraphQLErrorType,
19-
GraphQLResult,
20-
StateApi,
21-
} from './types';
15+
import type { HookConfig, GraphQLResult, StateApi } from './types';
2216
import type { YogaLogger, GraphQLParams } from 'graphql-yoga';
2317
import { PLUGIN_HOOKS_ERROR_CODES } from './errors';
2418

@@ -31,7 +25,7 @@ export interface AfterAllExecutionContext {
3125
state: StateApi;
3226
logger: YogaLogger;
3327
document: unknown;
34-
result: { data?: GraphQLData; errors?: GraphQLErrorType[] };
28+
result: GraphQLResult;
3529
setResultAndStopExecution: (result: GraphQLResult) => void;
3630
afterAll: HookConfig;
3731
}
@@ -77,6 +71,7 @@ export async function executeAfterAllHook(
7771
setResultAndStopExecution({
7872
data: hookResponse.data.result.data || result.data,
7973
errors: hookResponse.data.result.errors || result.errors,
74+
extensions: hookResponse.data.result.extensions || result.extensions,
8075
});
8176
}
8277
} catch (err: unknown) {

src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
HookConfig,
2020
MemoizedFns,
2121
UserContext,
22-
GraphQLData,
22+
GraphQLResult,
2323
SourceHookConfig,
2424
StateApi,
2525
AfterSourceHookFunctionPayload,
@@ -143,11 +143,7 @@ export default async function hooksPlugin(config: PluginConfig): Promise<HooksPl
143143

144144
if (afterAllHookHandler) {
145145
return {
146-
onExecuteDone: async ({
147-
result,
148-
}: {
149-
result: { data?: GraphQLData; errors?: GraphQLError[] };
150-
}) => {
146+
onExecuteDone: async ({ result }: { result: GraphQLResult }) => {
151147
await executeAfterAllHook(afterAllHookHandler, {
152148
params,
153149
request,

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type GraphQLData = ExecutionResult['data'];
2323
export type GraphQLResult = {
2424
data?: GraphQLData;
2525
errors?: GraphQLError[];
26+
extensions?: Record<string, unknown>;
2627
};
2728

2829
/**

0 commit comments

Comments
 (0)