aws-amplify / amplify-cli Public
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
Feature/@key #1463
Feature/@key #1463
Conversation
|
excited (sorry can't be technically constructive but wanted to show thanks) |
…tructures. Still need to update list as well as implement the new query resolver using existing parts. The last change is to handle the partial key update scenario in update operations.
|
Will there be a way to dynamically specify the keys client-side like so API.graphql(graphqlOperation(listContacts, { limit: 100, nextToken, sortBy: { firstName: 'gte', lastName: 'gte' }));? Or if that's not possible, will we be able to add multiple query fields like type Contact
@model
@key(name: "ByOwnerLastNameFirstName", fields: ["owner", "lastName", "firstName"], queryField: "contactsByOwnerAndName")
@key(name: "ByOwnerCityLastNameFirstName", fields: ["owner", "city", "lastName", "firstName"], queryField: "contactsByOnwerAndCity")
@auth(rules: [{ allow: owner }])
{
id: ID!
firstName: String
lastName: String
city: String
email: String
telephone: String
owner: String
}? |
…ite sort key integrity
|
@janhesters Unfortunately there is no such thing as a dynamic sort by argument in DynamoDB but yes you are able to add multiple query fields exactly like you mentioned. edit: I should mention that you can dictate the direction that an index is scanned/queried dynamically. |
| if (deleteResolver) { | ||
| deleteResolver.Properties.RequestMappingTemplate = joinSnippets([ | ||
| this.setKeySnippet(directive, true), | ||
| ensureCompositeKeySnippet(directive), |
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.
Do we need this? Since we don't support batch delete do we need to ensure composite key
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.
Nope we do not. Removed.
| const finalSortKeyField = definition.fields.find(f => f.name.value === finalSortKeyFieldName); | ||
| // All composite keys (length > 2) are casted to strings. | ||
| const sortKeyConditionInput = args.fields.length > 2 ? | ||
| makeScalarKeyConditionForType(makeNamedType('String')) : |
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.
As discussed can we make this simpler as we know the fields.length is 2
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.
Updated
| GRAPHQL_CLIENT = new GraphQLClient(endpoint, { 'x-api-key': apiKey }) | ||
| }); | ||
|
|
||
| // afterAll(async () => { |
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.
Can we have the cleanup back
| @@ -0,0 +1,163 @@ | |||
| # Testing Custom Indexes | |||
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.
We don't need this anymore right
| import ModelTransformer from 'graphql-dynamodb-transformer'; | ||
| import KeyTransformer from 'graphql-key-transformer'; | ||
| import { parse, FieldDefinitionNode, ObjectTypeDefinitionNode } from 'graphql'; | ||
| import { expectArguments, expectFields, expectNonNullFields, expectNullableFields } from '../testUtil'; |
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.
Are we using expectFields?
| } from 'graphql'; | ||
| import { isNonNullType } from 'graphql-transformer-common'; | ||
|
|
||
| export function expectFields(type: ObjectTypeDefinitionNode, fields: string[]) { |
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.
Extending the matcher would be a better approach. More on this at jest docs
How? |
|
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |


Issue #, if available:
#1062
Description of changes:
Still a work in progress. This is the initial work for custom indexes. I have a few more things to finish so please do not merge this yet. These features require substantial changes so I want to start the PR process earlier rather than later.
Complete:
Work remaining:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.