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

Unable to fetch graphQL list whenever app coming to foreground from background. #3794

Open
Santosh2332 opened this issue Jul 28, 2024 · 3 comments
Labels
api Issues related to the API category bug Something isn't working

Comments

@Santosh2332
Copy link

Santosh2332 commented Jul 28, 2024

Describe the bug

I configured amplify successfully, where fetching list of data successfully, Auth type is API_KEY.
but whenever app is going into background and coming to foreground either list is empty or getting error-1005 network connection lost.

The code i implemented is:

       let amplifyModel = UserSession.keys
       let predicate = amplifyModel.email == email
       let limit = (isFromBackground) ? 1 : 1000
       
       let request = GraphQLRequest<UserSession>.list(UserSession.self, where: predicate, limit: limit)
       Task {
           do {
               let result = try await Amplify.API.query(request: request)
               switch result {
               case .success(let data):
                   print("Successfully retrieved list of data: \(data.count)")
               case .failure(let error):
                   print("Got failed result with \(error.errorDescription)")
               }
           } catch let error as APIError {
               print("Failed to query list of amplify model: ", error)
           } catch {
               print("Unexpected error: \(error)")
           }
       }

Steps To Reproduce

Steps to reproduce the behavior:
1. Run the app
2. then go to background 
3. wait for some time come again to foreground
4. and fetch the data

Expected behavior

Like when app is in active state, and functionality working fine.
Similerly after coming back to foreground the list of data should be fetched successfully

Amplify Framework Version

2.2

Amplify Categories

API

Dependency manager

Swift PM

Swift version

Swift 5.2

CLI version

12.12.4

Xcode version

14.2

Is this a regression?

Yes

Regression additional context

No response

Platforms

iOS

OS Version

15.2

Device

iPhone XR

Specific to simulators

No response

Additional context

No response

@ruisebas ruisebas added bug Something isn't working api Issues related to the API category labels Jul 29, 2024
@ruisebas
Copy link
Member

Thanks for opening this issue.

You mentioned you're using Amplify 2.2.0, is that correct?
That version was released in Dec 2022, please update to the latest one as there's been significant bug fixes since then.

@ruisebas ruisebas added the pending-community-response Issue is pending response from the issue requestor label Jul 29, 2024
@Santosh2332
Copy link
Author

Hi @ruisebas Thank you for reply.

Amplify version 2.33.7 also getting same result, if limit is 1 (if limit 10 then data fetched in the list)

@github-actions github-actions bot removed the pending-community-response Issue is pending response from the issue requestor label Jul 30, 2024
@5d
Copy link
Member

5d commented Jul 31, 2024

Hi @Santosh2332 ,

With the latest Amplify version (2.33.7), could you please provide us with the verbose log, ensuring that any sensitive information is properly redacted or obscured?

You can enable verbose logging to the console by doing this before calling Amplify.configure:

Amplify.Logging.logLevel = .verbose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API category bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants