how i can create a function in flutter using graphQL to register a user in supabase platform?

how i can create a function in flutter using graphQL to register a user in supabase platform?


-2

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

leith inoubli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

  • Instead of insert_auth_users use insertIntoUsersCollection

    – Alexander Salas Bastidas

    18 mins ago


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *