Skip to content

Commit

Permalink
Don't use source generation for now--it's simpler with the variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nloum committed Aug 27, 2024
1 parent 187d9f4 commit 84e1fe1
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions CodegenBot/GraphQLRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace CodegenBot;

public class GraphQLRequest
{
private static readonly SourceGenerationContext _context = new();

[JsonPropertyName("query")]
public string Query { get; set; }
[JsonPropertyName("operationName")]
Expand All @@ -16,22 +14,11 @@ public class GraphQLRequest

public static GraphQLRequest FromJsonString(string requestBody)
{
return JsonSerializer.Deserialize(requestBody, _context.GraphQLRequest);
return JsonSerializer.Deserialize<GraphQLRequest>(requestBody, new JsonSerializerOptions() { WriteIndented = true });
}

public string ToJsonString()
{
return JsonSerializer.Serialize(this, _context.GraphQLRequest);
return JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
}
}

[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Dictionary<string, object?>))]
[JsonSerializable(typeof(GraphQLRequest))]
[JsonSerializable(typeof(string))]
[JsonSerializable(typeof(bool))]
[JsonSerializable(typeof(int))]
[JsonSerializable(typeof(double))]
internal partial class SourceGenerationContext : JsonSerializerContext
{
}

0 comments on commit 84e1fe1

Please sign in to comment.