Use Amplify with MySQL

0

I want to use a GraphQL API connected to a MySQL Database in my mobile App. For this i have configured the AppSync API, generated the Schema out of the database export and generated the models for swift locally. In the amplifyconfiguration i have added the right credentials to the API.

With:

Amplify.API.query(request: .list(Model.self))

i get all database entries, so the connection/configuration is ok, i think.

When i do this:

Amplify.API.mutate(request: .create(Personen(vorname: "Daniel")))

the row will be added but the autoincrement id will be overwritten with an id from anywhere else?! and i get an error: Failed to decode GraphQL response to the 'ResponseType'

When i do this:

Amplify.API.query(request: .get(Personen.self, byId: "1"))

i have the problem that the id is an int in the database and in GraphQL, but byID is expecting a String.

After the above problems i am asking myself if i use Amplify Framework the right way? Do i have to use another Code to use the GraphQL API? Is Amplify Framework only working with normal Amplify DynamoDB? Can i also use DataStore locally and autosync with MySql? I also wanted to add auth to Amplify, but with configuring it, Amplify generated a new Api and everything stopped working. For my Project i want to use Amplify auth, notification, object storage and other services from Amplify.

Maybe someone can give me some clarity over the cooperation between the different services and give some answers to my questions :) Thank you!

1 Answer
0

Hello,



Thank you for explaining your application set-up in detail.

Based on the error, I suspect the issue lies in the codegen generated models. Kindly check your codegen models for Personen if the ID value is being overwritten. And for the ResponseType error, please enable AppSync verbose logging to confirm all the data is being returned as expected, and in case if we are still facing issue we can validate the output data with the codegen generated model



You can use Amplify Library to make requests to your AppSync API. However, in case you do not want to use the codegen models, you can create your own GraphQLRequest as explained in the doc



Also currently DataStore feature is only supported when using AppSync with Dynamo DB backend, as AppSync currently supports versioning only on DynamoDB data sources.

Additionally, you can configure other categories to your project with commands amplify add auth/notifications/storage. Could you please explain in details steps you performed to add auth category to your project and error you faced during the same.


Please feel free to reach out to Premium Support to troubleshoot further for your application

AWS
SUPPORT ENGINEER
answered 2 months ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions