@aws-amplify/data-schema 1.20.4 → 1.20.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -601,6 +601,7 @@ function getAppSyncAuthDirectiveFromRule(rule) {
601
601
  function mapToNativeAppSyncAuthDirectives(authorization, isCustomHandler) {
602
602
  const rules = new Set();
603
603
  const groupProvider = new Map();
604
+ const generalProviderUsed = new Set();
604
605
  for (const entry of authorization) {
605
606
  const rule = accessData(entry);
606
607
  isCustomHandler && validateCustomHandlerAuthRule(rule);
@@ -612,14 +613,15 @@ function mapToNativeAppSyncAuthDirectives(authorization, isCustomHandler) {
612
613
  rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
613
614
  }
614
615
  else {
616
+ generalProviderUsed.add(provider);
615
617
  rules.add(provider);
616
618
  }
617
619
  }
618
620
  groupProvider.forEach((groups, provider) => {
619
- rules.add(`${provider}(cognito_groups: [${Array.from(groups)
620
- .map((group) => `"${group}"`)
621
- .join(', ')}])`);
622
- // example: (cognito_groups: ["Bloggers", "Readers"])
621
+ if (!generalProviderUsed.has(provider)) {
622
+ rules.add(`${provider}(cognito_groups: [${Array.from(groups).reduce((acc, group) => acc == "" ? `"${group}"` : `${acc}, "${group}"`, "")}])`);
623
+ // example: (cognito_groups: ["Bloggers", "Readers"])
624
+ }
623
625
  });
624
626
  const authString = [...rules].join(' ');
625
627
  return { authString };