-
Notifications
You must be signed in to change notification settings - Fork 58
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
AWSAppSyncClient is not generating code from the graphql file in Android #408
Comments
Hi @Dharan23 what steps have you tried on cli ? Have you tried |
Please refer to this codegen documentation: https://docs.amplify.aws/sdk/api/graphql/q/platform/android/#code-generation |
I am using the amplify codegen models but it is not generating any models because i am not writing my schema files and pushing it to the console through CLI. I am using an already existing resource. So I will just have the .graphql file shared to me. Because of that I am not doing any amplify init in my project. Does AWSAppSync generate models and API for us to consume if we just have the .graphql file in a specific location in the project without doing any of amplify init? Because this approach is working for IOS but not for Android so I am curious if the Android SDK has such support. |
Can you share the output of amplify status ? |
That's what I thought. Your environment is not configured. You can even pull a specific project down. Go to your amplify console and pull that project ID to see if that works. |
Just to clarify a little here are the steps you would need to take to pull |
Sure thank you I will try this solution. I have one more question I followed these steps in README.md and I am trying to include the AWSAppSyncClient dependency to my android project. When I add the dependency (classpath in build (proj), plugin in build (app) and dependency) I am getting this error below. What should I do to solve this? Note: I am using Android studio Electric Eel 2022.1.1 Patch 2 FAILURE: Build completed with 2 failures. 1: Task failed with an exception.
2: Task failed with an exception.
|
See if this workaround solves your issue : #377 (comment) |
This solution is not working as well.. I'm not even able to sync my project after this. the error i'm getting.. Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method node() for arguments [build_aw1jn4ogdai8pbr597637y56$_run_closure1$_closure10@1c9f449] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension. Is there a Kotlin equivalent of this library? We are not declaring classpath in build.gradle anymore as classpath instead we are using
but the SDK documentation says to use classpath. Is there a way to use the library without any issue in new version of Android studio? |
This is what we are trying to achieve by using existing resource in our project instead of using Amplify to create a profile. We need AWSAppSycnCLient to talk to our endpoints. Please help us. Your responses are much appreciated. |
Hi @Dharan23 please paste your entire dependencies block from gradle so that I can understand which versions of our libraries you are using. |
@gpanshu These are my dependencies in the entire application. build.gradle (app)
build.gradle (project)
And this is the error I'm getting when I build my project after adding these dependencies''' 1: Task failed with an exception.
2: Task failed with an exception.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings BUILD FAILED in 19s ''' |
Are you using a feature that is not available in Amplify from appsync? |
I'm using amplify only for cognito (Auth) services and to maintain session in my application. All the other things are maintained in GraphQL we are trying to use AWSAppsyncClient as it helps to talk to GraphQL like an API layer. I cannot use Amplify to directly connect to the backend because we have other platforms (IOS & Web) using the same service and schema is maintained by a different team directly on AWS console. We will just receive a schema from them when new changes happen. I found a solution to talk to GraphQL service using Retrofit (Android network lib) and I am able to call the service but I need to write my own models and API from schema through this approach. But AWSAppsyncClient will help me to generate these codes for me which makes it much easier. My additional question to you is does AWSAppSync add any additional security to calling the GraphQL service? Or it is just a code generator which helps developers skip writing API and just focus on business logic. |
I think you can use Amplify all of that. Amplify V2 should work similarly between iOS and Android and the schema shouldnt be different between the platforms. Please try using Amplify V2 for your needs as this cross application could be what is causing the issue. Try using Amplify and your original problem of authentication on CLI can be resolved by using the steps I mentioned. |
@gpanshu the situation is different in our case. Our backend team has hosted the data using AWSApp sync. Using amplify pull also we can not see any profile because there is nothing created using amplify. So the only way we have is using AWSAppSyncClient, we need to generate our code. We already followed all the steps mentioned here in the link - https://docs.amplify.aws/sdk/api/graphql/q/platform/android/#import-sdk-and-config , but unfortunately we are getting this error - Execution failed for task ':app:nodeSetup' , mentioned already in one the issue open thread and posted our issue on a descriptive way in stackoverflow, you can check this also. |
Hey @Dharan23, above where you linked the docs on reusing existing AppSync resources, that requires an Amplify project to be set up in your local directory. To follow those steps, start with I hope that helps resolve your issue in the short term. We will continue to look into the issue you've reported for now, though. |
@Dharan23 Have you found fix of issue? |
I'm trying to use AWSAppSyncClient with Amplify in Android. We have an existing schema in AWS console which the other platforms like IOS and Web are using. So I want to use AWSAppSyncClient to call the api instead of using Amplify. But I am facing issue like it is not generating any API layer for me to consume (like it does for IOS).
My Schema sample:
What should I do to generate Model and API from this schema file? Please help me with an answer
The text was updated successfully, but these errors were encountered: