-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api-graphql): add model index query support #12967
Conversation
160f01c
to
63dbb09
Compare
63dbb09
to
5b0c44e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm torn on this one. There are two lines I'm tempted to hold here.
- We can and should decompose functions down into well named, single responsibility private functions to increase the readability.
- Casting
any
into a type gives us no protection and this code is touching the piece that is making promises it isn't guaranteeing.
I'm inclined to hold the line on the 1 and accept that 2 is a bigger issue that deserves individual treatment, but both seem worth discussion / alignment.
const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model); | ||
|
||
for (const idx of secondaryIdxs) { | ||
models[name][idx.queryField] = indexQueryFactory( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised TS is cool with this, but it looks like models is any
above and specified by the return type here, which doesn't give our customers any type interface protection, does it? How do we get guarantees that all of the typed index methods from the type will be populated at runtime?
5b0c44e
to
1154745
Compare
1db80e4
to
af52ac4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the updates. One nit suggestion, but otherwise happy to carry on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving changes to aws-amplify
and core
.
Description of changes
Runtime implementation for this feature.
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.