Comments (5)
Thank you posting this issue - our team will investigate and post updates on this ticket.
from amplify-swift.
Hi @ip5038, I could not reproduce this issue, but as I was trying out the code snippet, I made a few changes to get it to work.
Task {
do
{
let model = MyModel.keys
let predicate = model.post_id == "1" && model.user_id == "1"
let request = GraphQLRequest<MyModel>.list(MyModel.self, where: predicate, limit: 1000)
let result = try await Amplify.API.query(request: request)
switch result {
case .success(let models): // query returns .success with empty list
if (models.count > 1) {
print("count \(models.count)")
}
print(models)
if models.hasNextPage() {
print("Has Next Page")
let nextPage = try await models.getNextPage()
} else {
print("No pages remaining")
}
case .failure(let error):
print(error)
}
}
catch let error
{
print("Error getting model by post and user id: \(error)")
}
}
- I noticed you used the coding key
model.self
instead ofMyModel.self
- this wasn't compiling for me, i assume this was already updated on your end - Added a few more print statements.
case .failure(let error)
is when there's a successful network request but categorized as a failure when there is a GraphQL errors array, partial data/errors response, or transformation (decoding) error. Is your code going into this line? - Added a check for hasNextPage(), this checks if the response contained the
nextToken
, used bygetNextPage()
for pagination. More details here https://docs.amplify.aws/gen1/swift/build-a-backend/graphqlapi/query-data/#list-subsequent-pages-of-items
In my amplify CLI project, i also have generatemodelsforlazyloadandcustomselectionset
set to true
before running amplify codegen models
.
from amplify-swift.
It's still not working for me.
- It never goes into the failure case. It always goes to success case with an empty list of items. There are also no next pages.
- I changed
generatemodelsforlazyloadandcustomselectionset
totrue
and re-ranamplify codegen models
then did clean build folder and reran the app, but still won't work.' - The entire do-catch block is in an async function.
- I have multiple other Amplify queries and they are
.get
queries that query on theid
field of the object. Those queries work fine. - If I pass in
post_id
that doesn't exist in dynamodDB, it still return.success
with empty list.
This amplify query works fine:
let result = try await Amplify.API.query(request: .get(AnotherModel.self, byId: "some_id"))
I have attached a screenshot of logs for the .list
query that doesn't work. Everything that is highlighted orange is from printf()
statements. Rest is from amplify logs
from amplify-swift.
The issue was in my logic. Query was returning only 1 item but my if-statement conditional check was if (count > 1)
which failed even though there was an item. Switching my logics to if (count >= 1)
fixed the issue.
Thank you for the help!
from amplify-swift.
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
from amplify-swift.
Related Issues (20)
- High Memoey leak HOT 4
- Amplify API Unathorized error Error HOT 29
- `HostedUIASWebAuthenticationSession.showHostedUI` never calls the continuation when `aswebAuthenticationSession.canStart` is false HOT 3
- Retrying signing challenge doesn't work HOT 5
- Gen2 Swift Codegen for one-to-one does not compile HOT 2
- Data Race - Thread Sanitizer HOT 4
- Amplify SwitUI - Auth Signout documentation error HOT 3
- Crash in save<Models> from DataStoreBaseBehavior HOT 3
- Amplify JSON Issue HOT 2
- Linker Error when using SPM dependency as a dynamic library HOT 13
- Crash on Amplify.add(plugin HOT 2
- Crash on AuthCategory.getCurrentUser() HOT 2
- Upload failure with error Amplify.StorageError error 7 HOT 13
- Logging happens when set to log level none HOT 3
- Old data not visible for some users HOT 19
- Fetch `ListIdentityProviders` Amplify using getEscapeHatch HOT 7
- All production users local data gets lost on DataStore migration HOT 6
- Crash on AppSyncRealTimeClient.monitorHeartBeats(_:) + 428 HOT 3
- Data not showing even though data is in datastore HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-swift.