Skip to content

Commit 7c84758

Browse files
committed
cache json parsing
1 parent 05270ea commit 7c84758

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Tocsoft.GraphQLCodeGen.Cli/SchemaIntrospection/JsonIntrospection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ public class JsonIntrospection : IIntrosepctionProvider
1212
{
1313
public SchemaSource.SchemaTypes SchemaType => SchemaSource.SchemaTypes.Json;
1414

15+
static Dictionary<string, string> parseCache = new Dictionary<string, string>();
1516

1617
public Task<string> LoadSchema(SchemaSource source)
1718
{
18-
string schema = ConvertJsonToSchema(File.ReadAllText(source.Location));
19+
if (!parseCache.TryGetValue(source.Location, out var schema))
20+
{
21+
schema = ConvertJsonToSchema(File.ReadAllText(source.Location));
22+
parseCache.Add(source.Location, schema);
23+
}
1924
return Task.FromResult(schema);
2025
}
2126

0 commit comments

Comments
 (0)