Registry / api-clients / graphql-request-appsync-iam

graphql-request-appsync-iam

JSON →
library5.0.1jsnpmunverified

Extends graphql-request to sign requests for AWS AppSync GraphQL APIs using IAM authorization. Version 5.0.1 supports Node.js >=18 and graphql 14–16. It wraps the familiar graphql-request client interface, automatically computing the AWS Signature Version 4 signature for every request. Unlike alternative approaches that require manual signing or using the AWS Amplify client, this library provides a drop-in solution for existing graphql-request users. Release cadence is irregular; breaking changes may accompany upstream graphql-request releases.

npm install graphql-request-appsync-iam
INSTALL
IMPORT
SIG · GRAPHQL-REQUEST-AP
G
graphql-request-appsync-iam
api-clientsjavascriptv5.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getGraphQLClient
import { getGraphQLClient } from 'graphql-request-appsync-iam'
const getGraphQLClient = require('graphql-request-appsync-iam')
ESM-only since v5. CommonJS require() will fail. Use dynamic import() if needed.
GraphQLClient
import { GraphQLClient } from 'graphql-request'
import { GraphQLClient } from 'graphql-request-appsync-iam'
getGraphQLClient returns a graphql-request GraphQLClient instance. Do not import GraphQLClient from this package.
type AppSyncIAMOptions
import type { AppSyncIAMOptions } from 'graphql-request-appsync-iam'
import { AppSyncIAMOptions } from 'graphql-request-appsync-iam'
AppSyncIAMOptions is a TypeScript type, not a value. Use type-only import to avoid runtime issues.

Creates a signed GraphQL client for AWS AppSync with IAM auth and performs a query.

import { getGraphQLClient } from 'graphql-request-appsync-iam'; const url = 'https://your-appsync-api.appsync-api.us-east-1.amazonaws.com/graphql'; const client = getGraphQLClient(url, { awsRegion: 'us-east-1', awsCredentials: { accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '', secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '', sessionToken: process.env.AWS_SESSION_TOKEN ?? '', }, }); const query = ` query getMovie($title: String!) { Movie(title: $title) { releaseDate actors { name } } } `; const data = await client.request(query, { title: 'Inception' }); console.log(data);
Debug
Known issues
breakingVersion 5 requires Node.js 18+ and is ESM-only. The package no longer supports CommonJS require().
fix
Update to Node.js >=18 and use ESM imports (import syntax or dynamic import()).
affects: >=5.0.0
breakinggraphql peer dependency changed from `14 - 15` to `14 - 16` in v5. graphql@16 is now supported.
fix
Update graphql to 14 - 16 range. If upgrading from v4, ensure graphql version compatibility.
affects: >=5.0.0
deprecatedUsage of global AWS.config for credentials is discouraged. Explicitly pass awsCredentials and awsRegion in options.
fix
Pass awsCredentials and awsRegion explicitly to getGraphQLClient() to avoid reliance on global AWS configuration.
affects: >=4.0.0
gotchaThe fetch option is explicitly disallowed in configuration. Passing fetch will cause an error.
fix
Do not pass fetch in the options object. The library uses its own signed fetch implementation.
affects: >=5.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Version 5 is ESM-only, but code uses require() to import the package.
fix
Change to import { getGraphQLClient } from 'graphql-request-appsync-iam' or use dynamic import().
TypeError: graphQLClient.request is not a function
Incorrectly imported GraphQLClient from this package instead of graphql-request, or called request on the client variable wrongly.
fix
Ensure you use the client returned by getGraphQLClient() and call request method as client.request(query, variables).
SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided.
Incorrect AWS region or credentials passed to getGraphQLClient().
fix
Verify the awsRegion matches your AppSync API's region and that awsCredentials have correct accessKeyId, secretAccessKey, and sessionToken if using temporary credentials.
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency for graphql-request integration
graphql-requestrequiredcore dependency providing the GraphQL client interface
@aws-sdk/credential-providersrequiredruntime dependency for resolving AWS credentials
@aws-sdk/typesoptionalruntime dependency for TypeScript types
Agent activity
22 hits · last 30 days
node
18
Resources
graphql-request-appsync-iam — npm install graphql-request-appsync-iam · libregistry