Skip to content

Commit

Permalink
Add support for .net9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
byme8 committed Dec 25, 2024
1 parent de84d77 commit 67bba92
Show file tree
Hide file tree
Showing 34 changed files with 332 additions and 262 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="StrawberryShake.Server" Version="13.8.1" />
<PackageReference Include="StrawberryShake.Transport.Http" Version="13.8.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="StrawberryShake.Server" Version="14.1.0" />
<PackageReference Include="StrawberryShake.Transport.Http" Version="14.1.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
``` ini

BenchmarkDotNet=v0.13.2, OS=macOS 14.5 (23F79) [Darwin 23.5.0]
BenchmarkDotNet=v0.13.2, OS=macOS 15.0.1 (24A348) [Darwin 24.0.0]
Apple M3 Max, 1 CPU, 14 logical and 14 physical cores
.NET SDK=8.0.301
[Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
DefaultJob : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
.NET SDK=9.0.100
[Host] : .NET 9.0.0 (9.0.24.52809), Arm64 RyuJIT AdvSIMD
DefaultJob : .NET 9.0.0 (9.0.24.52809), Arm64 RyuJIT AdvSIMD


```
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|--------------------------- |---------:|---------:|---------:|-------:|----------:|
| Raw | 68.65 μs | 0.277 μs | 0.231 μs | 0.6104 | 5.34 KB |
| StrawberryShake | 73.48 μs | 0.362 μs | 0.321 μs | 1.3428 | 11.58 KB |
| ZeroQLLambdaWithoutClosure | 69.55 μs | 0.376 μs | 0.351 μs | 0.7324 | 6.74 KB |
| ZeroQLLambdaWithClosure | 70.43 μs | 0.439 μs | 0.410 μs | 0.8545 | 7.22 KB |
| ZeroQLRequest | 69.95 μs | 0.439 μs | 0.366 μs | 0.7324 | 6.32 KB |
| Raw | 64.68 μs | 0.409 μs | 0.383 μs | 0.4883 | 5.32 KB |
| StrawberryShake | 69.06 μs | 0.371 μs | 0.347 μs | 1.3428 | 11.79 KB |
| ZeroQLLambdaWithoutClosure | 66.61 μs | 0.457 μs | 0.428 μs | 0.8545 | 7.07 KB |
| ZeroQLLambdaWithClosure | 66.90 μs | 0.419 μs | 0.392 μs | 0.8545 | 7.55 KB |
| ZeroQLRequest | 66.47 μs | 0.488 μs | 0.457 μs | 0.7324 | 6.65 KB |
2 changes: 1 addition & 1 deletion src/Benchmarks/ZeroQL.Benchmark/ZeroQL.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/TestApp/TestStandardLibrary/Generated/GraphQL.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 2938f381f05ea9f538686268fde7023c
// c849b892619845face64d0012af70905
// <auto-generated>
// This file generated for ZeroQL 1.0.0.0.
//
Expand Down Expand Up @@ -212,12 +212,12 @@ public class Limit2ZeroQL
[JsonPropertyName("limit2")]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
[global::System.ObsoleteAttribute("This property is for internal use only. Do not use it directly. It maybe be removed in the future releases.")]
public Limit2ZeroQL __Limit2 { get; set; }
public Limit2ZeroQL? __Limit2 { get; set; }

[ZeroQL.GraphQLName("limit2")]
public T Limit2<T>(Func<Limit2ZeroQL, T> selector = default !)
public T? Limit2<T>(Func<Limit2ZeroQL, T> selector = default !)
{
return __Limit2 is null ? throw new NullReferenceException("Limit2 is null but it should not be null. Schema can be outdated.") : selector(__Limit2);
return __Limit2 is null ? default : selector(__Limit2);
}
}

Expand Down Expand Up @@ -1325,7 +1325,7 @@ public class Limit2Input

[JsonPropertyName("limit2")]
[ZeroQL.GraphQLName("limit2")]
public Limit2Input Limit2 { get; set; }
public Limit2Input? Limit2 { get; set; }
}

