Is there a method to create unit tests to test the queries and mutations of AWS AppSync before deploying it(using serverless framework).
I have created appsync api and data source is relational database, but now i want to integrate test case for all queries and mutations which are in vtx file format but not getting relevant information.
Related
I have a few doubt that is unclear in was amplify docs.
Can I turn off data sync to DynamoDB, when using amplify graphQL API with datastore?
Can I query data from dynamo DB using amplify datastore?
If I can query data using a data store, what is the use of API, they should merge all the things?
The datastore sync options are slightly different depending on the language you are using. I think explaining the differences might help you understand things better:
DynamoDB = your database
Appsync API = graphql api that connects to DynamoDB via resolvers initially built out by amplify using your graphql.schema file. If you add amplify codegen it will build out the client code for you as well, based on your schema file.
Datastore = Basically it is a really nice caching layer. It can sync in data via Appsync from Dynamo down to your client in the datastore cache. you can then run queries on datastore in offline mode because the data can be local. The sync helps datastore stay up to date with the live data from the DB. So when querying with datastore, you are usually just querying locally. If you data is up to date it saves the trip to the DB. If you were to use the Appsync API codegen client, it is calling the db through your resolvers each time.
Hope this explanation helps.
I am trying to connect my react native mobile app with graphql server. For that, as the graphql client I am using Apollo Client. I hope to use AWS services and, I have a problem in selecting the suitable graphql server.
Can I use AWS AppSync instead of using a separate GraphQL server such as ApolloServer, Express GraphQL etc.
Yes, you can use AWS AppSync as a GraphQL server on AWS. AWS AppSync is an AWS service for creating your fully managed GraphQL API layers. Since, it is a managed service, which means you don't need to worry about provisioning a server for your backend.
I would suggest you to use Serverless framework to manage and deploy your AppSync application. Here is the link for you to get started and will probably give you a good idea how to use Serverless for AppSync applications.
https://www.serverless.com/guides/aws-appsync
I have created graphql schema and api endpoint in one amplify project but now want to reuse that in separate javascript project. What is the flow of reusing this existing graphql endpoint and corresponding schema in second project to also generate mutations and queries in graphql folder in amplify project?
You can use a multi-frontend workflow for that.
Check their documentation for more on how to use it.
This post has a step by step guide.
You have to:
Create a new Amplify project
Pull your app backend: amplify pull --appId ************* --envName *******
Choose "No" when asked if you gonna modify your backend
The appId you can find on your Amplify Console.
You are ready to go.
Is it possible to use AWS amplify framework to build a database intensive application like "Accounting"?
If I want to use a serverless framework to develop an Accounting application what Serverless framework should I use "Lambda" or else? Is it really possible to implement a Serverless architecture for a database intensive application like Accounting or HR?
Is it possible to have business logic on my AppSync's mutation when the datasource is dynamoDB?
I'm fairly new to GraphQL and Appsync. My understanding is when you're using plain GraphQL you can have business logic inside your resolver to validate before updating. How would you achieve the same thing with AWS AppSync when you pass it the GraphQL schema with DynamoDB as the datasource?
In AWS AppSync, you would attach a resolver to the field that is mapped to the DynamoDB DataSource. You can then use the Velocity template to have your custom business logic inside the resolver for any validations.
Please refer to the following documentation on the Resolver Mapping Template programming guide from AWS.
Here is the mapping template reference for DynamoDB resolvers.
According to AWS AppSync's Website: With AppSync, your app can access data in Amazon DynamoDB, trigger AWS Lambda functions, or run Amazon Elasticsearch queries.
You can think of it as a gateway for clients to access different backends (data sources), defined by mapping templates attached to GraphQL fields (resolvers).
AppSync supports DynamoDB and ElasitcSearch queries natively, but if you want to perform business logic you will have to add a AWS Lambda data source and then use AWS SDKs to R/W DynamoDB or anything else such as another API or maybe even an excel file!
Additionally, you can use Apache VTL along with AppSync's available helpers such as $context to help you perform authorization or field data access based on permissions. Keep in mind that your DynamoDB or ES resolver can only perform 1 operation at the end, Apache VTL only helps you build the resolver that will be run by AppSync.
Here are two diagrams that compare a traditional approach vs appsync