awslabs / aws-mobile-appsync-sdk-ios

iOS SDK for AWS AppSync.
https://awslabs.github.io/aws-mobile-appsync-sdk-ios/
Other
262 stars 130 forks source link

Using AWSAppSync with Amplify DataStore #550

Closed fzy-github closed 11 months ago

fzy-github commented 2 years ago

State your question 
Hello, 
 

I am creating mobile application that is supposed to use existing resources on AWS servers (Cognito, AppSync with GraphQL, etc). 

As all backend resources are already created and ready, I decided to use Amplify iOS library to connect to them and followed https://docs.amplify.aws/lib/auth/existing-resources/q/platform/ios/ instructions.
 

 
I’ve configured the app to use library via SPM and implemented auth using Cognito and I am able to perform all sign-in/signup operations without issues. 
 


Now I am adding support for backend storage via AppSync and I’d like to be able to use DataStore for offline mode. 

When looking into AWS AppSync console it tells me to integrate it via: amplify add codegen --apiId ABCD command which generates API.swift file. 



After looking into API.swift file contents I see that is uses https://github.com/awslabs/aws-mobile-appsync-sdk-ios which seems to not be a part of Amplify SDK and does not look like it is compatible with DataStore. 

 


 


This leads me to a question - how can I use existing AppSync GraphQL API (generated in this API.swift file) with Amplify DataStore? Is there a way to somehow import existing GraphQL schema into Amplify app and use it with DataStore? If so, how can this be achieved? 


 


 


What I tried so far is to use https://github.com/awslabs/aws-mobile-appsync-sdk-ios (integrated via SPM) to talk to GraphQL and it works but from what I see is that it does not support offline mode which I need in my app. 


 
Provide code snippets (if applicable) N/A

Environment(please complete the following information):

Device Information (please complete the following information):

For reference - I posted simillar question to amplify project as it is not clear to me who would be responsible for this: https://github.com/aws-amplify/amplify-ios/issues/2395

fzy-github commented 1 year ago

Hey, any update on this?

royjit commented 1 year ago

Hi @fzy-spyro If you are connecting to Appsync using Amplify you can generate the models using amplify codgen models command. You can follow the steps mentioned here - https://docs.amplify.aws/lib-v1/datastore/getting-started/q/platform/ios/#code-generation-platform-integration

pzmudzinski commented 1 year ago

@royjit What about custom queries and mutations inside schema.graphql?

fzy-github commented 1 year ago

@royjit If I remember correctly I tried this as well and it didn't work. Due to this issue we have decided to move away from AppSync/DataStore integration. When I have time I will try to set up ne project and share it here reproducing the issue

atierian commented 11 months ago

Thank you for opening this issue. AWS AppSync SDK for iOS entered maintenance mode in September 2023 and will receive no further updates as of September 2024.

Please use Amplify Swift going forward. For information on upgrading to Amplify Swift, refer to the Upgrade from AppSync SDK documentation.