Skip to content

Commit

Permalink
Update to server v6 release (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r authored May 22, 2022
1 parent 188feec commit 5ad6b1c
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
dotnet-version: '6.0.102'

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
queries: security-and-quality
languages: csharp
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Build CodeQL solution
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/troubleshooting-the-codeql-workflow#reduce-the-amount-of-code-being-analyzed-in-a-single-workflow
working-directory: codeql
run: dotnet build --no-restore
run: dotnet build --no-restore -p:UseSharedCompilation=false

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
1 change: 1 addition & 0 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- windows-latest
graphqlversion:
- 5.0.0
- 5.2.0
steps:
- name: Checkout source
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<IsPackable>true</IsPackable>
<!--<TreatWarningsAsErrors>true</TreatWarningsAsErrors>-->
<GraphQLTestVersion>5.0.0</GraphQLTestVersion>
<GraphQLTestVersion>5.2.0</GraphQLTestVersion>
</PropertyGroup>

</Project>
3 changes: 1 addition & 2 deletions src/GraphQL.Relay.StarWars/Api/Entities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ public interface ISwapiResponse { }

public class EntityList<TEntity> : ISwapiResponse
{

public int Count { get; set; }
public Uri Next { get; set; }
public Uri Previous { get; set; }
public List<TEntity> Results = new List<TEntity>();
public List<TEntity> Results = new();
}

public class Entity : ISwapiResponse
Expand Down
11 changes: 4 additions & 7 deletions src/GraphQL.Relay.StarWars/Api/Swapi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ public class Swapi
private const string API_BASE = "http://swapi.dev/api";
private readonly ResponseCache _cache = new();

private string GetResource<T>() where T : Entity
{
return typeof(T).Name.ToLower();
}
private static string GetResource<T>() where T : Entity => typeof(T).Name.ToLower();

public Swapi(ResponseCache cache)
{
Expand Down Expand Up @@ -70,7 +67,7 @@ public Task<IEnumerable<T>> GetMany<T>(IEnumerable<Uri> urls)
where T : Entity =>
FetchManyAsync<T>(urls);

private bool DoneFetching(int count, ConnectionArguments args)
private static bool DoneFetching(int count, ConnectionArguments args)
{
if (args.After != null || args.Before != null || args.Last != null || args.First == null)
return false;
Expand All @@ -82,7 +79,7 @@ public async Task<List<T>> GetConnectionAsync<T>(ConnectionArguments args)
{
var nextUrl = new Uri($"{API_BASE}/{typeof(T).Name.ToLower()}/");
var entities = new List<T>();
var canStopEarly =
var canStopEarly = // TODO: unused ?
args.After != null ||
args.Before != null ||
args.Last != null ||
Expand All @@ -99,7 +96,7 @@ public async Task<List<T>> GetConnectionAsync<T>(ConnectionArguments args)
return entities;
}

private T DeserializeObject<T>(string payload)
private static T DeserializeObject<T>(string payload)
{
return JsonConvert.DeserializeObject<T>(
payload,
Expand Down
8 changes: 4 additions & 4 deletions src/GraphQL.Relay.StarWars/GraphQL.Relay.StarWars.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL.MicrosoftDI" Version="5.0.0" />
<PackageReference Include="GraphQL.SystemTextJson" Version="5.0.0" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="6.0.0-preview-176" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="6.0.0-preview-176" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="5.2.0" />
<PackageReference Include="GraphQL.SystemTextJson" Version="5.2.0" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="6.0.0" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Relay.StarWars/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void ConfigureServices(IServiceCollection services)
.AddSingleton<ResponseCache>();

services.AddGraphQL(b => b
.AddServer(true)
.AddMetrics(true)
.AddHttpMiddleware<StarWarsSchema>()
.AddSchema<StarWarsSchema>()
.AddSystemTextJson()
Expand Down
8 changes: 4 additions & 4 deletions src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL.MicrosoftDI" Version="5.0.0" />
<PackageReference Include="GraphQL.SystemTextJson" Version="5.0.0" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="6.0.0-preview-176" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="6.0.0-preview-176" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="5.2.0" />
<PackageReference Include="GraphQL.SystemTextJson" Version="5.2.0" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="6.0.0" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.5" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Relay.Todo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddGraphQL(b => b
.AddServer(true)
.AddMetrics(true)
.AddHttpMiddleware<TodoSchema>()
.AddSchema<TodoSchema>()
.AddSystemTextJson()
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Relay/GraphQL.Relay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL" Version="5.0.0" />
<PackageReference Include="GraphQL" Version="5.2.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/GraphQL.Relay/Types/MutationPayloadGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private string GetClientId(IResolveFieldContext<TSource> context)
return (string)value.Value; // TODO: string allocation
}

private bool IsCorrectSelection(IResolveFieldContext<TSource> context, GraphQLField field)
private static bool IsCorrectSelection(IResolveFieldContext<TSource> context, GraphQLField field)
{
return Enumerable.Any(field.SelectionSet.Selections,
s => s.Location.Equals(context.FieldAst.Location));
Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL.Relay/Types/NodeGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ public FieldType Id<TReturnType>(string name, Expression<Func<T, TReturnType>> e
if (name.ToLower() == "id")
{
if (string.IsNullOrWhiteSpace(Name))
{
throw new InvalidOperationException(
"The parent GraphQL type must define a Name before declaring the Id field " +
"in order to properly prefix the local id field");
}

name = (Name + "Id").ToCamelCase();
}
Expand Down

0 comments on commit 5ad6b1c

Please sign in to comment.