amplify-swift/AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginFunctionalTests/GraphQLSyncBased
Michael Law 6d5a290cac
chore: APIHostApp for running APIPlugin integration tests (#2029)
* move to Sources and Tests for API

* update Package.swift

* Add APIHostApp, rename to drop Category naming

* APIHostApp compiling with AmplifyTestCommon files

* APIFunctional tets working

* add additional schemas

* Remove AWSPluginCore dependency

* revert unintended changes

* remove unintended changes

* remove unintented changes

* fix unintended changes

* fix unintended changes
2022-07-21 17:43:54 -04:00
..
GraphQLSyncBasedTests.swift chore: APIHostApp for running APIPlugin integration tests (#2029) 2022-07-21 17:43:54 -04:00
GraphQLSyncCustomPrimaryKeyTests.swift chore: APIHostApp for running APIPlugin integration tests (#2029) 2022-07-21 17:43:54 -04:00
README.md chore: APIHostApp for running APIPlugin integration tests (#2029) 2022-07-21 17:43:54 -04:00

README.md

Sync Based GraphQL

The following steps demonstrate how to set up an GraphQL endpoint with AppSync that is provisioned with conflict resolution (Sync-based API). The auth configured will be API key. The set up is used to run the tests in GraphQLSyncBasedTests.swift.

Set-up

  1. amplify init

  2. amplify add api

? Please select from one of the below mentioned services: `GraphQL`
? Provide API name: `<APIName>`
? Choose the default authorization type for the API `API key`
? Enter a description for the API key:
? After how many days from now the API key should expire (1-365): `365`
? Do you want to configure advanced settings for the GraphQL API `Yes, I want to make some additional changes.`
? Configure additional auth types? `No`
? Configure conflict detection? `Yes`
? Select the default resolution strategy `Optimistic Concurrency`
? Do you want to override default per model settings? `No`
? Do you have an annotated GraphQL schema? `Yes`
? Provide your schema file path: `schema.graphql`

When asked to provide the schema, create the schema.graphql file

enum PostStatus {
    PRIVATE
    DRAFT
    PUBLISHED
}

type Post @model {
    id: ID!
    title: String!
    content: String!
    createdAt: AWSDateTime!
    updatedAt: AWSDateTime
    draft: Boolean
    rating: Float
    status: PostStatus
    comments: [Comment] @connection(name: "PostComment")
}

type Comment @model {
    id: ID!
    content: String!
    createdAt: AWSDateTime!
    post: Post @connection(name: "PostComment")
}

type CustomerOrder @model
   @key(fields: ["orderId","id"]) {
   id: ID!
   orderId: String!
   email: String!
}
  1. amplify push

  2. Copy amplifyconfiguration.json over as GraphQLSyncBasedTests-amplifyconfiguration.json to ~/.aws-amplify/amplify-ios/testconfiguration/