@aws-amplify/data-schema 1.20.4 → 1.21.0

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 };
@@ -743,7 +745,7 @@ const transformedSecondaryIndexesForModel = (modelName, secondaryIndexes, modelF
743
745
  }
744
746
  }
745
747
  }
746
- if (!sortKeys.length && !indexName && !queryField) {
748
+ if (!sortKeys.length && !indexName && !queryField && queryField !== null) {
747
749
  return `@index(queryField: "${secondaryIndexDefaultQueryField(modelName, partitionKey)}")`;
748
750
  }
749
751
  const attributes = [];
@@ -753,7 +755,10 @@ const transformedSecondaryIndexesForModel = (modelName, secondaryIndexes, modelF
753
755
  if (sortKeys.length) {
754
756
  attributes.push(`sortKeyFields: [${sortKeys.map((sk) => `"${sk}"`).join(', ')}]`);
755
757
  }
756
- if (queryField) {
758
+ if (queryField === null) {
759
+ attributes.push(`queryField: null`);
760
+ }
761
+ else if (queryField) {
757
762
  attributes.push(`queryField: "${queryField}"`);
758
763
  }
759
764
  else {