The description for the interaction of point #2 is
The web/mobile client interacts with AWS Amplify frameworks, which allow communication with backend services with iOS, Android, web, and React Native front ends.
From my understanding, AWS AppSync has integration with Amazon Cognito User pools And there are AWS SDKs for web, IOS and Android.
What are the advantages of putting Amazon Amplify in Between the client and AWSAppsync? Why can't the client just interact with AppSync directly given that they can authorize using Cognito?
Reading more on AWS Amplify: Is AWS Amplify in this case likely just used for its higher level client APIs? So it can be seen as just using a different SDK then lower level AWS SDK?
CodePudding user response:
Amplify's Frontend Libraries and UI Components provide optional framework-native client integrations. All this can of course be done without the Amplify client tools, but they are useful!
Here is some Amplify React code wiring up Cognito auth as an example. Note it uses Apollo Client, not the Amplify GraphQL client. You can pick and choose.
// configure auth
Amplify.configure({
Auth: {
region,
userPoolId:USERPOOL_ID,
userPoolWebClientId: USERPOOL_CLIENT_ID,
},
});
// pass jwt to apollo graphql client
const config = {
url: `https://${APPSYNC_ID}.appsync-api.us-east-1.amazonaws.com/graphql`,
region,
auth: {
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken(),
} as AuthOptions,
};
const client = new ApolloClient({
link: ApolloLink.from([createAuthLink(config), createSubscriptionHandshakeLink(config)]),
});
// auth hooks in components
const { currentUser, signOut } = useAuth();
CodePudding user response:
Certainly you can use Cognito, Appsync and other AWS services packed into Amplify without Amplify.
I think the greatness of Amplify lies in graphical user interface (Amplify Studio) and automation of certain common management and DevOps tasks.
If you don't need a common UI to manage apps, environments, data, users and APIs and have experience in using IaC tools (CloudFormation, Terraform, CDK etc.) or AWS Console, there is no justification to start using Amplify.
Experienced developers can build and deploy apps by using IaC tools, CDK and SDK without extra abstraction layer like Amplify. It is really only a full stack development tool / platform to define different components which are deployed under the hood as CloudFormation Stacks. Some might find it useful tool which might save time, other might find it confusing.
If the use case were to use only Cognito, Appsync and Lamba - not all the Amplify features - I would not use Amplify.