(
existing: readonly GraphqlAuthMethod[],
incoming: readonly GraphqlAuthMethodInput[],
)
| 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, |
no test coverage detected