gmoraleda
gmoraleda

Reputation: 1953

CDK and TS: Share types between GraphQL and Lambda

I'm working on a CDK project using TS. I'm relatively new to TS development. I wonder what's the best way to share my generated types from the GraphQL schema so that I can access them from my Lambdas.

I tried tsconfig.pahts, but it's pretty cumbersome. I've read about Lambda layers, but seem to be problematic as well. My current approach is to deploy everything to the Lambda (which isn't ideal either, but at least is easy to understand):

    // Lambda: ProductList
    this.productListLambda = new lambda.Function(this, "ProductListLambda", {
      runtime: lambda.Runtime.NODEJS_LATEST,
      handler: "lib/lambda/productList/productList.handler",
      code: lambda.Code.fromAsset(path.join(__dirname, "../dist")),
      environment: {
        PRODUCT_LIST_TABLE: props.productListTable.tableName,
      },
    });

My types are located at /lib/graphql/generated

Upvotes: 0

Views: 21

Answers (0)

Related Questions