[System.CodeDom.Compiler.GeneratedCode ( "ZeroQL" , "1.0.0.0" )]
Expand Down
2 changes: 1 addition & 1 deletion src/TestApp/TestStandardLibrary/TestStandardLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Portable.System.DateTimeOnly" Version="7.0.1" />
<PackageReference Include="Portable.System.DateTimeOnly" Version="8.0.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- <ZeroQLCLIValidation>False</ZeroQLCLIValidation>-->
Expand Down
10 changes: 5 additions & 5 deletions src/TestApp/ZeroQL.TestApp/Generated/GraphQL.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// e3ffb4224ceaa474687dabfe4a87e72c
// 2529ecfad66562aa7d1aa2a47edf3d08
// <auto-generated>
// This file generated for ZeroQL 1.0.0.0.
//
Expand Down Expand Up @@ -212,12 +212,12 @@ public class Limit2ZeroQL
[JsonPropertyName("limit2")]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
[global::System.ObsoleteAttribute("This property is for internal use only. Do not use it directly. It maybe be removed in the future releases.")]
public Limit2ZeroQL __Limit2 { get; set; }
public Limit2ZeroQL? __Limit2 { get; set; }

[ZeroQL.GraphQLName("limit2")]
public T Limit2<T>(Func<Limit2ZeroQL, T> selector = default !)
public T? Limit2<T>(Func<Limit2ZeroQL, T> selector = default !)
{
return __Limit2 is null ? throw new NullReferenceException("Limit2 is null but it should not be null. Schema can be outdated.") : selector(__Limit2);
return __Limit2 is null ? default : selector(__Limit2);
}
}

Expand Down Expand Up @@ -1325,7 +1325,7 @@ public class Limit2Input

[JsonPropertyName("limit2")]
[ZeroQL.GraphQLName("limit2")]
public Limit2Input Limit2 { get; set; }
public Limit2Input? Limit2 { get; set; }
}

