GraphQL support for 8.0+ (#3615)
This commit is contained in:
parent
fce3682e4f
commit
e7bb24d4ec
|
|
@ -57,7 +57,7 @@ public static partial class LibraryVersion
|
|||
new List<PackageBuildInfo>
|
||||
{
|
||||
new("7.5.0", additionalMetaData: new() {{"GraphQLMicrosoftDI","7.5.0"},{"GraphQLServerTransportsAspNetCore","7.5.0"},{"GraphQLServerUIPlayground","7.5.0"}}),
|
||||
new("7.8.0", additionalMetaData: new() {{"GraphQLMicrosoftDI","7.8.0"},{"GraphQLServerTransportsAspNetCore","7.7.1"},{"GraphQLServerUIPlayground","7.7.1"}}),
|
||||
new("8.0.2", additionalMetaData: new() {{"GraphQLMicrosoftDI","8.0.2"},{"GraphQLServerTransportsAspNetCore","8.0.2"},{"GraphQLServerUIPlayground","8.0.2"}}),
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ due to lack of stable semantic convention.
|
|||
| `ELASTICSEARCH` | [Elastic.Clients.Elasticsearch](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch) | * \[4\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `ELASTICTRANSPORT` | [Elastic.Transport](https://www.nuget.org/packages/Elastic.Transport) | ≥0.4.16 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `ENTITYFRAMEWORKCORE` | [Microsoft.EntityFrameworkCore](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore) **Not supported on .NET Framework** | ≥6.0.12 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `GRAPHQL` | [GraphQL](https://www.nuget.org/packages/GraphQL) **Not supported on .NET Framework** | ≥7.5.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `GRAPHQL` | [GraphQL](https://www.nuget.org/packages/GraphQL) **Not supported on .NET Framework** | ≥7.5.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `GRPCNETCLIENT` | [Grpc.Net.Client](https://www.nuget.org/packages/Grpc.Net.Client) | ≥2.52.0 & < 3.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `HTTPCLIENT` | [System.Net.Http.HttpClient](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) and [System.Net.HttpWebRequest](https://docs.microsoft.com/dotnet/api/system.net.httpwebrequest) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
| `KAFKA` | [Confluent.Kafka](https://www.nuget.org/packages/Confluent.Kafka) | ≥1.4.0 & < 3.0.0 \[5\] | bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
<PackageVersion Include="Confluent.Kafka" Version="2.5.3" />
|
||||
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageVersion Include="Google.Protobuf" Version="3.28.0" />
|
||||
<PackageVersion Include="GraphQL" Version="7.8.0" />
|
||||
<PackageVersion Include="GraphQL.MicrosoftDI" Version="7.8.0" />
|
||||
<PackageVersion Include="GraphQL.Server.Transports.AspNetCore" Version="7.7.1" />
|
||||
<PackageVersion Include="GraphQL.Server.Ui.Playground" Version="7.7.1" />
|
||||
<PackageVersion Include="GraphQL" Version="8.0.2" />
|
||||
<PackageVersion Include="GraphQL.MicrosoftDI" Version="8.0.2" />
|
||||
<PackageVersion Include="GraphQL.Server.Transports.AspNetCore" Version="8.0.2" />
|
||||
<PackageVersion Include="GraphQL.Server.Ui.Playground" Version="8.0.2" />
|
||||
<PackageVersion Include="Grpc.AspNetCore" Version="2.65.0" />
|
||||
<PackageVersion Include="Grpc.Net.Client" Version="2.65.0" />
|
||||
<PackageVersion Include="Grpc.Net.Client.Web" Version="2.65.0" />
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public static partial class LibraryVersion
|
|||
theoryData.Add(string.Empty);
|
||||
#else
|
||||
theoryData.Add("7.5.0");
|
||||
theoryData.Add("7.8.0");
|
||||
theoryData.Add("8.0.2");
|
||||
#endif
|
||||
return theoryData;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Net.Http;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
namespace TestApplication.GraphQL;
|
||||
|
||||
/// <summary>
|
||||
/// Middleware to handle CSRF protection for GraphQL GET requests.
|
||||
/// GraphQL servers require the "GraphQL-Require-Preflight" header to bypass
|
||||
/// CSRF checks for GET requests. This middleware adds the header to ensure
|
||||
/// that GET requests are not blocked due to missing CSRF tokens.
|
||||
/// </summary>
|
||||
public class CsrfMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public CsrfMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
context.Request.Headers["GraphQL-Require-Preflight"] = "1";
|
||||
|
||||
await _next(context);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
using System.Collections;
|
||||
using TestApplication.Shared;
|
||||
|
||||
namespace TestApplication.GraphQL;
|
||||
|
||||
|
|
@ -22,14 +23,7 @@ public class Program
|
|||
|
||||
var logger = host.Services.GetRequiredService<ILogger<Program>>();
|
||||
|
||||
var prefixes = new[] { "COR_", "CORECLR_", "DOTNET_", "OTEL_" };
|
||||
var envVars = from envVar in Environment.GetEnvironmentVariables().Cast<DictionaryEntry>()
|
||||
from prefix in prefixes
|
||||
let key = (envVar.Key as string)?.ToUpperInvariant()
|
||||
let value = envVar.Value as string
|
||||
where key.StartsWith(prefix)
|
||||
orderby key
|
||||
select new KeyValuePair<string, string>(key, value);
|
||||
var envVars = ProfilerHelper.GetEnvironmentConfiguration();
|
||||
|
||||
foreach (var kvp in envVars)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ public class StarWarsSchema : Schema
|
|||
public StarWarsSchema(IServiceProvider provider)
|
||||
: base(provider)
|
||||
{
|
||||
Query = provider.GetService(typeof(StarWarsQuery)) as StarWarsQuery ?? throw new InvalidOperationException();
|
||||
Mutation = provider.GetService(typeof(StarWarsMutation)) as StarWarsMutation ?? throw new InvalidOperationException();
|
||||
Subscription = provider.GetService(typeof(StarWarsSubscription)) as StarWarsSubscription ?? throw new InvalidOperationException();
|
||||
Query = provider.GetRequiredService<StarWarsQuery>();
|
||||
Mutation = provider.GetRequiredService<StarWarsMutation>();
|
||||
Subscription = provider.GetRequiredService<StarWarsSubscription>();
|
||||
|
||||
FieldMiddleware.Use(new InstrumentFieldsMiddleware());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
using GraphQL;
|
||||
using GraphQL.SystemTextJson;
|
||||
using GraphQL.Transport;
|
||||
using GraphQL.Types;
|
||||
using StarWars;
|
||||
|
||||
|
|
@ -21,6 +23,7 @@ public class Startup
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseMiddleware<CsrfMiddleware>();
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseWebSockets();
|
||||
app.UseGraphQL<ISchema>();
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ internal static class PackageVersionDefinitions
|
|||
Versions = new List<GraphQLVersion>
|
||||
{
|
||||
new("7.5.0") { MicrosoftDIVersion = "7.5.0", ServerTransportsAspNetCoreVersion = "7.5.0", ServerUIPlayground = "7.5.0" },
|
||||
new("8.0.2") { MicrosoftDIVersion = "8.0.2", ServerTransportsAspNetCoreVersion = "8.0.2", ServerUIPlayground = "8.0.2" },
|
||||
new("*") { MicrosoftDIVersion = "*", ServerTransportsAspNetCoreVersion = "*", ServerUIPlayground = "*" },
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue