@aws-amplify/data-schema 1.20.3 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/data-schema",
3
- "version": "1.20.3",
3
+ "version": "1.20.5",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -897,6 +897,7 @@ function mapToNativeAppSyncAuthDirectives(
897
897
  const rules = new Set<string>();
898
898
 
899
899
  const groupProvider: Map<string, Set<string>> = new Map();
900
+ const generalProviderUsed = new Set<string>();
900
901
 
901
902
  for (const entry of authorization) {
902
903
  const rule = accessData(entry);
@@ -911,17 +912,20 @@ function mapToNativeAppSyncAuthDirectives(
911
912
  };
912
913
  rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
913
914
  } else {
915
+ generalProviderUsed.add(provider);
914
916
  rules.add(provider);
915
917
  }
916
918
  }
917
919
 
918
920
  groupProvider.forEach((groups, provider) => {
919
- rules.add(
920
- `${provider}(cognito_groups: [${Array.from(groups)
921
- .map((group) => `"${group}"`)
922
- .join(', ')}])`,
923
- );
924
- // example: (cognito_groups: ["Bloggers", "Readers"])
921
+ if(!generalProviderUsed.has(provider)) {
922
+ rules.add(
923
+ `${provider}(cognito_groups: [${Array.from(groups).reduce((acc, group) =>
924
+ acc == "" ? `"${group}"` : `${acc}, "${group}"`
925
+ , "")}])`
926
+ );
927
+ // example: (cognito_groups: ["Bloggers", "Readers"])
928
+ }
925
929
  })
926
930
 
927
931
  const authString = [...rules].join(' ');
@@ -1156,9 +1156,12 @@ export function buildGraphQLVariables(
1156
1156
  modelIntrospection,
1157
1157
  ),
1158
1158
  ).filter(([fieldName]) => {
1159
- const { isReadOnly } = fields[fieldName];
1160
-
1161
- return !isReadOnly;
1159
+ // omit field from update input
1160
+ // if exists in fields and marked read only
1161
+ // if does not exist in fields but implicitly added to schema via ownership
1162
+ return fields[fieldName]
1163
+ ? !fields[fieldName].isReadOnly
1164
+ : !resolveOwnerFields(modelDefinition).includes(fieldName);
1162
1165
  }),
1163
1166
  )
1164
1167
  : {},