graphql-client
graphql-client copied to clipboard
The HTTP request failed with status code InternalServerError
When I execute a mutation for deleting I don't get the errors in Errors but instead the 'graphQLResponse = await graphQlClient.SendQueryAsync<DeleteVehicleResponse>(request);' will throw and InternalServerError
So I would like to get this error handled by just checking if there are any errors in the response, but since it throws an InternalServerError I can't, and they are also null, as you can see here(this is the serialized response): { "Data": null, "Errors": null, "Extensions": null }
And this is the response I get when I use Banana Cake Pop with the same query.
{ "errors": [ { "message": "Unexpected Execution Error", "locations": [ { "line": 2, "column": 3 } ], "path": [ "deleteVehicle" ], "extensions": { "message": "Not found", "stackTrace": " Very long and not so interesting" } } ] }
Stack trace:
GraphQL.Client.Http.GraphQLHttpRequestException: The HTTP request failed with status code InternalServerError
at GraphQL.Client.Http.GraphQLHttpClient.SendHttpRequestAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken)
at GraphQL.Client.Http.GraphQLHttpClient.SendQueryAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken)
at CarRentalClientServer.Data.VehicleServiceGraphQL.DeleteVehicleAsync(Int32 id)
System.AggregateException: One or more errors occurred. (The HTTP request failed with status code InternalServerError)
---> GraphQL.Client.Http.GraphQLHttpRequestException: The HTTP request failed with status code InternalServerError
at GraphQL.Client.Http.GraphQLHttpClient.SendHttpRequestAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken)
at GraphQL.Client.Http.GraphQLHttpClient.SendQueryAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken)
at CarRentalClientServer.Data.VehicleServiceGraphQL.DeleteVehicleAsync(Int32 id)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
at CarRentalClientServer.Program.Main(String[] args)
Query: mutation DeleteVehicle($id : Int!) { deleteVehicle(id : $id) }
Thanks in advance.
please check why your server responds to the http request with HTTP 501 (InternalServerError) instead of running the GraphQL engine!
Thank you for the quick, response. Well I have tried to check that but I have failed since when I do the same thing, but not "DeleteVehicle" but "UpdateVehicle" and input a out of bounds ID, the server will throw the same exception, but it will run the GraphQL engine and produce a normal graphQL response with "good" errors. My graphQL resolvers are connected to consume an another API and that API is returning the same error for both, 404 NotFound, and they are throwing the exception in the same way with the same error inside.
Ok so I found out that if I don't use bool as a return it works, I used a custom object(Vehicle) and it now works properly. I have no idea why with bool it doesn't work, since that's the only think I changed
Now it gives me this nice return: serialised response: { "Data": { "DeleteVehicle": null }, "Errors": [ { "Locations": [ { "Column": 21, "Line": 5 } ], "Message": "Unexpected Execution Error", "Path": [ "deleteVehicle" ], "Extensions": { "message": "NotFound", "stackTrace": " at CarRentalLogicServer.APIConsumer.VehicleWebService.DeleteVehicleAsync(Int32 id) in C:\Users\janad\OneDrive\Adam\Dokumenty\GitHub\SEP3\SEP3\MiddlewareServer\CarRentalLogicServer\APIConsumer\Vehicl eWebService.cs:line 109\r\n at CarRentalLogicServer.GraphQLResolvers.Mutation.VehicleMutationResolver.DeleteVehicle(IVehicleService vehicleService, Int32 id) in C:\Users\janad\OneDrive\Adam\Dokumenty\GitHub\SEP3\SEP3\Middlewa reServer\CarRentalLogicServer\GraphQLResolvers\Mutation\VehicleMutationResolver.cs:line 27\r\n at HotChocolate.Resolvers.Expressions.ExpressionHelper.AwaitTaskHelper[T](Task\u00601 task)\r\n at HotChocolate.Types.Helpers.FieldMi ddlewareCompiler.\u003C\u003Ec__DisplayClass9_0.\u003C\u003CCreateResolverMiddleware\u003Eb__0\u003Ed.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteR esolverPipelineAsync(CancellationToken cancellationToken)\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)" } } ], "Extensions": null }
I am getting a similar issue, when I try to run a mutation and an error is raised by my graphql Error, I get a InternalServerError from the Graphql.Client. Running via playground, etc it works fine. In that there is no InternalServerError and the error is reported in the graphql response. I have tried a number version including 5.1.0 and get the same issue. even tried both SendMutationAsync and SendQueryAsync and no difference
Error Message: GraphQL.Client.Http.GraphQLHttpRequestException : The HTTP request failed with status code InternalServerError Stack Trace: at BulkOperationApi.e2e.Specflow.Tests.GeneralFunctions.MutationGraphQL(String accessToken, String url, String query, Object variables, IReadOnlyList1& errors) in /Users/craig.brown/Documents/_git/dotnet/BulkOperationApi/test/BulkOperationApi.e2e.Specflow.Tests/Steps/GeneralFunctions.cs:line 62
at BulkOperationApi.e2e.Specflow.Tests.Steps.BulkOperationTestSteps.WhenIRequestADownloadForAInvalidPagingQuery() in /Users/craig.brown/Documents/_git/dotnet/BulkOperationApi/test/BulkOperationApi.e2e.Specflow.Tests/Steps/BulkOperationTestSteps.cs:line 65
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
at BulkOperationApi.e2e.Specflow.Tests.Features.BulkOperationTestGraphFeature.ScenarioCleanup()
at BulkOperationApi.e2e.Specflow.Tests.Features.BulkOperationTestGraphFeature.RequestADownloadForAInvalidPagingQuery() in /Users/craig.brown/Documents/_git/dotnet/BulkOperationApi/test/BulkOperationApi.e2e.Specflow.Tests/Features/BulkOperationTest.feature:line 14`
