mypy-boto3-appsync Type Annotations

1.42.6 · active · verified Sat Apr 11

mypy-boto3-appsync provides official type annotations for the `boto3` AppSync client, generated by `mypy-boto3-builder`. It enhances development with static type checking for AWS SDK operations related to AppSync, helping catch errors before runtime. The current version is 1.42.6, and releases are frequent, typically in sync with `boto3` updates and `mypy-boto3-builder` enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `AppSyncClient` type annotation with `boto3`. It shows how to correctly type your `boto3` client instance and use a type definition for a response object, ensuring type safety for your AWS AppSync operations. Remember to have AWS credentials configured for actual execution.

import boto3
from mypy_boto3_appsync.client import AppSyncClient
from mypy_boto3_appsync.type_defs import ListGraphqlApisResponseTypeDef

# Instantiate the boto3 client with type annotation
client: AppSyncClient = boto3.client("appsync")

try:
    # Example: List GraphQL APIs (requires appropriate AWS credentials)
    response: ListGraphqlApisResponseTypeDef = client.list_graphql_apis()
    print("Successfully listed GraphQL APIs:")
    for api in response.get("graphqlApis", []):
        print(f"  - {api.get('name')} (API ID: {api.get('apiId')})")
except client.exceptions.UnauthorizedException as e:
    print(f"Authentication error: {e}. Make sure your AWS credentials are configured.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →