我正在尝试向 GraphQl 提出请求。我可以在操场上做。 在操场上请求
当我尝试使用颤振发出请求时,我无法在查询变量中创建包装器登录。这是我来自 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);
}
}