amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

GraphQL mutations issues when using the Map in flutter.

Open selva-harivara opened this issue 2 years ago • 5 comments

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

selva-harivara avatar Jul 28 '22 14:07 selva-harivara

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?

dnys1 avatar Jul 28 '22 14:07 dnys1

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.

selva-harivara avatar Jul 28 '22 14:07 selva-harivara

What issue are you facing?

dnys1 avatar Jul 28 '22 15:07 dnys1

i can't able create, update data.

selva-harivara avatar Jul 29 '22 04:07 selva-harivara

We are getting empty value after that mutations response.

selva-harivara avatar Jul 29 '22 06:07 selva-harivara

@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.

ragingsquirrel3 avatar Aug 24 '22 23:08 ragingsquirrel3

Thank you so much for your response to my request for information. We are fixed this issues.

selva-harivara avatar Aug 25 '22 05:08 selva-harivara