1 Answer
- Newest
- Most votes
- Most comments
0
Once you have your AppSync API defined you should see on the overview page (when you click on the name of the API) the command to add the API to an Amplify app:
amplify add codegen --apiId <YOUR_API_ID>
Please note that AppSync is a managed service that will remove the need for you to host your GraphQL on ECS or anything like that. The mapping of the GraphQL queries to the resolvers (such as the ones for DynamoDB) will do the fetching of the records for you. See for example the template mapping for DynamoDB resolvers here.
answered 2 years ago
Relevant content
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
Hi, there. Thank you for your reply.
add codegen
command.nextToken
becomes null and then returns the data to the client.Clarifications:
I believe I still require the proxy I have described. Please inform me if there is something I am missing from my understanding.
References:
[1] DynamoDB Pagination with AppSync: https://advancedweb.hu/how-to-use-dynamodb-with-appsync/#pagination
@Toby, your reference link explains how to use the pagination without any proxy. The pagination is done on the client-side. In most cases, you can't display more than a few results (10, 20, 50, 100...) on the client anyway, and you don't want to wait for the end of fetching thousands of items from the server. You can implement the logic of
limit
ornextToken
on the client app using any graphQL client or Amplify in this case.You're right about calling everything on the client. I overthought that aspect.
However, given my data is for a leader board, I do not see how I can display the N highest scores without considering all items.
GraphQL and AppSync support
sortDirection: DESC
on a query. For example, https://docs.amplify.aws/guides/api-graphql/query-with-sorting/q/platform/js/Hi, that's a great suggestion. Unfortunately, I'm going to struggle to make a GSI in DynamoDB because the field I want to sort by is nested like so: Teams --> Team -->
FinalScore
. Each database record contains the results of each team in a class at school.I believe I would have to create and maintain a second Dynamo table where each record is for one team's scores. (They can be linked back to their class record in the original table using the same partition key and sort key.)
FinalScore
could then have a GSI made for it (i.e. the field wouldn't be nested inside anything).