amplify-swift
amplify-swift copied to clipboard
Using Amplify DataStore with AwsAppSync client
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 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.