Solution 1:

I think your API Key expiration date is over.So goto -- APIs -> select your AppSync -> goto setting -> select your API keys -> then Edit -> now you are in "Configure your API key and change expiration date." -> Select Expires Choose when this API Key will expire here you can choose for 1 year from the date you create new API keys.

Solution 2:

Are you talking about in the "Queries" console? Even if you are logged in to your AWS account and you go to the AWS AppSync Queries console, you will still need to log in separately as a cognito user. Click the "Login with User Pools" button.

enter image description here

From there, just enter the info of a cognito user you already created, and that will simulate being logged in for testing purposes. You can find your clientId in your aws-exports.js file in your project on the line: "aws_user_pools_web_client_id".

Hope that helps!