Skip to content

Examples

Index > AppSync > Examples

Auto-generated documentation for AppSync type annotations stubs module types-aiobotocore-appsync.

Client

Implicit type annotations

Can be used with types-aioboto3[appsync] package installed.

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

Client usage example
from aioboto3.session import Session


session = Session()

async with session.client("appsync") as client:  # (1)
    result = await client.associate_api()  # (2)
  1. client: AppSyncClient
  2. result: AssociateApiResponseTypeDef
Paginator usage example
from aioboto3.session import Session


session = Session()

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

Explicit type annotations

With types-aioboto3-lite[appsync] or a standalone types_aiobotocore_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.

Client usage example
from aioboto3.session import Session

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


session = Session()

client: AppSyncClient
async with session.client("appsync") as client:  # (1)
    kwargs: AssociateApiRequestRequestTypeDef = {...}  # (2)
    result: AssociateApiResponseTypeDef = await client.associate_api(**kwargs)  # (3)
  1. client: AppSyncClient
  2. kwargs: AssociateApiRequestRequestTypeDef
  3. result: AssociateApiResponseTypeDef
Paginator usage example
from aioboto3.session import Session

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


session = Session()

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