aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.83k stars 822 forks source link

Export app sync in lambda layer #12634

Closed yegenpres closed 1 year ago

yegenpres commented 1 year ago

Before opening, please confirm:

Language and Async Model

Kotlin

Amplify Categories

GraphQL API

Gradle script dependencies

```groovy // Put output below this line ```

Environment information

``` # Put output below this line ```

Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/guides/functions/appsync-operations-to-lambda-layer/q/platform/android/#set-up-your-layer

Describe the bug

I follow all steps in docs many times in different project generated on CLI or Console, also try Ios and Android projects and receive the same result.

after this command: npm run updateAppsyncOperations

I did not receive generated js files in opt directory of lambda layer. Instead received schemes GraphQL in src.main directory of Android app.

Folloved guide I placed script in ./package.json file: "scripts": { "updateAppsyncOperations": "amplify api gql-compile && amplify codegen && babel src/graphql --config-file ./babel.config.json -d ./amplify/backend/function/testawsapappsyncOperations/opt/graphql/" }

and made ./babel.config.jsom : { "presets": [ [ "@babel/env", { "targets": { "node": "12" } } ] ] }

that is my console output: ✅ GraphQL schema compiled successfully.

Edit your schema at ./testProjects/kmm_app/testAwsAnd/amplify/backend/api/testawsap/schema.graphql or place .graphql files in a directory at ./testProjects/kmm_app/testAwsAnd/amplify/backend/api/testawsap/schema ✔ Generated GraphQL operations successfully and saved at src/main/graphql/com/amazonaws/amplify/generated/graphql babel: src/graphql does not exist

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

amplifyconfiguration.json

No response

GraphQL Schema

```graphql // Put your schema below this line type Todo @model { id: ID! name: String! description: String } ```

Additional information and screenshots

No response

tylerjroach commented 1 year ago

Hi @yegenpres I have transferred this issue to the CLI repo, as it appears that this issue may be more CLI related, than Android specific.

josefaidt commented 1 year ago

Hey @yegenpres :wave: thanks for raising this! If you have modified your Node.js package to ESM by specifying "type": "module" in your package.json you can simply copy the generated codegen files to the relevant Lambda layer. If you are using CommonJS (i.e. with require) you can continue to use the suggested Babel path and modify the npm script to read from src/main/graphql

josefaidt commented 1 year ago

Closing due to inactivity

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.