I am using serverless appsync plugin and deploying it to my aws account by following Part 03: AWS AppSync: Resolver Mapping Templates | Serverless Framework & AWS Amplify - YouTube.
I managed to get the initial resources deployed uisng cfn. however when deploying the graphql resources to create API, it is failing to save graphql schema.
error stack:
8c859063389c:backend jaydevn$ sls deploy
AppSync Plugin: GraphQl schema valid
Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.......................................
Serverless: Operation failed!
Serverless: View the full error output: https://eu-west-1.console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aeu-west-1%3A448567517997%3Astack%2Fserverless-appsync-backend-dev%2Fdfb8cb20-583a-11ec-b315-0a520f313c77
Serverless Error ----------------------------------------
An error occurred: GraphQlSchema - Schema Creation Status is FAILED with details: Internal Failure while saving the schema..
serverless.yml
service: serverless-appsync-backend
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221
stage: dev
region: us-east-1
resources:
Resources:
${file(resources.yml)}
plugins:
- serverless-appsync-plugin
custom:
appSync:
name: serverless-appsync-backend
# apiKey # only required for update-appsync/delete-appsync
# apiId # if provided, will update the specified API.
authenticationType: AMAZON_COGNITO_USER_POOLS
# if AMAZON_COGNITO_USER_POOLS
userPoolConfig:
awsRegion: us-east-1
defaultAction: ALLOW
userPoolId: !Ref cognitoUserPool
mappingTemplatesLocation: mapping_templates
mappingTemplates:
- dataSource: booksTable
type: Query
field: getBookById
- dataSource: booksTable
type: Mutation
field: createBook
dataSources:
- type: AMAZON_DYNAMODB
name: "booksTable"
description: "books ddb table"
config:
tableName: !Ref booksTable
schema.graphql
schema {
query: Query
mutation: Mutation
}
type Query {
getBookById(bookId: ID!): Book!
listBooks(limit: Int!, nextToken: String):BooksPage!
myOrders(limit: Int!, nextToken: String): OrderItemsPage!
}
type OrderItemsPage {
orderItems: [OrderItem]
nextToken: String
}
type OrderItem{
userId: ID!
orderId: ID!
book: Book!
quantity: Int!
}
type BooksPage{
books: [Book]
nextToken: String
}
type Book{
bookId: ID!
title: String!
description: String!
imageUrl: AWSURL
author: String!
price: Float!
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
type Mutation{
createBook(newBook: BookInput): Book! @aws_auth(cognito_groups: ["admin"])
createOrder(newOrder: OrderInput): Boolean!
}
type OrderInput{
items: [OrderItemsInput]
}
type OrderItemsInput{
bookId: ID!
quantity: Int!
}
type BookInput{
title: String!
description: String!
imageUrl: AWSURL
author: String!
price: Float!
}
I am unable to understand how should I resolve this. Thanks in advance!