A local simulator for AWS AppSync APIs, enabling developers to test GraphQL operations and resolvers without direct cloud resources. Part of the Amplify CLI ecosystem, this package (version 2.4.1 as per npm) allows offline development by mimicking AppSync behavior including VTL and JavaScript resolvers, pipeline functions, and authentication modes. It supports unit testing of resolvers and mocking of data sources, reducing deployment cycles. Maintained by AWS, it releases in lockstep with Amplify CLI (~monthly). Unlike alternatives like appsync-simulator, it integrates tightly with Amplify's schema and configuration files.
npm install amplify-appsync-simulatorVerified import paths — ran on the pinned version, not inferred.
Shows creating a minimal simulator with a static schema, a lambda resolver, and running a query inline.
Ensure VTL templates follow AppSync conventions; for JS resolvers, export async function handler(event, context).
Replace with 'authModes: [{ authenticationType: 'API_KEY' }]'.Check release notes for unsupported features; consider integration tests on real AppSync for full coverage.
Use fs.readFileSync to load schema from file and pass as string.
Use mock data sources or replace with local implementations.
Ensure resolver object has 'request' and 'response' properties each containing a 'code' string.
Add a resolver entry for 'Query.hello' with a 'request' and 'response' object.
Set 'authenticationType' to a valid value or use 'authModes' array.
Run 'npm install amplify-appsync-simulator' and use import syntax or ensure bundler supports ESM.