2024-06-01 04:20:26 发布
网友
是否可以使用Python调用带有Cognito身份验证的AppSync变异?怎样?在
我尝试使用boto3,但是我没有找到执行graphql操作的方法。在
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appsync.html
您可以将API身份验证模式转换为“API密钥”,并使用http调用AppSync变体。在
例如。在
import requests import json APPSYNC_API_KEY = 'da2-xxxxxxxxxxxxx' APPSYNC_API_ENDPOINT_URL = 'https://xxxxxxxxxxxxx.appsync-api.us-west-2.amazonaws.com/graphql' headers = { 'Content-Type': "application/graphql", 'x-api-key': APPSYNC_API_KEY, 'cache-control': "no-cache", } def execute_gql(query): payload_obj = {"query": query} payload = json.dumps(payload_obj) response = requests.request("POST", APPSYNC_API_ENDPOINT_URL, data=payload, headers=headers) return response
假设您有一个名为Items的模型,您可以轻松地进行如下查询:
Items
只需将字符串替换为变异操作。在
您可以将API身份验证模式转换为“API密钥”,并使用http调用AppSync变体。在
例如。在
假设您有一个名为
^{pr2}$Items
的模型,您可以轻松地进行如下查询:只需将字符串替换为变异操作。在
相关问题 更多 >
编程相关推荐