zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 622 forks source link

Issue with Registering Users via GraphQL on Supabase - Need Assistance #1383

Open inoublileith opened 1 year ago

inoublileith commented 1 year ago

the problem is specifically related to user registration using GraphQL on the Supabase platform, and i am seeking help to resolve it This is 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)])