the problem is specifically related to user registration using GraphQL on the Supabase platform, and you’re seeking help to resolve it.
this the function i use
Future<void> registerEmployee(
String email, String password, BuildContext context) async {
try {
setIsLoading = true;
if (email.isEmpty || password.isEmpty) {
throw 'All Fields are required';
}
const String registrationMutation = r'''
mutation Register($email: String!, $password: String!) {
insert_auth_users(email: $email, password: $password) {
Users {
id
email
}
}
}
''';
final MutationOptions registrationOptions = MutationOptions(
document: gql(registrationMutation),
variables: <String, dynamic>{
'email': email,
'password': password,
},
);
final QueryResult registrationResult =
await _graphQLClient.mutate(registrationOptions);
if (registrationResult.hasException) {
throw registrationResult.exception!;
}
final userData = registrationResult.data!['registerUser']['user'];
final user = User.fromJson(userData);
print("user : $user, userdata : $userData");
Utils.showSnackBar('Successfully registered!', context,
color: Colors.green);
setIsLoading = false;
} catch (e) {
setIsLoading = false;
Utils.showSnackBar(e.toString(), context, color: Colors.red);
}
}
-
and this is the error
error :OperationException(linkException: null, graphqlErrors: [GraphQLError(message: Unknown field "insert_auth_users" on type Mutation, locations: null, path: null, extensions: null)])
a fast response please
New contributor
1
Instead of
insert_auth_users
useinsertIntoUsersCollection
18 mins ago