Search code examples
amazon-web-servicesaws-lambdaaws-amplifyaws-appsyncaws-lambda-layers

Appsync operations Lambda Layer tutorial issue


I am following the tutorial from AWS here: Functions - Exporting AppSync operations to a Lambda layer for easy reuse - JavaScript - AWS Amplify Docs to create a Lambda Layer for my AppSync graphql operations to use in other Lambda functions.

In following the tutorial, when I get to the part of running the codegen from the script in packages.json, it runs through but finishes with the message:

Successfully compiled 0 files with Babel (9ms)

It looks like everything is pointing to the correct locations. I have also tried specifying extensions in my the script command for babel. Here is my script added to packages:

"updateAppsyncOperations": "amplify api gql-compile && amplify codegen && babel src/graphql --config-file ./babel.config.json -d ./amplify/backend/function/my_function_name/opt/graphql/"

where my_function_name is the name of the Lambda Layer function.

Has anyone run though this tutorial and got this to work successfully? I cannot figure out why it is not adding my mutations.js, queries.js and subscriptions.js to the Lambda Layer graphql folder.


Solution

  • If anyone else runs into this issue, the problem was that my codegen settings for my angular project were generating .graphql files, which is correct. Babel could not compile and copy those, so I had to first change the codeGenTarget: angular

    to codeGenTarget: javascript in my .graphqlconfig.yml

    After I made that change, the codegen generates the operations in javascript which will then be copied over. After that I have to change it back to generate for angular. Not the best solution but I am not sure what else to try.