amplify-flutter
amplify-flutter copied to clipboard
GraphQL mutations issues when using the Map in flutter.
Description
We are using custom mutations query in flutter. we are facing the some issues in using the Map value ( object ).
createWalletContent() async {
try {
String graphQLDocument =
'''mutation createAstrCbGlobalContent(\$walletAndRecharge: Map!) {
createAstrCbGlobalContent(input: {walletAndRecharge: \$walletAndRecharge}) {
id
walletAndRecharge {
title
subtitle
content
imageUrl
}
createdAt
updatedAt
}
}''';
var operation = Amplify.API.mutate(
request:
GraphQLRequest<String>(document: graphQLDocument, variables: {
'walletAndRecharge': {
"title": 'test title',
"subtitle": 'test subtitle',
"content": 'test content',
"imageUrl": 'testing.com',
},
}));
var response = await operation.response;
dynamic data = response.data ?? 'null returns';
print('Mutation result: ' + data);
} on ApiException catch (e) {
print('Mutation failed: $e');
}
}
Categories
- [ ] Analytics
- [ ] API (REST)
- [X] API (GraphQL)
- [ ] Auth
- [ ] Authenticator
- [ ] DataStore
- [ ] Storage
Steps to Reproduce
No response
Screenshots
No response
Platforms
- [ ] iOS
- [X] Android
Android Device/Emulator API Level
No response
Environment
There is no env file
Dependencies
amplify_api: ^0.6.0
amplify_flutter: ^0.6.0
Device
iphone 11 pro
OS
IOS 15.4
CLI Version
9.1.0
Additional Context
No response
Can you post any error messages you receive? I assume you mean the Map you've passed in the variables
key for walletAndRecharge
? Also, can you share your GraphQL schema?
GraphQL schema : type WalletRechargeContent { title: String subtitle: String content: String imageUrl: String }
type astrCbGlobalContent @model @auth(rules: [{ allow: private }]) { id: ID! walletAndRecharge: WalletRechargeContent! }
Didn't get any error message from exception.
What issue are you facing?
i can't able create, update data.
We are getting empty value after that mutations response.
@selva-harivara do you have any errors in your graphql response? I see you are checking for thrown errors, but a server-side appsync error should not throw an ApiException. Instead, will usually return a response with null data and some list of errors which provide a lot of visibility into what's happening, especially if something like invalid request/schema. You can check this by printing/debugging response.errors
in your code example.
Thank you so much for your response to my request for information. We are fixed this issues.