Skip to content

Commit

Permalink
Revert "fix(api-graphql): default selection set regression" (#13187)
Browse files Browse the repository at this point in the history
Revert "fix(api-graphql): default selection set regression (#13185)"

This reverts commit 873a6f4.
  • Loading branch information
iartemiev committed Mar 28, 2024
1 parent 873a6f4 commit 27c1917
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated from `./schema.ts` by amplify-backend generate config.
* Generated from `./schema.ts` by samsara.
*
* Cognito fields etc. omitted.
*/
Expand Down Expand Up @@ -1656,68 +1656,6 @@ const amplifyConfig = {
sortKeyFieldNames: [],
},
},
ModelStaticGroup: {
name: 'ModelStaticGroup',
fields: {
id: {
name: 'id',
isArray: false,
type: 'ID',
isRequired: true,
attributes: [],
},
description: {
name: 'description',
isArray: false,
type: 'String',
isRequired: false,
attributes: [],
},
createdAt: {
name: 'createdAt',
isArray: false,
type: 'AWSDateTime',
isRequired: false,
attributes: [],
isReadOnly: true,
},
updatedAt: {
name: 'updatedAt',
isArray: false,
type: 'AWSDateTime',
isRequired: false,
attributes: [],
isReadOnly: true,
},
},
syncable: true,
pluralName: 'ModelStaticGroups',
attributes: [
{
type: 'model',
properties: {},
},
{
type: 'auth',
properties: {
rules: [
{
groupClaim: 'cognito:groups',
provider: 'userPools',
allow: 'groups',
groups: ['Admin'],
operations: ['create', 'update', 'delete', 'read'],
},
],
},
},
],
primaryKeyInfo: {
isCustomPrimaryKey: false,
primaryKeyFieldName: 'id',
sortKeyFieldNames: [],
},
},
},
enums: {
Status: {
Expand Down
5 changes: 0 additions & 5 deletions packages/api-graphql/__tests__/fixtures/modeled/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ const schema = a.schema({
description: a.string(),
})
.authorization([a.allow.groupsDefinedIn('groupsField')]),
ModelStaticGroup: a
.model({
description: a.string(),
})
.authorization([a.allow.specificGroup('Admin')]),
// #endregion
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('generateClient', () => {
'CustomImplicitOwner',
'ModelGroupDefinedIn',
'ModelGroupsDefinedIn',
'ModelStaticGroup',
];

it('generates `models` property when Amplify.getConfig() returns valid GraphQL provider config', () => {
Expand Down
5 changes: 1 addition & 4 deletions packages/api-graphql/__tests__/resolveOwnerFields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ describe('owner field resolution', () => {
ThingWithOwnerFieldSpecifiedInModel: ['owner'],
ThingWithAPIKeyAuth: [],
ThingWithoutExplicitAuth: [],
ModelGroupDefinedIn: ['groupField'],
ModelGroupsDefinedIn: ['groupsField'],
ModelStaticGroup: [],
};

for (const [modelName, expected] of Object.entries(expectedResolutions)) {
Expand All @@ -26,7 +23,7 @@ describe('owner field resolution', () => {
const model: SchemaModel = modelIntroSchema.models[modelName];

const resolvedField = resolveOwnerFields(model);
expect(resolvedField).toStrictEqual(expected);
expect(resolvedField).toEqual(expected);
});
}
});
5 changes: 1 addition & 4 deletions packages/api-graphql/src/utils/resolveOwnerFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ export function resolveOwnerFields(model: Model): string[] {
for (const rule of attr.properties.rules) {
if (rule.allow === 'owner') {
ownerFields.add(rule.ownerField || 'owner');
} else if (rule.allow === 'groups' && rule.groupsField !== undefined) {
// only valid for dynamic group(s)
// static group auth will have an array of predefined groups in the attribute, groups: string[]
// but `groupsField` will be undefined
} else if (rule.allow === 'groups') {
ownerFields.add(rule.groupsField);
}
}
Expand Down

0 comments on commit 27c1917

Please sign in to comment.