Skip to content

Commit f5c81a0

Browse files
adrians5jclaude
andauthored
refactor(scheduler-aws): remove ContextPlugin from tests (#5419)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8e71446 commit f5c81a0

3 files changed

Lines changed: 14 additions & 38 deletions

File tree

packages/api-scheduler-aws/__tests__/__mocks/handler/useGraphQLHandler.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,15 @@ export const useGraphQLHandler = (params: UseGraphQLHandlerParams) => {
9090

9191
SchedulerFeature.register(container);
9292
container.registerInstance(SchedulerService, new VoidSchedulerService());
93-
if (extraPlugins.length > 0) {
94-
registerLegacyPluginsViaGqlContextualSchema(container, extraPlugins);
93+
// DI-native plugins are plain `container => {}` functions; call them directly. Any
94+
// remaining legacy plugins still go through the bridge until #39 removes it.
95+
const isFn = (p: any) => typeof p === "function" && !p.prototype;
96+
for (const plugin of extraPlugins.filter(isFn)) {
97+
(plugin as (container: any) => void)(container);
98+
}
99+
const legacyPlugins = extraPlugins.filter((p: any) => !isFn(p));
100+
if (legacyPlugins.length > 0) {
101+
registerLegacyPluginsViaGqlContextualSchema(container, legacyPlugins);
95102
}
96103

97104
GraphQLEngineFeature.register(container);

packages/api-scheduler-aws/__tests__/__mocks/schedulerManifestPlugin.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/api-scheduler-aws/__tests__/graphql.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
99
import { useHandler } from "~tests/__mocks/handler/useHandler.js";
1010
import { NamespaceHandler } from "~tests/__mocks/NamespaceHandler.js";
11-
import { ContextPlugin } from "@webiny/api";
11+
import type { Container } from "@webiny/di";
1212
import { SCHEDULED_ACTION_PUBLISH } from "@webiny/api-scheduler/constants.js";
1313

1414
describe("Scheduler GraphQL", () => {
@@ -19,10 +19,10 @@ describe("Scheduler GraphQL", () => {
1919
return createMockScheduleClient();
2020
},
2121
plugins: [
22-
new ContextPlugin(async context => {
23-
context.container.register(NamespaceHandler);
24-
context.container.register(PublishTestEntryActionHandler);
25-
})
22+
(container: Container) => {
23+
container.register(NamespaceHandler);
24+
container.register(PublishTestEntryActionHandler);
25+
}
2626
]
2727
});
2828

0 commit comments

Comments
 (0)