Gathering detailed insights and metrics for @acusti/appsync-fetch
Gathering detailed insights and metrics for @acusti/appsync-fetch
Gathering detailed insights and metrics for @acusti/appsync-fetch
Gathering detailed insights and metrics for @acusti/appsync-fetch
UI toolkit monorepo containing a React component library, UI utilities, a drag-and-drop library, and more
npm install @acusti/appsync-fetch
Typescript
Module System
Node Version
NPM Version
TypeScript (90.85%)
MDX (3.3%)
JavaScript (3.14%)
CSS (2.71%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Unlicense License
8 Stars
1,367 Commits
2 Watchers
14 Branches
1 Contributors
Updated on Jul 01, 2025
Latest Version
0.18.0
Package Id
@acusti/appsync-fetch@0.18.0
Unpacked Size
12.24 kB
Size
4.34 kB
File Count
5
NPM Version
10.9.2
Node Version
23.11.0
Published on
Jun 01, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
5
appsync-fetch
is a lightweight node.js module that uses @acusti/post
to make requests to an AWS AppSync graphql API. It expands on
@acusti/post’s API with an optional third argument for passing in AWS
credentials, as well as the region. If AWS credentials aren’t provided, it
uses the same algorithm as @aws-sdk/credential-providers
’s fromEnv
helper to get credentials from the standard AWS environment
variables made available in lambdas. It then uses those credentials to
construct the appropriate AWS SigV4 authorization headers for IAM-based
authorization.
There are two primary reasons it’s worth using:
http
/https
modules for fetching (via
@acusti/post) and on the native node.js crypto
module for its
cryptographic logic; this makes it way lighter weight than alternatives
and results in faster start times in your lambdasnpm install @acusti/appsync-fetch
# or
yarn add @acusti/appsync-fetch
The package exports appsyncFetch
, a function that takes similar arguments
to window.fetch
(note that method
is always POST
) and returns a
promise. The promise is resolved with the parsed JSON version of the
request’s response (i.e. return await response.json()
when using the
Fetch API), because that’s what you wanted anyways. It also sets all
required headers, including AWS authorization headers, a Date header, and
Content-Type.
In addition, the second argument can take a query
property (string) and a
variables
property (object), which it will JSON.stringify into a valid
GraphQL request body. You can also pass in body
as a string directly, but
if you pass in a query
, the body
will be overwritten (you will get a
type error in typescript if you try to pass both).
The function also takes an optional third argument where you can manually
pass in AWS credentials if you don’t wish to rely on the built-in
credentials handling, which will extract credentials from environment
variables via process.env
. Usage is illustrated in the code example
below.
And lastly, if the response is an error (4xx or 5xx), appsyncFetch
will
throw an Error object with the response HTTP error and message as the Error
object message and with the following additional properties:
Error.response
: the node.js response IncomingMessage
objectError.responseJSON
: if the response body can be parsed as JSON, the
JSON representation returned from calling JSON.parse()
on itError.responseText
: the response body as text1import { appsyncFetch } from '@acusti/appsync-fetch';
2
3const appsyncURL = 'https://_.appsync-api.us-west-2.amazonaws.com/graphql';
4
5// In its simplest usage, environment variables are used for authorization
6const itemsResult = await appsyncFetch(appsyncURL, {
7 query: `
8 query ListItems {
9 listItems {
10 items {
11 id
12 text
13 }
14 }
15 }`,
16});
17// itemsResult is the parsed JSON from the response, e.g.:
18// const response = await fetch(...);
19// const itemsResult = await response.json();
20
21// You can also pass in variables
22const createdItemResult = await appsyncFetch(appsyncURL, {
23 query: `
24 mutation CreateItem($input: CreateItemInput!) {
25 createItem(input: $input) {
26 id
27 }
28 }`,
29 variables: {
30 input: {
31 text: 'Here is the text of a new item',
32 },
33 },
34});
35
36// You can also provide the authentication variables manually
37const manualAuthenticationResult = await appsyncFetch(
38 appsyncURL,
39 { query: 'query {...}' },
40 {
41 accessKeyId,
42 secretAccessKey,
43 sessionToken,
44 },
45);
You can pass in the expected data
result from the GraphQL query as a
generic to appsyncFetch
. This works very well with the codegen GraphQL
API types provided by AWS amplify:
1import { ListItemsQuery } from 'API'; 2 3const itemsResult = await appsyncFetch<ListItemsQuery>(appsyncURL, { 4 query: ` 5 query ListItems { 6 listItems { 7 items { 8 id 9 text 10 } 11 } 12 }`, 13});
The type of itemsResult
will be
{ data?: ListItemsQuery, errors?: GraphQLResponseError[] }
, where
GraphQLResponseError
is the shape of GraphQL errors returned by appsync
as illustrated in the docs.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More