This use case is a simple demo that shows how to create a GraphQL API using AWS AppSync and an Amazon Aurora Serverless database as the data source.
Change the values for the variables in the variables.tf file to customize the demo (for example, region, database name, etc.).
After the apply
command is run without errors, you should be able to access the API via
the AppSync console.
The console will show the URL for the GraphQL endpoint, which includes an API named roles-api
.
You can also access and invoke the API using the AWS CLI, the AWS SDKs, etc.
Example queries, mutations, and subscriptions to interact with the API:
mutation MyMutation1 {
createRole(id: "3", name: "ROLE NAME") {
id
name
description
}
updateRole(id: "3", name: "DUMMY_USER", description: "Dummy User") {
id
name
description
}
}
query Query {
listRoles {
id
name
description
}
}
mutation MyMutation2 {
deleteRole(id: "3") {
id
}
}
subscription MySubscription {
onDeleteRole {
id
name
description
}
}
The schema and resolvers for the API are defined in the schema file and resolvers directory, respectively.