export const meta = {
  title: `GraphQL transform and Storage`,
  description: `The GraphQL Transform, Amplify CLI, and Amplify Library make it simple to add complex object support with Amazon S3 to an application.`
};

The GraphQL Transform, Amplify CLI, and Amplify Library make it simple to add complex object support with Amazon S3 to an application.

<Callout>

This documentation references the AWS AppSync SDK for JavaScript (V2), which is now in Maintenance mode. Please refer to the [Upgrade Guide](/lib/graphqlapi/upgrade-guide) and the [Working with Files](/lib/graphqlapi/working-with-files/) guide for updated guidance.

</Callout>


<Callout warning>

  Note: Complex objects are not supported by DataStore-enabled GraphQL APIs.
  
</Callout>

### Basics

At a minimum the steps to add S3 Object support are as follows:

**Create a Amazon S3 bucket to hold files via `amplify add storage`.**

**Create a user pool in Amazon Cognito User Pools via `amplify add auth`.**

**Create a GraphQL API via `amplify add api` and add the following type definition:**

```graphql
type S3Object {
  bucket: String!
  region: String!
  key: String!
}
```

**Reference the S3Object type from some `@model` type:**

```graphql
type Picture @model @auth(rules: [{ allow: owner }]) {
  id: ID!
  name: String
  owner: String

  # Reference the S3Object type from a field.
  file: S3Object
}
```

The GraphQL Transform handles creating the relevant input types and will store pointers to S3 objects in Amazon DynamoDB. The AppSync SDKs and Amplify library handle uploading the files to S3 transparently.

**Run a mutation with S3 objects from your client app:**

```graphql
mutation($input: CreatePictureInput!) {
  createPicture(input: $input) {
    id
    name
    visibility
    owner
    createdAt
    file {
      region
      bucket
      key
    }
  }
}
```
