Hey Prisma Team :wave: I'm following this guide (...
# orm-help
j
Hey Prisma Team 👋 I'm following this guide (https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-aws-lambda) to deploy my Prisma backend. I'm having trouble importing my resolvers and am seeing this error.
Copy code
import { NonEmptyArray } from "type-graphql";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (C:\Workspace\Stagewood-Test\server\handler.js:4:19)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
I think it has something to do with how I'm generating the resolvers to TypeScript and using it in the JS handler. This is what my handler.js looks like:
Copy code
const graphqlLambda = require('apollo-server-lambda');
const makeExecutableSchema = require('graphql-tools');
const importSchema = require('graphql-import');
const resolvers = require('./prisma/generated/type-graphql/index.ts');

const typeDefs = importSchema('./schema/schema.graphql')

const myGraphQLSchema = makeExecutableSchema({
  typeDefs: typeDefs,
  resolvers,
});

exports.graphqlHandler = function graphqlHandler(event, context, callback){
  function callbackWithHeaders(error, output) {
    output.headers['Access-Control-Allow-Origin'] = '*';
    callback(error, output);
  }
  const handler = graphqlLambda({schema: myGraphQLSchema });
  return handler(event, context, callbackWithHeaders)
}
Does anyone know how I can get this working on AWS or point me in the right direction?
l
Not obvious, but are you trying to use typescript from JS? That doesn't work, you must compile it to javascript first
👍 1
j
I used this (https://www.npmjs.com/package/typegraphql-prisma) generator that is used in this (prisma-examples/typegraphql) example from the Prisma GitHub All of my resolvers, models, etc. are typescript files. So, I'll just have to compile those to JS first before I try to deploy it to AWS?
r
Yes you would need to compile it first before deploying.