I've created a custom query and custom resolvers for the query. The query is added to the schema.graphql and the resolvers were added to the resolvers directory. This is what it looks like when compiled:
$ find . -name Query.getProductByName.*.vtl
./amplify/#current-cloud-backend/api/mybackend/resolvers/Query.getProductByName.req.vtl
./amplify/#current-cloud-backend/api/mybackend/resolvers/Query.getProductByName.res.vtl
./amplify/#current-cloud-backend/api/mybackend/build/resolvers/Query.getProductByName.req.vtl
./amplify/#current-cloud-backend/api/mybackend/build/resolvers/Query.getProductByName.res.vtl
./amplify/backend/api/mybackend/resolvers/Query.getProductByName.req.vtl
./amplify/backend/api/mybackend/resolvers/Query.getProductByName.res.vtl
./amplify/backend/api/mybackend/build/resolvers/Query.getProductByName.req.vtl
./amplify/backend/api/mybackend/build/resolvers/Query.getProductByName.res.vtl
Looks good to me (although I don't know what the #current-cloud-backend is used for)
If I modify a custom resolver and run amplify status, I get Operation: Update, as expected.
I only modify the files under ./amplify/backend/api/mybackend/resolvers (never in the build directory)
However amplify push (answering yes on all the "do you want to"-questions) does not push my resolvers to the cloud. The custom query is there but no resolvers attached.
Amplify version: 3.11.0
Am I missing something or is this a bug? If so, any workaround? Thanks
@onerider you can find some information about what files and directories the CLI creates and what is their purpose here: https://aws-amplify.github.io/docs/cli-toolchain/usage#amplify-cli-artifacts
About custom resolvers here: https://aws-amplify.github.io/docs/cli-toolchain/graphql#custom-resolvers
You are using the right directory to put your resolvers into, please check if are there any steps you are missing what is in the docs.
Did you add your resolvers to the CustomResources.json file, since that is the "glue" between your resolvers and the GraphQL API you're deploying.
@attilah
Thank's for such a fast reply! Your guess was correct, I had missed the "glue" part completely. Problem solved!
@onerider I'm closing the issue as it was answered, if anything else comes up, reopen this one or feel free to open a new one.
@attilah is there any reason that the CLI could not scan for custom resolvers (besides those that override Amp-generated resolvers) and inject them plus relevant parameters into the CustomResources.json stack? I can see a lot of edge cases but you can refine it a lot by adding some reasonable constraints and not trying to support every resolver case.