feat: optimize custom selection set type#647
Conversation
🦋 Changeset detectedLatest commit: 3733d95 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
We applied these changes as a patch to our project, but we still get the error message from #424
|
Are you sure all instances of |
packages/benches/comparisons/selection-set-experimentation.bench.ts
Outdated
Show resolved
Hide resolved
packages/benches/p99/within-limit/operations/p99-tall-complex-CRUDL.bench.ts
Outdated
Show resolved
Hide resolved
packages/integration-tests/__tests__/defined-behavior/3-exhaustive/custom-selection-set.ts
Outdated
Show resolved
Hide resolved
packages/integration-tests/__tests__/defined-behavior/3-exhaustive/custom-selection-set.ts
Outdated
Show resolved
Hide resolved
bobbor
left a comment
There was a problem hiding this comment.
tried my best to understand what is actually going on here.
I left a bunch of comments. If what I wrote makes no sense I would understand that too :D
|
I’ve installed the snapshot version via The import { SelectionSet } from 'aws-amplify/api';
export type User = SelectionSet<
Schema['User']['type'],
[
'id',
'firstName',
'lastName',
'email',
'workingContracts.*',
'workingContracts.workingTimeModelID',
]
>;Before applying the snapshot, this produced the expected strongly typed result (but triggered TS2590). When using the same selection set for querying, the returned data is correctly typed: const { data } = await client.models.User.list({
selectionSet: UserSelectionSet,
}); |
Thanks — I found the reason why my The first generic parameter of type User = SelectionSet<
Schema['User']['type'],
typeof UserSelectionSet
>Since Switching it to the model definition fixes it: type User = SelectionSet<
Schema['User'],
typeof UserSelectionSet
> |
|
Thanks for the feedback @oe-bayram! Appreciate it. |
dd23112 to
54c5624
Compare
Problem
Issue number, if available:
#424
Changes
Corresponding docs PR, if applicable: N/A
Validation
Test project: https://github.com/pranavosu/selection-set-repro
prereq: valid AWS creds
test commands:
npx ampx sandbox -> npm run build -> npm run startrun without overrides (
"@aws-amplify/data-schema": "1.22.0",) and then with the@amplify/data-schemapackage overrides (0.0.0-optimize-selection-sets-20260108232711).Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.