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 🙏

© 2024 – Pkg Stats / Ryan Hefner

appsync-dev-server

v1.0.2

Published

AWS Appsync Locally with GraphQL Yoga or Apollo Server

Downloads

24

Readme

AWS AppSync GraphQL API Locally Mocking

Introduction

  • This project using GraphQL Yoga or Apollo Server to running AWS AppSync GraphQL API locally\
  • Your project lambdas resolver must be following format {typeName}/{fieldName}/index.(t|j)s
  • Lambda folder structure must be following:
├── lambdas
│   ├── Query
│   │   └── test
│   │       └── index.ts
└── server.ts

Installation

npm install --save-dev appsync-dev-server

or

yarn add --dev appsync-dev-server

Usage

// Apollo Server
import path from "path";
import { createApolloServer } from "appsync-dev-server";

const lambdaFolder = path.resolve(__dirname, "lambdas");
const graphqlFolder = path.resolve(__dirname, "graphql");

createApolloServer({
  port: 4000,
  graphqlDir: graphqlFolder,
  lambdaDir: lambdaFolder,
});

or

// GraphQL Yoga Server
import path from "path";
import { createYogaServer } from "appsync-dev-server";

const lambdaFolder = path.resolve(__dirname, "lambdas");
const graphqlFolder = path.resolve(__dirname, "graphql");

createYogaServer({
  port: 4000,
  graphqlDir: graphqlFolder,
  lambdaDir: lambdaFolder,
});

Option props

interface ICreateServerProps {
  port?: number; // default 4000
  path?: string; // default /graphql
  graphqlDir: string; // graphql schema file folder, required if you don't use typeDefs
  lambdaDir: string; // lambda resolver file folder, required if you don't use resolvers
  resolvers?: any; // custom resolvers
  typeDefs?: any; // custom typeDefs
}

Run with watch mode

tsc-watch --onSuccess \"ts-node --project ./dist/tsconfig.json -r tsconfig-paths/register ./dist/server.js\"

Path alias

If you want to use path alias, you can use tsconfig-paths to resolve it

npm install tsconfig-paths

then run server with ts-node and tsconfig-paths/register

ts-node --project examples/tsconfig.json -r tsconfig-paths/register examples/server.ts

Directives supported

  • @aws_api_key
  • @aws_cognito_user_pools
  • @aws_subscribe

Environment variables

You can use environment variables in your lambda resolver by .env file

USER_POOL_ID=
USER_POOL_CLIENT_ID=
...

Example

Issues

  • Project can't compatible with more than project structure, you can clone this project and modify it to fit your project structure
  • If you have any issues, please create new issue and describe your problem

Thank for using