24
loading...
This website collects cookies to deliver better user experience
AWS AppSync is a fully managed service that makes it easy to develop GraphQL APIs by handling the heavy lifting of securely connecting to data sources like AWS DynamoDB, Lambda, and more. Adding caches to improve performance, subscriptions to support real-time updates, and client-side data stores that keep off-line clients in sync are just as easy. Once deployed, AWS AppSync automatically scales your GraphQL API execution engine up and down to meet API request volumes.
type Mutation {
# In this example, only users in the ManagerGroup can create tasks
createTask(
owner: String!,
title: String!,
taskStatus: String!,
description: String!
): Task
@aws_auth(cognito_groups: ["ManagerGroup"])
# Both Employees and Managers can update a task's status
updateTaskStatus(id: ID!, taskStatus: String!): Task
@aws_auth(cognito_groups: ["EmployeeGroup","ManagerGroup"])
updateTaskBody(id: ID!, title: String!, description: String!): Task
@aws_auth(cognito_groups: ["ManagerGroup"])
}
type Query {
# Users belonging to both EmployeesGroup and ManagerGroup can read a particular task
getTask(id: ID!): Task
@aws_auth(cognito_groups: ["EmployeeGroup","ManagerGroup"])
# Only Managers can list all the Tasks
allTasks(nextToken: String): TaskConnection
@aws_auth(cognito_groups: ["ManagerGroup"])
}
type Task {
id: ID!
owner: String!
title: String!
description: String!
taskStatus: String
}
type TaskConnection {
items: [Task]
nextToken: String
}
schema {
query: Query
mutation: Mutation
}
@aws_api_key
, @aws_iam
, @aws_cognito_user_pools
and @aws_oidc
.type Task @aws_cognito_user_pools{
id: ID!
owner: String!
title: String!
description: String!
taskStatus: String
}
@aws_auth
could be used with @aws_cognito_user_pools
to provide fine-grain access to users who belong to specific User Groups defined in the Cognito User Pool.type Query {
# Users belonging to both EmployeesGroup and ManagerGroup can read a particular task
getTask(id: ID!): Task
@aws_auth(cognito_groups: ["EmployeeGroup","ManagerGroup"])
# Only Managers can list all the Tasks
allTasks(nextToken: String): TaskConnection
@aws_auth(cognito_groups: ["ManagerGroup"])
}
getTask(id: ID!)
query can be invoked from the authenticated users who are part of EmployeeGroup and ManagerGroup whereas allTasks(nextToken: String)
query can be invoked from authenticated uysers who are part of only ManagerGroup in Congito User Pool.amplify add codegen
and amplify codegen
.$amplify add codegen --apiId xxxxxxxxxxxxxxxx
$amplify codegen
24