@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.
@@ -606,6 +606,7 @@ function getAppSyncAuthDirectiveFromRule(rule) {
606
606
  function mapToNativeAppSyncAuthDirectives(authorization, isCustomHandler) {
607
607
  const rules = new Set();
608
608
  const groupProvider = new Map();
609
+ const generalProviderUsed = new Set();
609
610
  for (const entry of authorization) {
610
611
  const rule = (0, Authorization_1.accessData)(entry);
611
612
  isCustomHandler && validateCustomHandlerAuthRule(rule);
@@ -617,14 +618,15 @@ function mapToNativeAppSyncAuthDirectives(authorization, isCustomHandler) {
617
618
  rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
618
619
  }
619
620
  else {
621
+ generalProviderUsed.add(provider);
620
622
  rules.add(provider);
621
623
  }
622
624
  }
623
625
  groupProvider.forEach((groups, provider) => {
624
- rules.add(`${provider}(cognito_groups: [${Array.from(groups)
625
- .map((group) => `"${group}"`)
626
- .join(', ')}])`);
627
- // example: (cognito_groups: ["Bloggers", "Readers"])
626
+ if (!generalProviderUsed.has(provider)) {
627
+ rules.add(`${provider}(cognito_groups: [${Array.from(groups).reduce((acc, group) => acc == "" ? `"${group}"` : `${acc}, "${group}"`, "")}])`);
628
+ // example: (cognito_groups: ["Bloggers", "Readers"])
629
+ }
628
630
  });
629
631
  const authString = [...rules].join(' ');
630
632
  return { authString };