question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Amplify.API.mutate or AWSAppSyncClient ?

See original GitHub issue

Is your feature request related to a problem? Please describe. The documentation here: https://aws-amplify.github.io/docs/ios/start show using Amplify.API to access an API. The document here: https://aws-amplify.github.io/docs/cli-toolchain/graphql shows using AWSAppSyncClient

The two aren’t compatible as pod versions conflict. Podfile

  use_frameworks!
  # Pods for nike-athlete-ios
  pod 'amplify-tools'
  pod 'Amplify'
  pod 'AWSPluginsCore'
  pod 'AmplifyPlugins/AWSAPIPlugin'
  pod 'AWSMobileClient', '~> 2.12.0'      # Required dependency
  pod 'AWSAuthUI', '~> 2.12.0'            # Optional dependency required to use drop-in UI
  pod 'AWSUserPoolsSignIn', '~> 2.12.0'   # Optional dependency required to use drop-in UI
  # pod 'AWSAppSync', ' ~> 2.9.0'

If you add AWSAppSync you get this error

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "AWSCore":
  In snapshot (Podfile.lock):
    AWSCore (= 2.12.3)

  In Podfile:
    AWSAppSync (~> 2.9.0) was resolved to 2.9.2, which depends on
      AWSCore (~> 2.8.0)

    AWSAuthUI (~> 2.12.0) was resolved to 2.12.3, which depends on
      AWSCore (= 2.12.3)

Here is an example of an API schema using owner permissions with Cognito user pools auth.

type Profile @model
@auth (
  rules: [
    { allow: owner },
    { allow: private, operations: [create, read, update] }
  ]
)
{
  id: ID!
  email: String!
  firstname: String
  lastname: String
}

Notice there is no owner field in the API. Some documentation says to add it into the schema, some says the framework handles it for you.

Describe the solution you’d like What is the correct way to access the API endpoint? Amplify.API or AWSAppSyncClient? Do we need to add an owner field and how does Amplify.API populate it and use it during retrieval?

Describe alternatives you’ve considered Changing the app back to using AWSAppSyncClient but Amplify.API is easier to read.

Additional context Don’t know what the clear direction is here. Please help.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jamesonwilliamscommented, Apr 20, 2020

@lingxiao @jamesingham Looks like maybe you wanted me, @jamesonwilliams!

This is still a true statement as of 20APR2020, but we will be making an announcement “soon”.

At this time, the Amplify projects for iOS and Android are still in “Preview” (beta). As such, AWSAppSyncClient is the only suitable option for production interaction with an AppSync endpoint, at this time. When Amplify achieves a 1.0 release, Amplify.API.mutate would be the preferred mechanism for interacting with an AppSync endpoint.

1reaction
renebrandelcommented, Apr 22, 2020

I am trying to follow tutorial on https://aws-amplify.github.io/docs/ios/start and getting this error… appreciate any suggestions to resolve this, thanks.

Hi @ashishverma1108 - we have recently updated our documentation. Here’s the new iOS SDK getting started guide. https://docs.amplify.aws/start/q/integration/ios and here’s the iOS Amplify Libraries (preview) getting started guide: https://docs.amplify.aws/lib/getting-started/setup/q/platform/ios

Read more comments on GitHub >

github_iconTop Results From Across the Web

API (GraphQL) - Advanced Workflows - JavaScript
Learn more about advanced workflows in Amplify's API category ... These can be separate from the other auth credentials you use in your...
Read more >
Run Queries and Mutations - AWS AppSync
To do this, you use the mutation keyword and pass in the appropriate arguments ... you can choose to build an API from...
Read more >
How To Use AWS AppSync in Lambda Functions - Jan Hesters
I needed to find a way to use AppSync from Lambda. This guide covers how you can access your AppSync API from a...
Read more >
How to change AWS Amplify Appsync default authorization ...
Based on this documentation I ran amplify update api : From there the command line prompts you to select the API type:
Read more >
Amplify API - AppSync - CRUD (Create Read Update Delete)
No more no less. Mutation (CREATE UPDATE DELETE)#. Mutations in GraphQL are a way to change data on a server and get updated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found