[System.CodeDom.Compiler.GeneratedCode ( "ZeroQL" , "1.0.0.0" )]
Expand Down
2 changes: 1 addition & 1 deletion src/TestApp/ZeroQL.TestApp/ZeroQL.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
41 changes: 29 additions & 12 deletions src/TestApp/ZeroQL.TestApp/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Limit {

type Limit2 {
value: Int!
limit2: Limit2!
limit2: Limit2
}

type Limit3 {
Expand All @@ -86,11 +86,11 @@ type Mutation {
timeOnly(timeOnly: TimeSpan!): TimeSpan!
createInstant(instant: Instant!): Instant!
addUser(firstName: String! lastName: String!): User!
doError: Int!
addUserProfileImage(USER_ID: Int! file: Upload!): Int!
addMyProfileImage(file: Upload!): Int!
addUsersInfo(users: [UserInfoInput!]!): Int!
addUsersInfoWithEmails(input: AddUsersInput!): Int!
doError: Int! @cost(weight: "10")
addUserProfileImage(USER_ID: Int! file: Upload!): Int! @cost(weight: "10")
addMyProfileImage(file: Upload!): Int! @cost(weight: "10")
addUsersInfo(users: [UserInfoInput!]!): Int! @cost(weight: "10")
addUsersInfoWithEmails(input: AddUsersInput!): Int! @cost(weight: "10")
addUserKindPascal(userKindPascal: UserKindPascal!): Int!
addLimit(limit: LimitInput!): Limit!
addLimitNullable(limit: LimitInput): Limit
Expand All @@ -99,7 +99,7 @@ type Mutation {
addLimit3(limit: Limit3Input): Limit3
addLimits(limit: [Limit2Input!]!): [Limit2!]!
addLowerCaseTypeName(value: lower_case_type_nameInput!): lower_case_type_name!
addValues(text: String! value1: Byte! value2: Byte value3: Short! value4: Short value5: Int! value6: Int value7: Long! value8: Long value9: Float! value10: Float value11: Float! value12: Float value13: Decimal! value14: Decimal value15: DateTime! value16: DateTime value17: Date! value18: Date value19: UUID! value20: UUID value21: [UUID!]! value22: [UUID!] value23: [UUID!]! value24: [UUID!] value25: [UUID!]! value26: [UUID!] value27: [KeyValuePairOfStringAndStringInput!]! value28: [KeyValuePairOfStringAndStringInput!] value29: KeyValuePairOfStringAndStringInput! value30: KeyValuePairOfStringAndStringInput value31: DateTime! value32: DateTime): Int!
addValues(text: String! value1: Byte! value2: Byte value3: Short! value4: Short value5: Int! value6: Int value7: Long! value8: Long value9: Float! value10: Float value11: Float! value12: Float value13: Decimal! value14: Decimal value15: DateTime! value16: DateTime value17: Date! value18: Date value19: UUID! value20: UUID value21: [UUID!]! value22: [UUID!] value23: [UUID!]! value24: [UUID!] value25: [UUID!]! value26: [UUID!] value27: [KeyValuePairOfStringAndStringInput!]! value28: [KeyValuePairOfStringAndStringInput!] value29: KeyValuePairOfStringAndStringInput! value30: KeyValuePairOfStringAndStringInput value31: DateTime! value32: DateTime): Int! @cost(weight: "10")
}

type Person implements IPerson {
Expand All @@ -126,7 +126,7 @@ type Query {
squares: [Square!]!
jsonUsersElement: JSON!
jsonUsersDocument: JsonDocument!
longOperation: Int!
longOperation: Int! @cost(weight: "10")
instant: Instant!
zonedDateTime: ZonedDateTime!
posts: [PostContent!]!
Expand Down Expand Up @@ -236,7 +236,7 @@ input KeyValuePairOfStringAndStringInput {

input Limit2Input {
value: Int!
limit2: Limit2Input!
limit2: Limit2Input
}

input Limit3Input {
Expand Down Expand Up @@ -288,6 +288,12 @@ enum UserKindPascal {
Bad
}

"The purpose of the `cost` directive is to define a `weight` for GraphQL types, fields, and arguments. Static analysis can use these weights when calculating the overall cost of a query or response."
directive @cost("The `weight` argument defines what value to add to the overall cost for every appearance, or possible appearance, of a type, field, argument, etc." weight: String!) on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM | INPUT_FIELD_DEFINITION

"The `@specifiedBy` directive is used within the type system definition language to provide a URL for specifying the behavior of custom scalar definitions."
directive @specifiedBy("The specifiedBy URL points to a human-readable specification. This field will only read a result for scalar types." url: String!) on SCALAR

"The `Byte` scalar type represents non-fractional whole numeric values. Byte can represent values between 0 and 255."
scalar Byte

Expand All @@ -297,10 +303,18 @@ scalar Date
"The `DateTime` scalar represents an ISO-8601 compliant date time type."
scalar DateTime @specifiedBy(url: "https:\/\/www.graphql-scalars.com\/date-time")

"The built-in `Decimal` scalar type."
"The `Decimal` scalar type represents a decimal floating-point number."
scalar Decimal

"Represents an instant on the global timeline, with nanosecond resolution."
"""
Represents an instant on the global timeline, with nanosecond resolution.
Allowed patterns:
- `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm`
Examples:
- `2000-01-01T20:00:00.999999999Z`
"""
scalar Instant

scalar JSON
Expand All @@ -319,7 +333,10 @@ scalar UUID @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc4122")
"The `Upload` scalar type represents a file upload."
scalar Upload

"A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants.\nA ZonedDateTime is global, in that it maps to a single Instant."
"""
A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants.
A ZonedDateTime is global, in that it maps to a single Instant.
"""
scalar ZonedDateTime

scalar uuid
5 changes: 4 additions & 1 deletion src/ZeroQL.CLI/DownloadHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net.Http.Headers;
using HotChocolate.Language.Utilities;
using HotChocolate.Utilities.Introspection;
using ZeroQL.CLI.Commands;

Expand All @@ -16,7 +17,9 @@ public static async Task DownloadSchema(
{
var client = CreateHttpClient(schemaUri, accessToken, authScheme, customHeaders);
await using var stream = File.Create(output);
await IntrospectionClient.Default.DownloadSchemaAsync(client, stream, cancellationToken);
var node = await IntrospectionClient.IntrospectServerAsync(client, cancellationToken);

await node.PrintToAsync(stream, cancellationToken: cancellationToken);
}

private static HttpClient CreateHttpClient(
Expand Down
6 changes: 3 additions & 3 deletions src/ZeroQL.CLI/ZeroQL.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>ZeroQL.Cli</PackageId>
Expand All @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CliFx" Version="2.3.1" />
<PackageReference Include="HotChocolate.Utilities.Introspection" Version="13.0.5" />
<PackageReference Include="CliFx" Version="2.3.5" />
<PackageReference Include="HotChocolate.Utilities.Introspection" Version="14.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ZeroQL.Core/ZeroQL.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NJsonSchema" Version="10.9.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ZeroQL.MSBuild/ZeroQL.MSBuild.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/ZeroQL.Package/ZeroQL.Package.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Expand Down
10 changes: 9 additions & 1 deletion src/ZeroQL.Runtime/Pipelines/PersistedQueryPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<GraphQLResponse<TQuery>> ExecuteAsync<TQuery>(IHttpHandler htt
return qlResponse with { Query = FormatPersistedQuery(queryInfo) };
}

if (qlResponse.Errors.All(o => o.Message != "PersistedQueryNotFound"))
if (qlResponse.Errors.All(FailedToFindPersistedQuery))
{
return qlResponse with { Query = FormatPersistedQuery(queryInfo) };
}
Expand All @@ -66,6 +66,14 @@ public async Task<GraphQLResponse<TQuery>> ExecuteAsync<TQuery>(IHttpHandler htt
return qlResponse with { Query = FormatPersistedQuery(queryInfo) };
}

private static bool FailedToFindPersistedQuery(GraphQueryError o)
{
var hotChocolateV13Way = o.Message == "PersistedQueryNotFound";
var hotChocolateV14Way = o.Extensions?.ContainsKey("HC0020") ?? false;

return hotChocolateV13Way || hotChocolateV14Way;
}

private static string FormatPersistedQuery(QueryInfo queryInfo)
{
return $"{queryInfo.Hash}:{queryInfo.Query}";
Expand Down
2 changes: 1 addition & 1 deletion src/ZeroQL.Runtime/ZeroQL.Runtime.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<RootNamespace>ZeroQL</RootNamespace>
Expand Down
14 changes: 8 additions & 6 deletions src/ZeroQL.TestServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ await StartServer(new ServerContext
});
}

public static async Task StartServer(ServerContext context)
public static async Task<WebApplication> StartServer(ServerContext context)
{
var builder = WebApplication.CreateBuilder(context.Arguments);
var app = CreateApp(context, builder);

await app.RunAsync(context.CancellationTokenSource.Token);
_ = app.RunAsync(context.CancellationTokenSource.Token);

return app;
}

public static WebApplication CreateApp(ServerContext context, WebApplicationBuilder builder)
Expand All @@ -47,14 +49,14 @@ public static WebApplication CreateApp(ServerContext context, WebApplicationBuil
if (string.IsNullOrEmpty(context.QueriesPath))
{
graphQLServer
.UseAutomaticPersistedQueryPipeline()
.AddInMemoryQueryStorage();
.UsePersistedOperationPipeline()
.AddInMemoryOperationDocumentStorage();
}
else
{
graphQLServer
.UsePersistedQueryPipeline()
.AddFileSystemQueryStorage(context.QueriesPath);
.UsePersistedOperationPipeline()
.AddFileSystemOperationDocumentStorage(context.QueriesPath);
}

var app = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion src/ZeroQL.TestServer/Query/Models/Limit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Limit_2
{
public int Value { get; set; }

public Limit_2 Limit2 { get; set; }
public Limit_2? Limit2 { get; set; }
}

[GraphQLName("Limit3")]
Expand Down
Loading

0 comments on commit 67bba92

Please sign in to comment.