Amplify Framework adds local mocking and testing for GraphQL APIs, Storage, Functions, and Hosting

Posted on: Aug 8, 2019

The Amplify Framework is an open-source project for building cloud-enabled mobile and web applications.  

Starting today, the Amplify CLI toolchain (part of the Amplify Framework) includes local mocking and testing capabilities for the API, Storage, Functions, and Hosting categories. You can now develop and test an AWS AppSync GraphQL API—with data sources such as Amazon DynamoDB and AWS Lambda functions—entirely in your local environment. Without pushing to the cloud, you can use custom directives, perform code generation with the GraphQL Transformer, and locally edit and run VTL (the “glue code” between your GraphQL schema and your data sources). Capabilities such as local debugging, auto-detection of local changes, hot reload of APIs, and automatic error checking further streamline and accelerate the development process. You can seamlessly transition between your local and cloud environment without changing your application code and backend setup. Previously, developers had to first push their changes to the cloud to validate and test their application with a GraphQL API endpoint. 

The local mocking support integrates with Amplify GraphiQL, an in-browser IDE for exploring GraphQL. Developers can use this IDE to quickly explore their APIs, auto-detect syntax errors, use code completion, build and run queries, mutations, and subscriptions through an easy to use UI. You can also mock tokens from Amazon Cognito User Pools to test authorization rules locally. 

Local storage mocking allows developers to use Amazon Simple Storage Service (S3) operations such as put, get, remove, and list locally without any modifications to their application code and setup. The mock local storage endpoint stores the objects under the local Amplify project folder for easy access.  

In addition, the Amplify CLI enhances the support for local AWS Lambda functions written in Node.js by enabling developers to use local Lambda functions as a data source for fields and operations in their GraphQL API. 

For more details on how to use the local mocking features, refer to our blog post. To learn more about Amplify Framework, please visit our documentation.