Skip to content

Mono repo that contains examples of Ionic with GraphQL and Java data generation for DynamoDB Single Table.

License

Notifications You must be signed in to change notification settings

aosolorzano/ionic-dynamodb-single-table-example

Repository files navigation

What is it?

This project uses Amplify Framework to generate an AWS GraphQL API and a DynamoDB Single Table.

Detailed components' creation/modification

You can find more detail of the configurations and components coded in this project in the following post: Using the Single Table design on AWS DynamoDB.

Requirements

  1. An AWS account.
  2. Git.
  3. AWS CLI.
  4. Amplify CLI.
  5. OpenJDK 17. You can use SDK Man.
  6. Maven.

Configuring Amplify for your AWS account

First, you need to initialize the Ionic/Angular project in the frontend folder:

amplify configure
amplify init

The previous command ask you to select your AWS profile installed in your local machine to deploy infra in your AWS account and region.

NOTE: If the previous command shows that there is a new version of Amplify CLI, try to update it first and then install Amplify again:

amplify upgrade
sudo npm install -g @aws-amplify/cli

Configure GraphQL API

First, you need to configure the API integration for the app, selected GraphQL as desired one:

amplify add api

Then, you need to modify the amplify/backend/api/ionicdynamosingletbl/schema.graphql file adding the following content:

# This "input" configures a global authorization rule to enable public access to
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
input AMPLIFY { globalAuthRule: AuthRule = { allow: public } } # FOR TESTING ONLY!

type SingleTable @model(subscriptions: { level: off }, timestamps: null) {
  pk: ID! @primaryKey(sortKeyFields: ["sk"])
  sk: String!
  gsi1pk: ID! @index(name: "gsi1pk", sortKeyFields: ["gsi1sk"], queryField: "getItemByGSI")
  gsi1sk: String!
  location: LocationVO
  company: CompanyVO
  openPosition: OpenPositionVO
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime
}

type LocationVO {
  country: String!
  flagImageUrl: String!
}

type CompanyVO {
  city: String!
  name: String!
  industry: String!
  url: String!
}

type OpenPositionVO {
  title: String!
  seniority: String!
  field: String!
  skills: String!
}

This content creates a Single table on DynamoDB, and we will be using it to interact with our app.

Loading testing data

You can load initial data to test this app. If so, run the Java Faker project in the backend folder:

mvn clean package
java -jar target/java-faker-dynamodb-example.jar

Build and deploy the project locally

ionic build
ionic serve

About

Mono repo that contains examples of Ionic with GraphQL and Java data generation for DynamoDB Single Table.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published