-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use existing appsync api without models #2574
Comments
Hi could you check if following Amplify documentation helps you to add existing AppSync endpoint for your usecase: https://docs.amplify.aws/lib/graphqlapi/existing-resources/q/platform/android/ |
I followed this but still wasn’t able to call the appsync api. I had to use custom request with the amplify GraphQLRequest where I parsed the schema as string and sent the request. So it works now. |
Have you tried using |
I have gotten it to work using the custom GraphQLRequest, the existing appsync api didn’t have model |
Ok is there any open question that needs to be addressed? |
Not at all, thank you |
|
@seyikayode Can you please paste an example how the custom query works, I am trying the same from the documentation, but gives me a null response. Your help will highly be appreciated, as I am completely blocked |
for android kotlin, i generated the queries with the schema.graphql file using amplify codegen. Below is an example of a generated query after running "amplify codegen add" query GetUserDetails($id: String) { This generated query above, make it a string variable and it becomes... val getUserDetailsQuery = "query GetUserDetails($id: String) {\n" + After making it a string, write another function that contains the graphqlRequest which maps the id parameter and also makes use of the getUserDetailsQuery variable above (assuming it's kotlin)... fun getUserDetailsRequest(id: String): GraphQLRequest { To finally make the api request, use the Amplify.API.query together with getUserDetailsRequest above. example below... suspend fun getUserDetails(id: String): GetUserDetailsResult { from here, you will be able to get your result. I used Gson() to deserialize the data here and also used GetUserDetailsResult to declare the result type. You can customize yours. |
Thanks a lot @seyikayode I will have a try now, probably i have done something wrong with Gson desrialization |
@seyikayode I Get below error while trying the same
My code here:
Do you know any reason for this ? Thanks, |
remove __typename from the document, add a slash before $id like I did in the example |
@seyikayode That helps resolve the error, I can query and mutate now. Thanks a lot for your help Another note, since Aws App sync sdk , already generates all queries nad mutations already and much easier to use. Is there any particular reason to use Amplify SDK ? Looks doing through Amplify is much complex than Aws App Sync SDK. Thanks |
Amplify is used for authentication with aws cognito, its also used for mobile development on aws. So its just better to call endpoints with it too instead of using another new library to make requests. Amplify can also be used to create the api, depends on the requirements. |
Before opening, please confirm:
Language and Async Model
Kotlin
Amplify Categories
GraphQL API
Gradle script dependencies
// Put output below this line
implementation("com.amplifyframework:core:2.12.0")
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
I followed the amplify android docs on using existing graphql api. After following this process, i wasn't able to use the appsync graphql api beacuse it doesn't have models. I couldn't find any part in the docs where an existing appsync graphql api was used and up till now i am unable to call any mutation or query because there i have not generated models to use. In the existing appsync api, model was not used.
Reproduction steps (if applicable)
No response
Code Snippet
// Put your code below this line.
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: