Skip to content

Commit d2f0821

Browse files
committed
chore: add comments
1 parent 27dd66b commit d2f0821

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

packages/backend/src/graphql/admin/mutations/add-gsi.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { flattenJsonb } from '@/helpers/knex-jsonb-flatten'
1+
import { DataPropertyNames } from 'objection'
2+
23
import { GSIS } from '@/models/dynamodb/table-row'
34
import TableColumnMetadata from '@/models/table-column-metadata'
45

@@ -37,17 +38,14 @@ const createTable: AdminMutationResolvers['addGsi'] = async (
3738
}
3839

3940
await TableColumnMetadata.query()
40-
.patch(
41-
flattenJsonb({
42-
config: {
43-
gsi: {
44-
indexName: correspondingGsi.gsi,
45-
type: correspondingGsi.type,
46-
status: 'pending',
47-
},
48-
},
49-
}),
50-
)
41+
.patch({
42+
['config:gsi' as DataPropertyNames<TableColumnMetadata>]: {
43+
indexName: correspondingGsi.gsi,
44+
type: correspondingGsi.type,
45+
status: 'pending',
46+
patchFrom: new Date().toISOString(),
47+
},
48+
})
5149
.where({ id: columnId })
5250

5351
return true

packages/backend/src/graphql/mutation-resolvers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { MutationResolvers } from './__generated__/types.generated'
1+
import type {
2+
AdminMutation,
3+
MutationResolvers,
4+
} from './__generated__/types.generated'
25
import bulkRetryExecutions from './mutations/bulk-retry-executions'
36
import createConnection from './mutations/create-connection'
47
import createFlow from './mutations/create-flow'
@@ -86,5 +89,5 @@ export default {
8689
// This is a special stub that enables us to group all our admin-related
8790
// mutations into a special AdminMutation object; each "mutations" is handled by field
8891
// resolvers defined in @/graphql/admin/mutations.
89-
admin: () => ({}),
92+
admin: () => ({} as AdminMutation),
9093
} satisfies MutationResolvers

packages/backend/src/helpers/authentication.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ const authentication = shield(
103103
// Not OTP, but no real reason to be looser than OTP.
104104
loginWithSgid: rateLimitRule({ window: '1s', max: 5 }),
105105
loginWithSelectedSgid: rateLimitRule({ window: '1s', max: 5 }),
106+
// Only admins can access admin mutations, we dont want to default it in '*'
106107
admin: isAdminOperation,
107108
},
109+
// This is not needed since it's already added above
110+
// but adding it here in case we want to make more granular in the future
108111
AdminMutation: isAdminOperation,
109112
},
110113
{

0 commit comments

Comments
 (0)