How do i append an array in GraphQL through AppSync?
See original GitHub issueFor an ‘id’ in my DynamoDB table (e.g. e5eb02ae-04d5-4331-91e6-11efaaf12ea5
), i have a column called Weather
['sun', 'rain', 'snow', etc...]
I need to update Weather when, say [‘hail’] arrives. Right now, my update() below, replaces the the entire array. All i want to do is append ‘hail’ to the end of that list.
const updateinfo = {
id: "e5eb02ae-04d5-4331-91e6-11efaaf12ea5",
Weather: "hail"
}
try {
await API.graphql(graphqlOperation (UpdateInfo, { input: updateinfo })) //mutation
console.log('success')
}
catch (err) {
console.log(err)
}
How do i do this, ensuring that my list is just appended to with the info, WITHOUT having to get() and pull down [‘sun’, ‘rain’, ‘snow’, etc…], then adding ‘hail’ and creating a new array? Thats then a GetInfo() and an UpdateInfo() which is double the effort/call/expense.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:11 (1 by maintainers)
Top Results From Across the Web
AWS amplify graphql appsync - how to replace array instead ...
I am using AWS amplify with graphql and appsync. ... How can I replace my array with a new array, instead of appending...
Read more >Resolver mapping template programming guide - AWS AppSync
In this tutorial, we demonstrate this by creating a simple GraphQL schema and passing a map of values to a Lambda function. The...
Read more >Tutorial: Send an Array with GraphQL | by Andrew Larsen
Step 2 — Create your Input Type This step looks nearly identical to Step 1, but is absolutely necessary in order to send...
Read more >GraphQL List - How to use arrays in GraphQL schema ...
Applying array on GraphQL type. Implementing GraphQL modifiers. How to design mutations and queries with list of items as an argument and returned...
Read more >Directly push to an array on DynamoDB entry with GraphQL ...
Is it possible to create a resolver in AppSync that takes an input (say an object) and pushes it on an existing array...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ajhool an array is definitely a standard thing that many many people use, this should absolutely be a feature that should work out of the box
Appending to an array field is definitely not standard logic and should be outside the scope of a framework like Amplify’s purview. The post by @nathan-quinn is incredibly helpful. Just use that