Describe the bug
When using mock, it doesn't appear that custom resolvers in the resolvers directory are "seen" by the tool.
Receive an error (screenshot below):
GraphQL schema compiled successfully.
Edit your schema at /Users/mwarger/dev/projects/conference-app-in-a-box/amplify/backend/api/rnconfinabox/schema.graphql or place .graphql files in a directory at /Users/mwarger/dev/projects/conference-app-in-a-box/amplify/backend/api/rnconfinabox/schema
Creating table TalkTable locally
Creating table CommentTable locally
Creating table ReportTable locally
Failed to start API Mock endpoint Error: Invalid config for UNIT_RESOLVER {"dataSourceName":"CommentTable","typeName":"Query","fieldName":"listCommentsByTalkId","requestMappingTemplateLocation":"resolvers/Query.listCommentsByTalkId.req.vtl","responseMappingTemplateLocation":"resolvers/Query.listCommentsByTalkId.res.vtl","kind":"UNIT"}
Missing mapping template resolvers/Query.listCommentsByTalkId.req.vtl
To Reproduce
Steps to reproduce the behavior:
amplify init
amplify mock
Expected behavior
It should work.
Screenshots
Before mock:
After mock:
Error:
Desktop (please complete the following information):
Hey, I just tested this and it works, but in a brand new project.
I'm wondering if there is some sort of conflict in a project that has already been deployed. Is this in a project with a live API, or is this completely local?
This happens if you have a custom resource stack. Mock serve is not parsing the custom stack and is missing the resource created by it
Hey, I just tested this and it works, but in a brand new project.
I'm wondering if there is some sort of conflict in a project that has already been deployed. Is this in a project with a live API, or is this completely local?
This was a new project. I will change accounts to make sure I don't have anything existing.
This happens if you have a custom resource stack. Mock serve is not parsing the custom stack and is missing the resource created by it
@yuth are you saying you were able to reproduce this?
Yes. I could reproduce this. conference-app-in-a-box has a schema has custom query
type Query {
listCommentsByTalkId(talkId: ID!): ModelCommentConnection
}
For this custom query, it uses CustomResources.json
stack to create the resolver and inserts the required mapping template in resolvers
folder. Mock server did not look at either the custom stack or did not honor existing resolver which were not created by GraphQL transformer
I am working on a fix for this.
I think I misunderstood this initially. I was also now able to reproduce after cloning the project. Previously I was unable to reproduce because I was in a new project.
Steps to reproduce:
~ git clone https://github.com/dabit3/conference-app-in-a-box.git
amplify init
amplify mock api
Most helpful comment
Yes. I could reproduce this. conference-app-in-a-box has a schema has custom query
For this custom query, it uses
CustomResources.json
stack to create the resolver and inserts the required mapping template inresolvers
folder. Mock server did not look at either the custom stack or did not honor existing resolver which were not created by GraphQL transformerI am working on a fix for this.