Skip to content

Amplify.API.mutate or AWSAppSyncClient ? #1094

@cabeaulac

Description

@cabeaulac

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions