Can anyone please tell me what is the difference between:
aws-sdk/clients/appsync
, and aws-appsync
According to the doc, aws-sdk/clients/appsync
is used because just including aws-sdk
is too large when we just need appsync, we use aws-sdk/clients/appsync
.
However, aws-appsync
seems also doing the same thing. When I create a client using aws-sdk/clients/appsync
, there is no hydrated()
function while aws-appsync
has.
So
aws-sdk/clients/<any_aws_package>
and break everything that did not use it?Thank you very much in advance for all your help.
difference between: aws-sdk/clients/appsync, and aws-appsync
GraphQL
originated at Facebook and the React/React Native apps used react-apollo
to talk to the GraphQL based APIs.
AWS AppSync
is the AWS offering for GraphQL
. aws-sdk/clients/appsync
is the JS SDK to invoke various AppSync
management/control APIs (like create GraphQL API, create data source etc). Not sure if they also provided apis to consume the GraphQL based api.
aws-appsync
is the way to consume AppSync
backed GraphQL APIs. It plays well with react-apollo
which is now moved to apollo-client
.
There is another high level JS library from AWS Amplify, which is used to consume AppSync
backed GraphQL APIs.
aws-sdk/clients/appsync is used because just including aws-sdk is too large
The initial release of the aws-sdk
(Github repo here) contained the clients for all the AWS services and more. You need to install aws-sdk
and you can talk to pretty much all the AWS services by initialising the clients for them. Obvisously it was not so good in terms of packaging JS bundles, the library was also not very modular.
Now the latest version V3 (rewritten using TypeScript) which is GA now, moves the clients to individual npm packages i.e. you need to only install the client you need e.g. npm i @aws-sdk/client-appsync
instead of npm i aws-sdk
. Learn more about it here. If you are getting started use the V3
packages.
Why can't we simplify everything by just using aws-sdk/clients/<any_aws_package> and break everything that did not use it?
It is the case with the V3 JS SDK.
What is the point of separating something that is similar?
They are not similar. One is used to consume the GraphQL based APIs (provided by AppSync) and the other is to manage AppSync itself. The V3 packages follow this very strictly while the earlier versions may have some utility code/ high level abstractions along with the core AWS apis.