Absolute paths in lambda functions?

I am having a hard time deploying my lambda functions using Netlify. You can find my source code here. Everything works perfectly fine when I run it locally via ntl dev. However, once I deploy it, it appears the absolute paths to my files don’t seem to be right?

I am using path.join(__dirname) to get the absolute path from where I want to find my schema type files and resolvers like so. Again, everything works just fine locally but fails to find my files since once deployed since the path according to the logs point to var/task/src/lambda/types?

Below are the errors in the console:

5:54:28 PM: graphql invoked
5:54:28 PM: types dir: /var/task/src/lambda/types
5:54:28 PM: typeDefs: "schema {\n  query: Query\n}\n"
5:54:28 PM: {"errorMessage":"Unknown type \"Query\".","errorType":"Error","stackTrace":["assertValidSDL (/var/task/node_modules/graphql/validation/validate.js:108:11)","Object.buildASTSchema (/var/task/node_modules/graphql/utilities/buildASTSchema.js:71:34)","Object.buildSchemaFromTypeDefinitions (/var/task/node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js:23:28)","Object.makeExecutableSchema (/var/task/node_modules/graphql-tools/dist/makeExecutableSchema.js:26:29)","ApolloServer.initSchema (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:272:49)","new ApolloServerBase (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:202:30)","new ApolloServer (/var/task/node_modules/apollo-server-lambda/dist/ApolloServer.js:21:9)","Object.exports.initialize (/var/task/lib/apollo.js:21:18)","module.exports (/var/task/initializers/apollo.initializer.js:8:10)","Object.exports.run (/var/task/initializers/setup.js:4:3)"]}
XRAY TraceId: 1-5d7adab4-68fd15e0267321c011a9d000	SegmentId: 4e71066a7ddc4fa9	Sampled: false

Apollo craps out because it can’t find a valid Query type since it failed to find and load in my .graphql files.

Any ideas? I’m sure I am missing something obvious here but been banging my head :frowning_face:

I took a different approach in how to import my schema files to ensure they’re included in my bundled function and now my graphql endpoint works!

That’s great to hear, @codebuddies_admin!