Skip to content
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
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
</PropertyGroup>
<ItemGroup>
<!-- Production dependencies -->
<PackageVersion Include="LibLog" Version="5.0.8" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.7" />
<PackageVersion Include="Serilog.AspNetCore" Version="10.0.0" />
<PackageVersion Include="Serilog.Sinks.Seq" Version="9.0.0" />
Expand Down
4 changes: 3 additions & 1 deletion examples/SimpleBlog/FakeBlogData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public static class FakeBlogData
new Post { Id = 2, Author = "Jane", Title = "Follow up post", Content = "This blog is really fun!" },
new Post
{
Id = 3, Author = "Gene", Title = "Guest post",
Id = 3,
Author = "Gene",
Title = "Guest post",
Content = "Jane has let me write a guest post for her blog."
}
};
Expand Down
16 changes: 2 additions & 14 deletions examples/SimpleBlog/Models/Mutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ public class Mutation
public bool AddPost(string author, string title, string post)
{
var newId = FakeBlogData.Posts.Max(_ => _.Id) + 1;
var postModel = new Post
{
Id = newId,
Author = author,
Title = title,
Content = post
};
var postModel = new Post { Id = newId, Author = author, Title = title, Content = post };
FakeBlogData.Posts.Add(postModel);
return true;
}
Expand All @@ -27,13 +21,7 @@ public bool AddPost(string author, string title, string post)
public bool Comment(int postId, string author, string comment)
{
var newId = FakeBlogData.Comments.Max(_ => _.Id) + 1;
var commentModel = new Comment
{
Id = newId,
PostId = postId,
Author = author,
Content = comment
};
var commentModel = new Comment { Id = newId, PostId = postId, Author = author, Content = comment };
FakeBlogData.Comments.Add(commentModel);
return true;
}
Expand Down
54 changes: 27 additions & 27 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<Product>GraphZen</Product>
<Authors>GraphZen</Authors>
<Company>GraphZen LLC</Company>
<Copyright>Copyright (c) 2017-2026 GraphZen LLC. All Rights Reserved.</Copyright>
<RepositoryUrl>https://github.com/GraphZen/graphzen-dotnet</RepositoryUrl>
<PackageProjectUrl>https://github.com/GraphZen/graphzen-dotnet</PackageProjectUrl>
<RepositoryType>Git</RepositoryType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IsPackable>True</IsPackable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RootNamespace>GraphZen</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<Product>GraphZen</Product>
<Authors>GraphZen</Authors>
<Company>GraphZen LLC</Company>
<Copyright>Copyright (c) 2017-2026 GraphZen LLC. All Rights Reserved.</Copyright>
<RepositoryUrl>https://github.com/GraphZen/graphzen-dotnet</RepositoryUrl>
<PackageProjectUrl>https://github.com/GraphZen/graphzen-dotnet</PackageProjectUrl>
<RepositoryType>Git</RepositoryType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IsPackable>True</IsPackable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RootNamespace>GraphZen</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
<None Include="..\..\README.md" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
<None Include="..\..\README.md" Pack="true" PackagePath="" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
});
</script>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public class PlaygroundHtmlWriter
private static JsonSerializerOptions SerializerOptions { get; } = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
Converters =
{
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
},
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) },
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using GraphZen.Internal;
using GraphZen.LanguageModel;
using GraphZen.LanguageModel.Internal;
using GraphZen.Logging;
using GraphZen.QueryEngine;
using GraphZen.QueryEngine.Validation;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

// ReSharper disable once CheckNamespace
namespace Microsoft.AspNetCore.Builder;
Expand All @@ -23,7 +23,6 @@ public static class GraphZenApplicationBuilderExtensions
private const int DefaultMemoryThreshold = 1024 * 30;

private static string? _sTempDirectory;
private static ILog Logger { get; } = LogProvider.GetCurrentClassLogger();

