Closed fzy-github closed 1 year ago
I've cross-posted the same question to AWSAppSyncClient team as it is not clear to me who should be responsible for answering/integrating it: https://github.com/awslabs/aws-mobile-appsync-sdk-ios/issues/550
I do not think you can use API.swift
with Amplify Datastore plugin. You need to run amplify codegen models
that will generate the required models that can be used int Amplify Datastore. More details are here - https://docs.amplify.aws/lib/datastore/getting-started/q/platform/ios/#code-generation-platform-integration .
It does not generate anything. Here's the amplify status
output that suggests that I have api configured (which is correct I think as I added that api via amplify add codegen --apiId xyz
):
$ amplify status
╭────────────────────────────────────────────────────────────╮
│ │
│ Update available: │
│ Run amplify upgrade for the latest features and fixes! │
│ │
╰────────────────────────────────────────────────────────────╯
Current Environment: dev
┌──────────┬───────────────┬───────────┬─────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
├──────────┼───────────────┼───────────┼─────────────────┤
│ Api │ MY-API-123 │ No Change │ │
└──────────┴───────────────┴───────────┴─────────────────┘
GraphQL endpoint: https://my-api-123url.appsync-api.us-west-2.amazonaws.com/graphql
GraphQL transformer version: 2
and after running amplify codegen models
I get this:
$ amplify codegen models
No AppSync API configured. Please add an API
Updating Xcode project:
🚫 folderNotFound: Amplify generated models not found at /PATH-TO-MY-PROJECT/amplify/generated/models
-- Recovery suggestion: Run amplify codegen models.
Hey, I was just wondering if there is any update on the above
Did you ever get this resolved @fzy-spyro? Hitting the same "No AppSync API configured. Please add an API" issue when trying to run amplify codegen models
for an existing AppSync API that I believe I've configured properly after running amplify status
.
@r-token Unfortuantely no, still having the same issue with that particular setup.
What I did instead is moved away from "pure" AppSync which was generating API.swift
file and started using Amplify DataStore instead and then the codegen works. Sadly this is not ideal though because not everyone can do that kind of transition and it would be great if using DataStore with AwsAppSyncClient was supported.
Hi @fzy-spyro, if you want to use DataStore, you would need to use amplify add api
and provide your schema. We do not have an import flow for API plugin yet. The amplify add codegen --apiId ABCD
command works for any AppSync API but is intended to be used only for statements and frontend types generation and not with DataStore.
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 generatesAPI.swift
file. After looking intoAPI.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 thisAPI.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.