MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / merge

Function merge

packages/plugins/graphql/src/api/handlers.test.ts:38–57  ·  view source on GitHub ↗
(
    existing: readonly GraphqlAuthMethod[],
    incoming: readonly GraphqlAuthMethodInput[],
  )

Source from the content-addressed store, hash-verified

36): GraphqlPluginExtension => {
37 let counter = 0;
38 const merge = (
39 existing: readonly GraphqlAuthMethod[],
40 incoming: readonly GraphqlAuthMethodInput[],
41 ): readonly GraphqlAuthMethod[] => {
42 const result: GraphqlAuthMethod[] = existing.map((entry: GraphqlAuthMethod) => entry);
43 const taken = new Set<string>(result.map((entry: GraphqlAuthMethod) => entry.slug));
44 for (const entry of incoming) {
45 const requested = entry.slug?.trim() ?? "";
46 const index = result.findIndex((current: GraphqlAuthMethod) => current.slug === requested);
47 if (requested.length > 0 && index >= 0) {
48 result[index] = entry as GraphqlAuthMethod;
49 continue;
50 }
51 const slug =
52 requested.length > 0 && !taken.has(requested) ? requested : `custom_${counter++}`;
53 taken.add(slug);
54 result.push({ ...entry, slug } as GraphqlAuthMethod);
55 }
56 return result;
57 };
58
59 const extension: GraphqlPluginExtension = {
60 addIntegration: () => unused,

Callers 1

makeStubExtensionFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected