Skip to content
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

Support Query calls to Dynamo #1

Open
multimeric opened this issue Feb 23, 2022 · 4 comments
Open

Support Query calls to Dynamo #1

multimeric opened this issue Feb 23, 2022 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@multimeric
Copy link
Owner

multimeric commented Feb 23, 2022

This would speed up the count function for users who have GSIs.

Implementers should look into how Amplify performs the conditional logic using VTL: https://github.com/aws-amplify/amplify-cli/blob/fcf9100c778e98e16f0ed695112f2a7251aca06a/packages/amplify-graphql-model-transformer/src/resolvers/query.ts#L141-L155.

#if( !$util.isNull($ctx.stash.modelQueryExpression) && !$util.isNullOrEmpty($ctx.stash.modelQueryExpression.expression) )
  $util.qr($ListRequest.put("operation", "Query"))
  $util.qr($ListRequest.put("query", $ctx.stash.modelQueryExpression))
  #if( !$util.isNull($args.sortDirection) && $args.sortDirection == "DESC" )
    #set( $ListRequest.scanIndexForward = false )
  #else
    #set( $ListRequest.scanIndexForward = true )
  #end
#else
  $util.qr($ListRequest.put("operation", "Scan"))
#end
@multimeric multimeric added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Feb 23, 2022
@multimeric
Copy link
Owner Author

This would also require generating a few new Query subtypes like countByRepresentative.

@multimeric
Copy link
Owner Author

multimeric commented Feb 24, 2022

Ideally this would be implemented as a @count directive on the individual index fields. It should check if they also have the @index directive and fail if they do not.

@Tedsterh
Copy link

Tedsterh commented Mar 20, 2022

I believe I have added a way to use @count on Fields as well, its in a fork at the moment as I'm not what the next steps are, I am unable to install it in my area as I get an npm error. If you could take a look and let me know what I need to do to test this and or get it in here.

I have also added a variable to the Directive called CountType as there is a DISTINCT query on DynamoDB that might be quite useful

@multimeric
Copy link
Owner Author

Can you open a pull request please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants