Skip to content

Examples#

Index > AppSync > Examples

Auto-generated documentation for AppSync type annotations stubs module mypy-boto3-appsync.

Client#

Implicit type annotations#

Can be used with boto3-stubs[appsync] package installed.

Write your AppSync code as usual, type checking and code completion should work out of the box.

# AppSyncClient usage example

from boto3.session import Session


session = Session()

client = session.client("appsync")  # (1)
result = client.associate_api()  # (2)
  1. client: AppSyncClient
  2. result: AssociateApiResponseTypeDef
# ListApiKeysPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("appsync")  # (1)

paginator = client.get_paginator("list_api_keys")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: AppSyncClient
  2. paginator: ListApiKeysPaginator
  3. item: ListApiKeysResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[appsync] or a standalone mypy_boto3_appsync package, you have to explicitly specify client: AppSyncClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# AppSyncClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_appsync.client import AppSyncClient
from mypy_boto3_appsync.type_defs import AssociateApiResponseTypeDef
from mypy_boto3_appsync.type_defs import AssociateApiRequestRequestTypeDef


session = Session()

client: AppSyncClient = session.client("appsync")

kwargs: AssociateApiRequestRequestTypeDef = {...}
result: AssociateApiResponseTypeDef = client.associate_api(**kwargs)
# ListApiKeysPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_appsync.client import AppSyncClient
from mypy_boto3_appsync.paginator import ListApiKeysPaginator
from mypy_boto3_appsync.type_defs import ListApiKeysResponseTypeDef


session = Session()
client: AppSyncClient = session.client("appsync")

paginator: ListApiKeysPaginator = client.get_paginator("list_api_keys")
for item in paginator.paginate(...):
    item: ListApiKeysResponseTypeDef
    print(item)