0

I am using Typescript, ApolloServer, graphql, serverless, and Lambdas to build out my application. When running a sls offline start I am getting the following error:

offline: Failure: Cannot find module '/Users/aroe/Desktop/projects/test-serverless-backend/functions/graph/graphql'
Require stack:

Here is my serverless.yml config

service: gamitrak-backend # service name
provider:
  name: aws # deploy to AWS
  runtime: nodejs12.x
  versionFunctions: false # disable function versioning
  region: us-west-2 # AWS region
  apiGateway:
    shouldStartNameWithService: true

functions:
  graph:
    handler: /src/functions/graph/graphql.handler # Lambda handler path
    events:
      - http:
          path: graphql # define Lambda endpoint
          method: any # any HTTP method can access this Lambda
          cors: true # enable CORS
plugins:
  - serverless-offline

Under handler: we can see that it's trying to hit my function, here is that file when running a PWD command to show path

/Users/aroe/Desktop/projects/test-serverless-backend/src/functions/graph

Here is the actual meat of the code that's attempting to be hit:

import { ApolloServer, gql } from 'apollo-server-lambda';
import { usersTypeDefs, usersResolvers } from './schema/users';

// get the GraphQL schema

// resolver functions

const server = new ApolloServer({ typeDefs: usersTypeDefs, resolvers: usersResolvers });

// launch the server when the Lambda is called
export async function handler(_event: any, _context: any) {
  const handler = server.createHandler();
  console.log(handler);
  return handler;
}

My inclination is to think that it cannot hit the file for some reason? However, I am not sure why/how?

Here is all the version information for my stack in case it's relevant as to what serverless version I'm using.

Framework Core: 2.70.0 Plugin: 5.5.2 SDK: 4.3.0 Components: 3.18.1

Thank you all so much in advance!

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.