So I'm trying to get AWS Amplify's datastore library working with a reactJS web app I'm building. I was sending data to and from the api just fine using the graphql mutations manually, and then I tried to set up DataStore by following this tutorial. Everything is working fine in the client with the indexed DB, but I can't get the data to synchronise with the api. I get the following error in the console:
DataStore - Data won't be synchronized. No GraphQL endpoint configured. Did you forget `Amplify.configure(awsconfig)`?
I doubled checked, and I'm definitely including my AWS export as so:
import Amplify from "@aws-amplify/core";
import awsExports from "./aws-exports";
Amplify.configure(awsExports);
And the content of the generated ./aws-exports.js
is the following:
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-2",
"aws_appsync_graphqlEndpoint": "https://xxxxxxxxxxxxxx.appsync-api.us-east-2.amazonaws.com/graphql",
"aws_appsync_region": "us-east-2",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "xxxxxxxxxxxxxx",
"aws_cognito_identity_pool_id": "us-east-2:xxxxxxxxxxxxx",
"aws_cognito_region": "us-east-2",
"aws_user_pools_id": "us-east-2_xxxxxxxxx",
"aws_user_pools_web_client_id": "xxxxxxxxxxxxxxxxxx",
"oauth": {}
};
export default awsmobile;
I've double checked the credentials for aws_appsync_graphqlEndpoint
and aws_appsync_apiKey
and they match the values returned from amplify status
in the cli. I've also run amplify push
and my Api has a status of No Change
. When setting up the api I made sure to enable the conflict resolution too, as specified in the tutorial.
Interestingly, I also tried the following when setting up amplify:
import Amplify from "@aws-amplify/core";
import {DataStore} from "@aws-amplify/datastore";
import awsExports from "./aws-exports";
Amplify.configure(awsExports);
DataStore.configure(awsExports);
This solved the DataStore - Data won't be synchronised
error, but I got the following errors instead, and the data still isn't being sent to the api.
DataStore - subscriptionError Subscribe only available for AWS AppSync endpoint
DataStore - Sync error Subscribe only available for AWS AppSync endpoint
Does this mean my API is somehow not configured properly? How Would I go about fixing it?