Describe the bug
When I run amplify mock
it sets up the storage and creates the tables properly. It tells me that elastic search is not supported but then i get the following error:
Failed to start API Mock endpoint Error: Invalid config for UNIT_RESOLVER {"dataSourceName":"ElasticSearchDataSource","typeName":"Query","fieldName":"searchAccounts","requestMappingTemplateLocation":"resolvers/Query.searchAccounts.req.vtl","responseMappingTemplateLocation":"resolvers/Query.searchAccounts.res.vtl","kind":"UNIT"}
Missing data source ElasticSearchDataSource
Can mock
bypass this error so that I can at least use the other features?
To Reproduce
Steps to reproduce the behavior:
@searchable
on at least one objectamplify mock
Expected behavior
Not get an error and be able to use mock.
Desktop (please complete the following information):
Additional context
My graphql transform compiles without errors via CLI and amplify console.
I still have this issue, see my comment here:
https://github.com/aws-amplify/amplify-cli/pull/1999#issuecomment-525882093
@rpostulart could you share a minimal project where we can reproduce this issue
Of course what do you need? At least here is my scheme:
type Event @model @searchable{
id: ID!
date: String!
polygon: Location
subscribers: [EventSubscribers] @connection(name: "EventEvent")
eventOwner: Subscriber! @connection
name: String!
description: String
coordinates: [Coordinate]
planned: Boolean
}
type EventSubscribers @model(queries: null){
id: ID!
event: Event! @connection(name: "EventEvent")
subscriber: Subscriber! @connection(name: "EventSubscriber")
createdAt: String
}
type Subscriber @model @searchable{
id: ID!
name: String
email: String
phone: String
device: String
addressLocation: Location
address: String
complete: Boolean
events: [EventSubscribers] @connection(name: "EventSubscriber")
planning: [Planning] @connection(name: "SubscriberPlanning")
}
type Planning @model{
id: ID!
event: Event
subscriber: Subscriber @connection(name: "SubscriberPlanning")
location: Location
type: String
time: String
notificationSend: Boolean
}
type Location {
type: String
coordinates: [[[Float]]]
}
type Coordinate{
longitude: Float
latitude: Float
}
input LocationInput {
type: String
coordinates: [[[Float]]]
}
type EventConnection {
items: [Event]
total: Int
nextToken: String
}
input PointInput {
type: String
coordinates: [Float]
}
type Query {
nearbyEvent(location: PointInput!): EventConnection
}
type Mutation {
sendNotification(input: NotificationInput): NotificationResult @function(name: "sendNotifications-${env}")
}
type NotificationResult {
result: String
}
input NotificationInput {
action: String
data: String
}
same here with simple lambda as source:
Node: v10.16.3
/api
/resolvers
Query.echo.req.vtl
Query.echo.res.vtl
/stacks
CustomResources.json
schema.graphql
schema.graphql:
type Query {
echo(msg: String): String
}
CustomResources.json:
.
.
.
"QueryEchoResolver": {
"Type": "AWS::AppSync::Resolver",
"Properties": {
"ApiId": {
"Ref": "AppSyncApiId"
},
"DataSourceName": {
"Fn::GetAtt": [
"proxyGraphQLLambdaDataSource",
"Name"
]
},
"TypeName": "Query",
"FieldName": "echo",
"RequestMappingTemplateS3Location": {
"Fn::Sub": [
"s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Query.echo.req.vtl",
{
"S3DeploymentBucket": {
"Ref": "S3DeploymentBucket"
},
"S3DeploymentRootKey": {
"Ref": "S3DeploymentRootKey"
}
}
]
},
"ResponseMappingTemplateS3Location": {
"Fn::Sub": [
"s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Query.echo.res.vtl",
{
"S3DeploymentBucket": {
"Ref": "S3DeploymentBucket"
},
"S3DeploymentRootKey": {
"Ref": "S3DeploymentRootKey"
}
}
]
}
}
}
,
,
,
Query.echo.req.vtl:
{
"version": "2017-02-28",
"operation": "Invoke",
"payload": {
"type": "Query",
"field": "echo",
"arguments": $utils.toJson($context.arguments),
"identity": $utils.toJson($context.identity),
"source": $utils.toJson($context.source)
}
}
amplify mock
Failed to start API Mock endpoint Error: Invalid config for UNIT_RESOLVER {"dataSourceName":"proxyGraphQLLambda","typeName":"Query","fieldName":"echo","requestMappingTemplateLocation":"resolvers/Query.echo.req.vtl","responseMappingTemplateLocation":"resolvers/Query
.echo.res.vtl","kind":"UNIT"}
Missing mapping template resolvers/Query.echo.req.vtl
If it can be useful I add that I run "amplify mock" from Windows 10.
From the error we see that the template is searched in the path as:
"Resolvers / Query.echo.req.vtl"
to notice instead that the path of Windows is with backslash:
"Resolvers \ Query.echo.req.vtl"
also, the resolvers folder in build/ is empty
Is there any update on this?
"QueryEchoResolver": { "Type": "AWS::AppSync::Resolver", "Properties": { "ApiId": { "Ref": "AppSyncApiId" }, "DataSourceName": { "Fn::GetAtt": [ "proxyGraphQLLambdaDataSource", "Name" ] }, "TypeName": "Query", "FieldName": "echo", "RequestMappingTemplateS3Location": { "Fn::Sub": [ "s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Query.echo.req.vtl", { "S3DeploymentBucket": { "Ref": "S3DeploymentBucket" }, "S3DeploymentRootKey": { "Ref": "S3DeploymentRootKey" } } ] }, "ResponseMappingTemplateS3Location": { "Fn::Sub": [ "s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Query.echo.res.vtl", { "S3DeploymentBucket": { "Ref": "S3DeploymentBucket" }, "S3DeploymentRootKey": { "Ref": "S3DeploymentRootKey" } } ] } } }
@federicopuntoni Where is proxyGraphQLLambdaDataSource
defined. Could you share the cloudformation template where this data source is defined
Also getting the same issue. I'm busy with the Amplify tutorial Part 1. I'm using the same settings as the example shows. However, the mock API fuction failed as shown below
$ amplify mock api
Failed to start API Mock endpoint Error: not found: java
@bugzbuks Amplify Mock needs Java to be installed in your computer to start DynamoDB local. Could you please install the latest version of Java and see if the issue gets resolved
@Yuth Java is installed and working.
Same issue:
"Failed to start API Mock endpoint Error: No AppSync API is added to the project"
I do have an API though as per:
$ amplify add codegen --apiId xxxxxxxxxxx
Gives response:
"Codegen support only one GraphQL API per project"
Also Java is installed and working.
I do have an API though as per:
$ amplify add codegen --apiId xxxxxxxxxxx
If you add an API to your project with --apiId
you can use that API only for codegen. Mock needs API to be provisioned in the project and does not work with externally provisioned API
Most helpful comment
If it can be useful I add that I run "amplify mock" from Windows 10.
From the error we see that the template is searched in the path as:
"Resolvers / Query.echo.req.vtl"
to notice instead that the path of Windows is with backslash:
"Resolvers \ Query.echo.req.vtl"