public static string TempDirectory
{
Expand Down Expand Up @@ -55,6 +54,8 @@ public static IEndpointConventionBuilder MapGraphQL(this IEndpointRouteBuilder e
{
return endpoints.MapPost(path, async httpContext =>
{
var logger = httpContext.RequestServices.GetRequiredService<ILoggerFactory>()
.CreateLogger(typeof(GraphZenApplicationBuilderExtensions));
var request = httpContext.Request;
var readStream = request.Body;
if (!request.Body.CanSeek)
Expand Down Expand Up @@ -109,20 +110,18 @@ public static IEndpointConventionBuilder MapGraphQL(this IEndpointRouteBuilder e

result = await new Executor().ExecuteAsync(graphQLContext.Schema, document,
rootValue,
graphQLContext, req.Variables, req.OperationName, new ExecutionOptions
{
ThrowOnError = false
});
graphQLContext, req.Variables, req.OperationName,
new ExecutionOptions { ThrowOnError = false });
}
}
catch (GraphQLException gqlException)
{
Logger.Error(gqlException, gqlException.Message);
logger.LogError(gqlException, "{Message}", gqlException.Message);
result = new ExecutionResult(null, new[] { gqlException.GraphQLError });
}
catch (Exception e)
{
Logger.Error(e, e.Message);
logger.LogError(e, "{Message}", e.Message);
var coreOptions = graphQLContext.Options.GetExtension<CoreOptionsExtension>();
var error = coreOptions.RevealInternalServerErrors
? new GraphQLServerError(e.Message, innerException: e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Reflection;
using GraphZen;
using GraphZen.Infrastructure;
using GraphZen.Logging;
using GraphZen.QueryEngine.Validation;
using Microsoft.Extensions.DependencyInjection.Extensions;

Expand All @@ -13,8 +12,6 @@ namespace Microsoft.Extensions.DependencyInjection;

public static class GraphZenServiceCollectionExtensions
{
private static ILog Logger { get; } = LogProvider.GetCurrentClassLogger();

public static void AddGraphQLContext(
this IServiceCollection serviceCollection,
Action<GraphQLContextOptionsBuilder>? optionsAction = null)
Expand All @@ -37,7 +34,6 @@ public static void AddGraphQLContext<TContext>(
: (Action<IServiceProvider, GraphQLContextOptionsBuilder>?)null;

var contextType = typeof(TContext);
Logger.Debug($"Adding GraphQL context {contextType}");
if (optionsAction != null)
{
var declaredConstructors = contextType.GetTypeInfo().DeclaredConstructors.ToList();
Expand All @@ -48,33 +44,26 @@ public static void AddGraphQLContext<TContext>(
}
}

Logger.Debug($"Registering {nameof(GraphQLContextOptions<TContext>)}");
serviceCollection.TryAdd(new ServiceDescriptor(typeof(GraphQLContextOptions<TContext>),
p => GraphQLContextOptionsFactory<TContext>(p, optionsActionImpl),
ServiceLifetime.Scoped));

Logger.Debug($"Registering {nameof(GraphQLContextOptions)}");
serviceCollection.Add(new ServiceDescriptor(typeof(GraphQLContextOptions),
p => p.GetRequiredService<GraphQLContextOptions<TContext>>(), ServiceLifetime.Scoped));


Logger.Debug($"Registering {typeof(TContext)}");
serviceCollection.TryAdd(new ServiceDescriptor(typeof(TContext),
typeof(TContext), ServiceLifetime.Scoped));

Logger.Debug($"Registering {nameof(GraphQLContext)}");
serviceCollection.TryAdd(new ServiceDescriptor(typeof(GraphQLContext),
p => p.GetRequiredService<TContext>(),
ServiceLifetime.Scoped));

Logger.Debug($"Registering {nameof(IQueryValidator)}");
serviceCollection.TryAddScoped<IQueryValidator>(_ => new QueryValidator());


Logger.Debug("Building temporary service provider");
var tempServiceProvider = serviceCollection.BuildServiceProvider();

Logger.Debug("Building temporary service provider");
var context = tempServiceProvider.GetRequiredService<TContext>();
var queryClrType = context.Schema.QueryType?.ClrType;
if (queryClrType != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public static class PlaygroundApplicationBuilderExtensions
[UsedImplicitly]
public static void UseGraphQLPlayground(this IApplicationBuilder app)
{
var shared = new SharedOptions
{
RequestPath = ""
};
var shared = new SharedOptions { RequestPath = "" };
var defaultFileOptions = new DefaultFilesOptions(shared);
// ReSharper disable once PossibleNullReferenceException
defaultFileOptions.DefaultFileNames.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ public static HttpRequestMessage ToHttpRequest(this GraphQLRequest request)

var requestJson = JsonSerializer.Serialize(request);
var requestJsonContent = new StringContent(requestJson, Encoding.UTF8, "application/json");
var message = new HttpRequestMessage
{
Method = HttpMethod.Post,
Content = requestJsonContent
};
var message = new HttpRequestMessage { Method = HttpMethod.Post, Content = requestJsonContent };
return message;
}
}
10 changes: 3 additions & 7 deletions src/GraphZen.DevCli/CodeGen/CodeGenTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ namespace GraphZen.TypeSystem {

var fieldAccessors = new List<(string containerType, string valueType)>
{
("InterfaceType", "Field"),
("ObjectType", "Field"),
("InputObjectType", "InputField")
("InterfaceType", "Field"), ("ObjectType", "Field"), ("InputObjectType", "InputField")
};

foreach (var (containerType, valueType) in fieldAccessors)
Expand All @@ -66,8 +64,7 @@ namespace GraphZen.TypeSystem {

var argumentDefinitionAccessors = new List<(string containerType, string valueType)>
{
("FieldDefinition", "ArgumentDefinition"),
("DirectiveDefinition", "ArgumentDefinition")
("FieldDefinition", "ArgumentDefinition"), ("DirectiveDefinition", "ArgumentDefinition")
};

foreach (var (containerType, valueType) in argumentDefinitionAccessors)
Expand All @@ -78,8 +75,7 @@ namespace GraphZen.TypeSystem {

var argumentAccessors = new List<(string containerType, string valueType)>
{
("Field", "Argument"),
("IArguments", "Argument")
("Field", "Argument"), ("IArguments", "Argument")
};

foreach (var (containerType, valueType) in argumentAccessors)
Expand Down
12 changes: 2 additions & 10 deletions src/GraphZen.Infrastructure/GraphZen.Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Infrastructure code supporting the GraphZen SDK. Not intended for direct installation or use.</Description>
<DefineConstants>LIBLOG_EXCLUDE_CODE_COVERAGE;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibLog">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GraphZen.Abstractions\GraphZen.Abstractions.csproj" />
</ItemGroup>

</Project>
</Project>
5 changes: 1 addition & 4 deletions src/GraphZen.Infrastructure/Infrastructure/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ public static class Json
[DebuggerStepThrough]
public static string SerializeObject(object value)
{
var options = new JsonSerializerOptions(SerializerOptions)
{
WriteIndented = true
};
var options = new JsonSerializerOptions(SerializerOptions) { WriteIndented = true };
return JsonSerializer.Serialize(value, options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,4 @@ public virtual TResult LeaveOperationTypeDefinition(OperationTypeDefinitionSynta

/// <summary>Called when the visitor leaves a <see cref="VariableSyntax" /> node.</summary>
public virtual TResult LeaveVariable(VariableSyntax node) => OnLeave(node);
}
}
3 changes: 2 additions & 1 deletion src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ public void Join(IReadOnlyList<SyntaxNode> nodes, Action? seperatorAction = null

private void Join(IReadOnlyList<SyntaxNode> nodes, string? seperator = null)
{
Join(nodes, seperator != null ? () => { Append(seperator); }
Join(nodes, seperator != null
? () => { Append(seperator); }
: null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1380,4 +1380,4 @@ public override TResult VisitEnter<TResult>(GraphQLSyntaxVisitor<TResult> visito
/// <summary>Called when a <see cref="GraphQLSyntaxVisitor{TResult}" /> leaves a <see cref="VariableSyntax" /> node.</summary>
public override TResult VisitLeave<TResult>(GraphQLSyntaxVisitor<TResult> visitor) =>
visitor.LeaveVariable(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,11 @@ public static class DocumentValidationRules
SpecifiedSdlRules.Concat(
new[]
{
SchemaMustHaveRootObjectTypes,
FieldArgsMustBeProperlyNamed,
UnionTypesMustBeValid,
InputObjectsMustHaveFields,
EnumTypesMustBeWellDefined,
ObjectFieldsMustHaveOutputTypes,
ObjectsCanOnlyImplementUniqueInterfaces,
InterfaceExtensionsShouldBeValid,
InterfaceFieldsMustHaveOutputTypes,
FieldArgumentsMustHaveInputTypes,
ObjectsMustAdhereToInterfaceTheyImplement,
ObjectsMustHaveFields,
SchemaMustHaveRootObjectTypes, FieldArgsMustBeProperlyNamed, UnionTypesMustBeValid,
InputObjectsMustHaveFields, EnumTypesMustBeWellDefined, ObjectFieldsMustHaveOutputTypes,
ObjectsCanOnlyImplementUniqueInterfaces, InterfaceExtensionsShouldBeValid,
InterfaceFieldsMustHaveOutputTypes, FieldArgumentsMustHaveInputTypes,
ObjectsMustAdhereToInterfaceTheyImplement, ObjectsMustHaveFields,
InputObjectFieldsMustHaveInputTypes
}).ToList();
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ public override VisitAction LeaveDocument(DocumentSyntax node)
return n.Fields;
}).Any())
{
var nodes = new List<SyntaxNode>
{
objectTypeNode.Name
};
var nodes = new List<SyntaxNode> { objectTypeNode.Name };
// ReSharper disable once PossibleNullReferenceException
nodes.AddRange(extensionNodes.Select(_ => _.Name));
ReportError($"Type {objectTypeName} must define one or more fields.", nodes);
Expand Down
Loading
Loading