2

I keep getting the HTTP 500 Internal Server Error in my android studio trying to call a loginQuery with apollo client for android, following this tutorial : link to apollo docs

Yet when I run the same query in graphiQL in my browser, it succeeds.

here's a picture of the error in studio : android studio

here's my code:

String userNumber = numberInput.getText().toString();
String password = passwordInput.getText().toString();
Intent intent;

LogInQuery logInQuery = LogInQuery.builder().nationalID(userNumber).password(password).build();
apolloClient.query(logInQuery).enqueue(new ApolloCall.Callback<LogInQuery.Data>() {
    @Override
    public void onResponse(@NotNull Response<LogInQuery.Data> response) {
        LogInQuery.Data data = response.getData();
        List<Error> error = response.getErrors();
        assert error != null;
        String errorMessage = error.get(0).getMessage();

        assert data != null;
        Log.d(TAG, "onResponse: " + data.login() + "-" + data.login());

        if(data.login() == null){
            Log.e("Apollo", "an Error occurred : " + errorMessage);
            runOnUiThread(() -> {
                // Stuff that updates the UI
                loading.setVisibility(View.GONE);
                Toast.makeText(LogInActivity.this,
                        errorMessage, Toast.LENGTH_LONG).show();
            });
        } else {
            runOnUiThread(() -> {
                // Stuff that updates the UI
                loading.setVisibility(View.GONE);
                Toast.makeText(LogInActivity.this,
                        "New User Created!", Toast.LENGTH_LONG).show();

                //Intent intent = new Intent(LogInActivity.this, LogInActivity.class);
                //startActivity(intent);
            });
        }
    }

    @Override
    public void onFailure(@NotNull ApolloException e) {
        runOnUiThread(() -> {
            Log.e("Apollo", "Error", e);
            Toast.makeText(LogInActivity.this,
                    "An error occurred : " + e.getMessage(), Toast.LENGTH_LONG).show();
            loading.setVisibility(View.GONE);
        });

    }
});
}

I can't find much on the internet to help me solve it. If it's duplicate, direct me to the correct answer.

Ivan Bila
  • 747
  • 7
  • 9
itwabi
  • 125
  • 10

1 Answers1

0

Check your API in Postman. It's working fine or not! Please share API if possible.

Abhnav Maurya
  • 115
  • 1
  • 4
  • here's the api : https://waste-mgmt-api.herokuapp.com/graphql , and I didn't use postman, i used the graphql browser interface, also the api is working fine for other mutations and queries, just not the login one. which is puzzling to say the least – itwabi Feb 24 '21 at 16:40
  • Use a client that will give you more details for error. As per your data. The issue is. The API you are calling doesn't exist. Refer this post to the client. https://site-valley.com/2021/02/17/retrofit-android-tutorial-in-kotlin/ – Abhnav Maurya Feb 25 '21 at 06:33