Skip to content

skyhookadventure/appsync-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Appsync Client

Built with typescript version dependants license

A lightweight Appsync client that signs requests for you (using IAM permissions) - perfect for running on Lambdas or servers.

Queries are made using TypedDocumentNode which means that the variables and results will be automatically typed for you if using Typescript.

Use

import AppsyncClient from "appsync-client";

async function getTodo() {

    // Create a client
    const client = new AppsyncClient({
        // Required
        apiUrl: "https://xxx.appsync-api.xx-xxxx-x.amazonaws.com/graphql",
        // Optional - these will default to process.env values (e.g. the IAM
        // role of the Lambda)
        accessKeyId: "",
        secretAccessKey: "",
        sessionToken: ""
    });

    // Query for Todos
    const res = await client.request({
        // The typed document node query
        query: TypedDocumentNodeQuery,
        // Variables to replace (here we are replacing $id with "todoId")
        variables: {
            id: "todoId"
        }
    );
}

Checklist

CD Feature Provided
Typescript
Linting (AirBnB + Prettier)
Unit tests (Jest)
100% test coverage
Github Continuous Deployment

About

A lightweight Appsync client that signs requests for you - designed to be run server-side (e.g. on Lambdas)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published