Skip to content

Commit

Permalink
Bump to GraphQL.NET v8 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 authored Aug 20, 2024
1 parent 6f3add4 commit f3fb80c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<IsPackable>false</IsPackable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<AnalysisMode>Recommended</AnalysisMode>
<GraphQLVersion>7.0.0</GraphQLVersion>
<GraphQLAspNetCore3Version>5.0.0</GraphQLAspNetCore3Version>
<GraphQLVersion>8.0.0</GraphQLVersion>
<GraphQLAspNetCore3Version>6.0.0</GraphQLAspNetCore3Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="EfLocalDb" Version="8.5.0" />
<PackageReference Include="GraphQL.DataLoader" Version="$(GraphQLVersion)" />
<PackageReference Include="GraphQL.AspNetCore3" Version="$(GraphQLAspNetCore3Version)" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="$(GraphQLVersion)" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="7.7.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.16" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions src/GraphQL.DI/DIObjectGraphBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public abstract class DIObjectGraphBase<TSource> : IDIObjectGraphBase<TSource>,
Dictionary<string, (GraphQLField Field, FieldType FieldType)>? IResolveFieldContext.SubFields => Context.SubFields;
IReadOnlyDictionary<string, object?> IResolveFieldContext.InputExtensions => Context.InputExtensions;
IDictionary<string, object?> IResolveFieldContext.OutputExtensions => Context.OutputExtensions;
IExecutionContext IResolveFieldContext.ExecutionContext => Context.ExecutionContext;
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/DIObjectGraphBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void SourceTyped()
[Fact]
public void RFC_FieldAst()
{
var fieldAst = new GraphQLField();
var fieldAst = new GraphQLField(new("test"));
_mockContext.Setup(x => x.FieldAst).Returns(fieldAst);
_graphContext.FieldAst.ShouldBe(fieldAst);
}
Expand Down Expand Up @@ -130,15 +130,15 @@ public void RFC_Schema()
[Fact]
public void RFC_Document()
{
var obj = new GraphQLDocument();
var obj = new GraphQLDocument(new());
_mockContext.Setup(x => x.Document).Returns(obj);
_graphContext.Document.ShouldBe(obj);
}

[Fact]
public void RFC_Operation()
{
var obj = new GraphQLOperationDefinition();
var obj = new GraphQLOperationDefinition(new(new()));
_mockContext.Setup(x => x.Operation).Returns(obj);
_graphContext.Operation.ShouldBe(obj);
}
Expand Down
17 changes: 15 additions & 2 deletions src/Tests/DIObjectGraphTypeTests/Argument.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Globalization;
using GraphQL.Conversion;

namespace DIObjectGraphTypeTests;

Expand Down Expand Up @@ -128,10 +129,22 @@ public void IdNonNull()
{
Configure<CIdGraphType2, object>();
VerifyFieldArgument("Field1", "arg", typeof(NonNullGraphType<IdGraphType>), "3");
VerifyField("Field1", true, false, "3");
InitializeSchema();
VerifyField("Field1", typeof(StringGraphType), false, "3");
Verify(false);
}

private void InitializeSchema()
{
if (_graphType == null)
throw new InvalidOperationException();
var schema = new Schema { Query = new ObjectGraphType() { Name = "Query" } };
schema.Query.AddField(new FieldType { Name = "dummy", Type = typeof(StringGraphType) });
schema.RegisterType(_graphType);
schema.NameConverter = DefaultNameConverter.Instance;
schema.Initialize();
}

public class CIdGraphType2 : DIObjectGraphBase
{
public static string? Field1([Id] int arg) => arg.ToString(CultureInfo.InvariantCulture);
Expand Down Expand Up @@ -160,7 +173,7 @@ public void DefaultValue()
Configure<CDefaultValue, object>();
VerifyFieldArgument("Field1", "arg1", false, 2);
VerifyField("Field1", false, false, 2);
VerifyFieldArgument<int>("Field2", "arg2", false);
VerifyFieldArgument("Field2", "arg2", false, 5); // as of version 8, IResolveFieldContext.Arguments include the default values
VerifyField("Field2", false, false, 5);
Verify(false);
}
Expand Down

0 comments on commit f3fb80c

Please sign in to comment.