I am trying to make a request to GraphQl. I can do it in the playground. Request in the playground
When I try to make a request using flutter, I cannot make a wrapper LogIn in Query variables. This is my code from Flutter:
InviteCodeRepository.dart
import 'package:fauna/data/api/graphql_api_client.dart';
import 'package:get/get.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
abstract class InviteCodeRepository {
Future<void> inviteCode(String inviteCode, String phone);
}
class InviteRepositoryImplementation extends GetxController
implements InviteCodeRepository {
String login = r'''
mutation login($Login: Login){
login(login: $Login) {
token
}
}
final _gqlClient = Get.put(GraphQLApiClient(), permanent: true);
@override
Future<void> inviteCode(String inviteCode, String phone) async {
final variables = {'phone': phone, 'accessCode': inviteCode};
final QueryResult result = await _gqlClient.mutation(
login,
variables: variables,
);
print(result.data);
}
}
Here is what worked for me: InviteCodeRepository.dart