Skip to content

Commit 36c86e9

Browse files
committed
Merge branch 'main' into multiple-methods
2 parents 3a1e500 + 68e91b7 commit 36c86e9

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/Linq2GraphQL.Client/GraphBaseExecute.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq.Expressions;
1+
using Linq2GraphQL.Client.Schema;
2+
using System.Linq.Expressions;
23

34
namespace Linq2GraphQL.Client;
45

@@ -13,6 +14,7 @@ public abstract class GraphBaseExecute<T, TResult>
1314

1415
private readonly SemaphoreSlim _lock = new(1, 1);
1516
private bool intialized;
17+
private GraphQLSchema schema;
1618

1719
public GraphBaseExecute(GraphClient client, OperationType operationType, QueryNode queryNode,
1820
Expression<Func<T, TResult>> selector)
@@ -32,7 +34,7 @@ private async Task InitQueryAsync()
3234
{
3335
if (!intialized)
3436
{
35-
var schema = await client.GetSchemaForSafeModeAsync();
37+
schema = await client.GetSchemaForSafeModeAsync();
3638
QueryNode.SetAllUniqueVariableNames();
3739
QueryNode.AddPrimitiveChildren(true, schema);
3840
intialized = true;
@@ -43,12 +45,10 @@ private async Task InitQueryAsync()
4345
{
4446
_lock.Release();
4547
}
46-
47-
48-
49-
5048
}
5149

50+
public GraphQLSchema Schema => schema;
51+
5252
private string GetQueryVariablesString()
5353
{
5454
var args = QueryNode.GetAllActiveArguments();

src/Linq2GraphQL.Client/GraphClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class GraphClient
1111
{
1212
private readonly IMemoryCache cache;
1313
private readonly IOptions<GraphClientOptions> options;
14-
14+
1515
public GraphClient(HttpClient httpClient, IOptions<GraphClientOptions> options, IServiceProvider provider)
1616
{
1717
this.options = options;
@@ -64,7 +64,9 @@ public async Task<GraphQLSchema> GetSchemaForSafeModeAsync()
6464
return null;
6565
}
6666

67-
return await cache.GetOrCreateAsync("__schema", async entry =>
67+
var cackeKey = "Linq2GraphQL_Schema:" + HttpClient.BaseAddress;
68+
69+
return await cache.GetOrCreateAsync(cackeKey, async entry =>
6870
{
6971
var executor = new QueryExecutor<GraphQLSchema>(this);
7072

src/Linq2GraphQL.Client/QueryExecutor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ internal QueryExecutor(GraphClient client)
1717
internal async Task<T> ExecuteRequestAsync(string name, GraphQLRequest graphRequest)
1818
{
1919
var json = JsonSerializer.Serialize(graphRequest, client.SerializerOptions);
20-
2120
using var response = await client.HttpClient.PostAsJsonAsync("", graphRequest, client.SerializerOptions);
2221

2322
if (!response.IsSuccessStatusCode)

test/Linq2GraphQL.Tests/QueryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public async Task Customers_WithIncludeSelect()
6464

6565
var result = await query.ExecuteAsync();
6666

67+
var schema = query.Schema;
68+
6769
var customer1 = result[0];
6870
Assert.NotEqual(default, customer1.CustomerId);
6971
Assert.Equal(default, customer1.CustomerName);

test/Linq2GraphQL.Tests/SampleClientFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public SampleClientFixture()
1919
sampleClient = new SampleClient(client, Options.Create(new GraphClientOptions
2020
{
2121
SubscriptionProtocol = SubscriptionProtocol.ServerSentEvents,
22-
UseSafeMode = false
22+
UseSafeMode = true
2323
}), application.Services);
2424
//Please note currently only ServerSentEvents work in test project
2525
}

version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "0.12-prerelease",
2+
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "0.13-prerelease",
44
"publicReleaseRefSpec": [
55
"^refs/heads/main$",
66
"^refs/heads/release/v\\d+(?:\\.\\d+)?$"

0 commit comments

Comments
 (0)