Austin Robinson
Austin Robinson

Reputation: 105

AWS Amplify GraphQL authorization based on field values

I have an AWS Amplify project that has three different user groups in Cognito. An Admin, Instructor, and Student group. I also have a GraphQL Schema that looks like this.

type DriveTime @model {
  id: ID!
  start: AWSDateTime!
  end: AWSDateTime!
  openRegistration: AWSDateTime!
  closeRegistration: AWSDateTime!
  vehicle: Vehicle @connection(name: "VehicleDriveConnection")
  instructor: Instructor @connection(name: "InstructorDriveConnection")
  student: Student @connection(name: "StudentDriveConnection")
  evaluation: DriveEvaluation @connection(name: "DriveEvaluationConnection")
}

Basically Admins or Instructors put in times that the students can then register for.

I want to create authorization rules that allow for the following:

Is Amplify GraphQL @Auth capable of this?

Upvotes: 2

Views: 864

Answers (1)

Leon Africa
Leon Africa

Reputation: 619

Have a read through the documentation:

[1] https://docs.amplify.aws/cli/graphql-transformer/auth

[2] https://docs.amplify.aws/cli/graphql-transformer/directives#aws-appsync-provided-directives

[3] https://aws.amazon.com/blogs/mobile/graphql-security-appsync-amplify/

Some of your requirements may have no out the box support which means you may have to create custom logic- check out Lambda Resolvers: https://docs.amplify.aws/cli/graphql-transformer/function#usage

Upvotes: 0

Related Questions