Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump GraphQL.NET to v8 #295

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
pack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Check formatting

on:
pull_request:
branches:
- master
- develop
paths:
- src/**
- .github/workflows/**
Expand All @@ -18,11 +15,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check github.ref starts with 'refs/tags/'
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
Expand All @@ -28,9 +28,9 @@ jobs:
echo version=$version
echo "version=$version" >> $GITHUB_ENV
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Run code tests

on:
pull_request:
branches:
- master
- develop
paths:
- src/**
- .github/workflows/**
Expand All @@ -27,22 +24,21 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
graphqlversion:
- 7.0.0
- 7.1.1
- 7.2.2
- 8.0.0
name: ${{ matrix.os }}/${{ matrix.graphqlversion }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
8 changes: 4 additions & 4 deletions src/BasicSample/BasicSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -15,9 +15,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GraphQL.MicrosoftDI" Version="7.*" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.*" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="8.*" />
<PackageReference Include="GraphQL.SystemTextJson" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.*" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>

<PropertyGroup>
<VersionPrefix>7.0.0-preview</VersionPrefix>
<NextVersion>8.0.0</NextVersion>
<VersionPrefix>8.0.0-preview</VersionPrefix>
<NextVersion>9.0.0</NextVersion>
<LangVersion>latest</LangVersion>
<Authors>Joe McBride</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Authorization.ApiTests/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public void public_api_should_not_change_unintentionally(Type type)
// Note: If the AssemblyName.approved.txt file doesn't match the latest publicApi value,
// this call will try to launch a diff tool to help you out but that can fail on
// your machine if a diff tool isn't configured/setup.
publicApi.ShouldMatchApproved(options => options.WithFilenameGenerator((_, _, fileType, fileExtension) => $"{type.Assembly.GetName().Name}.{fileType}.{fileExtension}"));
publicApi.ShouldMatchApproved(options => options.NoDiff().WithFilenameGenerator((_, _, fileType, fileExtension) => $"{type.Assembly.GetName().Name}.{fileType}.{fileExtension}"));
}
}
43 changes: 0 additions & 43 deletions src/GraphQL.Authorization.ApiTests/BomTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="../Tests.props" />

<PropertyGroup>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ namespace GraphQL.Authorization
public System.Collections.Generic.IEnumerable<GraphQL.Authorization.IAuthorizationPolicy> GetPolicies(System.Collections.Generic.IEnumerable<string> policies) { }
public GraphQL.Authorization.IAuthorizationPolicy? GetPolicy(string name) { }
}
public class AuthorizationValidationRule : GraphQL.Validation.IValidationRule
public class AuthorizationValidationRule : GraphQL.Validation.ValidationRuleBase
{
public AuthorizationValidationRule(GraphQL.Authorization.IAuthorizationEvaluator evaluator) { }
public System.Threading.Tasks.ValueTask<GraphQL.Validation.INodeVisitor?> ValidateAsync(GraphQL.Validation.ValidationContext context) { }
public override System.Threading.Tasks.ValueTask<GraphQL.Validation.INodeVisitor?> GetPreNodeVisitorAsync(GraphQL.Validation.ValidationContext context) { }
}
public class ClaimAuthorizationRequirement : GraphQL.Authorization.IAuthorizationRequirement
{
Expand Down
28 changes: 11 additions & 17 deletions src/GraphQL.Authorization.Tests/AuthorizationValidationRuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,27 +424,20 @@ public class Author
private static ISchema TypedSchema()
{
var query = new ObjectGraphType();
query.Field<StringGraphType>(
"author",
arguments: new QueryArguments(new QueryArgument<AuthorInputType> { Name = "input" }),
resolve: _ => "testing"
);

query.Connection<PostGraphType>()
.Name("posts")
query.Field<StringGraphType>("author")
.Arguments(new QueryArguments(new QueryArgument<AuthorInputType> { Name = "input" }))
.Resolve(_ => "testing");

query.Connection<PostGraphType>("posts")
.AuthorizeWithPolicy("ConnectionPolicy")
.Resolve(_ => new Connection<Post>());

query.Field<StringGraphType>(
"project",
arguments: new QueryArguments(new QueryArgument<AuthorInputType> { Name = "input" }),
resolve: _ => "testing"
).AuthorizeWithPolicy("AdminPolicy").AuthorizeWithPolicy("ConfidentialPolicy");
query.Field<StringGraphType>("project")
.Arguments(new QueryArguments(new QueryArgument<AuthorInputType> { Name = "input" }))
.Resolve(_ => "testing").AuthorizeWithPolicy("AdminPolicy").AuthorizeWithPolicy("ConfidentialPolicy");

query.Field<ArticleGraphType>(
"article",
resolve: _ => null
);
query.Field<ArticleGraphType>("article")
.Resolve(_ => null);

return new Schema { Query = query };
}
Expand All @@ -453,6 +446,7 @@ public class AuthorInputType : InputObjectGraphType<Author>
{
public AuthorInputType()
{
Name = "AuthorInputType";
Field(x => x.Name).AuthorizeWithPolicy("FieldPolicy");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<Import Project="../Tests.props" />

<PropertyGroup Condition="'$(SingleTestPlatform)' == 'true'">
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(SingleTestPlatform)' != 'true'">
<TargetFrameworks>net7;net6;net5;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<GraphQLTestVersion>7.0.0</GraphQLTestVersion>
<GraphQLTestVersion>8.0.0</GraphQLTestVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Authorization.Tests/ValidationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static IValidationResult Validate(ValidationTestConfig config)
Rules = config.Rules,
Variables = config.Variables ?? Inputs.Empty,
User = config.User
}).GetAwaiter().GetResult().validationResult;
}).GetAwaiter().GetResult();
}

internal static ClaimsPrincipal CreatePrincipal(string? authenticationType = null, IDictionary<string, string>? claims = null)
Expand Down
6 changes: 3 additions & 3 deletions src/GraphQL.Authorization/AuthorizationValidationRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GraphQL.Authorization;
/// GraphQL authorization validation rule which evaluates configured
/// (via policies) requirements on schema elements: types, fields, etc.
/// </summary>
public class AuthorizationValidationRule : IValidationRule
public class AuthorizationValidationRule : ValidationRuleBase
{
private readonly IAuthorizationEvaluator _evaluator;

Expand All @@ -22,7 +22,7 @@ public AuthorizationValidationRule(IAuthorizationEvaluator evaluator)
}

/// <inheritdoc />
public async ValueTask<INodeVisitor?> ValidateAsync(ValidationContext context)
public override async ValueTask<INodeVisitor?> GetPreNodeVisitorAsync(ValidationContext context)
{
var visitor = new Visitor(_evaluator);

Expand Down Expand Up @@ -113,7 +113,7 @@ public ValueTask LeaveAsync(ASTNode node, ValidationContext context)
return default;
}

public async ValueTask AuthorizeAsync(ASTNode? node, IProvideMetadata? provider, ValidationContext context)
public async ValueTask AuthorizeAsync(ASTNode? node, IMetadataReader? provider, ValidationContext context)
{
if (provider == null || !provider.IsAuthorizationRequired())
return;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Authorization/GraphQL.Authorization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL" Version="7.0.0" />
<PackageReference Include="GraphQL" Version="8.0.0" />
</ItemGroup>

</Project>
11 changes: 5 additions & 6 deletions src/Harness/Harness.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Description>Example ASP.NET Core project to demonstrate GraphQL.NET Authorization setup</Description>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -11,11 +11,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GraphQL.MicrosoftDI" Version="7.*" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="7.*" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="7.*" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="7.*" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.*" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="8.*" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="8.*" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="8.*" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="8.*" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading