npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@middy-appsync/constructs

v0.1.5

Published

CDK constructs for middy-appsync

Downloads

633

Readme

@middy-appsync/constructs

CDK constructs that wire @middy-appsync/graphql resolvers into an AWS AppSync GraphqlApi.

npm install @middy-appsync/constructs @middy-appsync/graphql aws-cdk-lib constructs esbuild

Peer dependencies: @middy-appsync/graphql >= 0.1.4, esbuild >= 0.27.

MiddyAppsyncGraphQLResolvers

Creates one AppSync unit resolver per entry in resolvers, all bound to the Lambda data source you supply. The Lambda is expected to run appSyncGraphQLRouter, which dispatches each invocation to the matching resolver by typeName.fieldName.

Props

| Prop | Type | Required | Description | | ------------------------ | --------------------------------- | -------- | ----------------------------------------------------------------------------------- | | api | IGraphqlApi | Yes | The AppSync GraphQL API the resolvers attach to. | | resolvers | AnyResolver[] | Yes | Resolver array from @middy-appsync/graphql (defineResolvers / query / …). | | dataSource | LambdaDataSource | Yes | Lambda data source for the function that runs appSyncGraphQLRouter. | | additionalDataSources | Record<string, BaseDataSource>? | No | Advanced — additional data sources referenced by custom resolver templates. | | templateSource | string \| string[]? | No | Advanced — paths to TS resolver templates ({typeName}.{fieldName}.ts) to bundle. |

Usage

import * as path from "node:path";
import { fileURLToPath } from "node:url";
import { Duration, Expiration, Stack } from "aws-cdk-lib";
import { AuthorizationType, Definition, GraphqlApi } from "aws-cdk-lib/aws-appsync";
import { Runtime } from "aws-cdk-lib/aws-lambda";
import { NodejsFunction, OutputFormat } from "aws-cdk-lib/aws-lambda-nodejs";
import { MiddyAppsyncGraphQLResolvers } from "@middy-appsync/constructs";
import { resolvers } from "../../src/resolvers";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export class ExampleStack extends Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const handler = new NodejsFunction(this, "ResolverHandler", {
      runtime: Runtime.NODEJS_24_X,
      entry: path.join(__dirname, "../../src/lambda/execute.ts"),
      handler: "handler",
      bundling: { format: OutputFormat.ESM, target: "node24" },
    });

    const api = new GraphqlApi(this, "Api", {
      name: "MiddyAppsyncExample",
      definition: Definition.fromFile(path.join(__dirname, "../../src/schema/schema.graphql")),
      authorizationConfig: {
        defaultAuthorization: {
          authorizationType: AuthorizationType.API_KEY,
          apiKeyConfig: { expires: Expiration.after(Duration.days(7)) },
        },
      },
    });

    const dataSource = api.addLambdaDataSource("LambdaDs", handler);

    new MiddyAppsyncGraphQLResolvers(this, "Resolvers", {
      api,
      resolvers: [...resolvers],
      dataSource,
    });
  }
}

The matching handler runs the router:

import middy from "@middy/core";
import { appSyncGraphQLRouter } from "@middy-appsync/graphql";
import { resolvers } from "../resolvers/index.js";

export const handler = middy(appSyncGraphQLRouter({ resolvers }));

Advanced

templateSource and additionalDataSources let you mix custom AppSync JS resolver templates and non-Lambda data sources (DynamoDB, HTTP, …) with the router-driven Lambda resolvers. Templates are TypeScript files named {typeName}.{fieldName}.ts; @datasource <name> and @pipeline <fn1>, <fn2> JSDoc tags pick the data source and (optionally) the pipeline functions for each entry. This surface is still evolving — see packages/constructs/src/graphql/construct.ts until it's covered by an example.

Example

A complete CDK stack using this construct is in examples/graphql/.

License

MIT