I have been trying to deploy a backend api service made with graphql api and express to Amazon web services. This is my folder structure
Graphql-api
-src
-index.js
-serverless.yml
-index.js(this only contains an import statement of the src folder)
The serverless.yml looks like this
service: graphql-api
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221
functions:
api:
handler: src/index.handler
events:
- http:
path: graphql
method: ANY
cors: true
And I have exported this handler in my src/index.js file
`const awsServerlessExpress = require('aws-serverless-express');
const app = require('./app');
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context);`
But when I run serverless deploy and get the endpoint url which is: https://nir4749aal.execute-api.us-east-1.amazonaws.com/dev/graphql I get a message saying internal server error. I can't figure out what I am doing wrong. This is my first time trying to deploy to AWS. Any help or suggestion would help thanks in advance.
-----UPDATE-------- This are the logs from lambda
{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Cannot use import statement outside a module",
"stack": [
"Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",
" at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1015:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)",
" at Module.load (internal/modules/cjs/loader.js:879:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}