From 6f567ed8506a9fc2b3079a11d35a2f4df1e7ca65 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 29 Oct 2024 19:35:21 +0900 Subject: [PATCH] fix: check `errors` field See https://spec.graphql.org/October2021/#sec-Errors --- Mimir.Worker/Client/HeadlessGQLClient.cs | 2 +- Mimir.Worker/Client/Models.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Mimir.Worker/Client/HeadlessGQLClient.cs b/Mimir.Worker/Client/HeadlessGQLClient.cs index fc428b8c..071c1ecd 100644 --- a/Mimir.Worker/Client/HeadlessGQLClient.cs +++ b/Mimir.Worker/Client/HeadlessGQLClient.cs @@ -94,7 +94,7 @@ private async Task PostGraphQLRequestAsync( jsonResponse ); - if (graphQLResponse is null || graphQLResponse.Data is null) + if (graphQLResponse is null || graphQLResponse.Data is null || graphQLResponse.Errors is not null) { throw new HttpRequestException("Response data is null."); } diff --git a/Mimir.Worker/Client/Models.cs b/Mimir.Worker/Client/Models.cs index fadbe6ab..9e78e3be 100644 --- a/Mimir.Worker/Client/Models.cs +++ b/Mimir.Worker/Client/Models.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using System.Text.Json.Serialization; namespace Mimir.Worker.Client; @@ -14,7 +15,9 @@ public class GraphQLRequest public class GraphQLResponse { [JsonPropertyName("data")] - public T Data { get; set; } + public T? Data { get; set; } + + public JsonElement[]? Errors { get; set; } } public class GetAccountDiffsResponse