Skip to content

Commit

Permalink
Fixed Compile Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Oct 14, 2024
1 parent accf41b commit 5149561
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/GreenDonut/src/Core/DataLoaderFetchContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#endif
#if NET6_0_OR_GREATER
using GreenDonut.Selectors;
using GreenDonut.Predicates;
#endif

namespace GreenDonut;
Expand Down
2 changes: 1 addition & 1 deletion src/GreenDonut/src/Core/IDataLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Immutable;
#if NET8_0_OR_GREATER
using GreenDonut.Projections;
using GreenDonut.Selectors;
#endif

namespace GreenDonut;
Expand Down
4 changes: 4 additions & 0 deletions src/GreenDonut/src/Core/Predicates/DefaultPredicateBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;

namespace GreenDonut.Predicates;

#if NET8_0_OR_GREATER
[Experimental(Experiments.Predicates)]
#endif
internal sealed class DefaultPredicateBuilder : IPredicateBuilder
{
private List<LambdaExpression>? _predicates;
Expand Down Expand Up @@ -49,3 +52,4 @@ public void Add<T>(Expression<Func<T, bool>> selector)
return expression;
}
}
#endif
2 changes: 2 additions & 0 deletions src/GreenDonut/src/Core/Predicates/IPredicateBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace GreenDonut.Predicates;
/// The predicate builder helps you create a combined predicate expression
/// by adding multiple expressions together.
/// </summary>
#if NET8_0_OR_GREATER
[Experimental(Experiments.Predicates)]
#endif
public interface IPredicateBuilder
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;

Expand All @@ -6,7 +7,9 @@ namespace GreenDonut.Predicates;
/// <summary>
/// Data loader extensions for predicates.
/// </summary>
#if NET8_0_OR_GREATER
[Experimental(Experiments.Predicates)]
#endif
public static class PredicateDataLoaderExtensions
{
/// <summary>
Expand Down Expand Up @@ -113,3 +116,4 @@ public static IQueryable<T> Where<T>(
return query;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ namespace GreenDonut.Predicates;
/// <summary>
/// Provides extension methods for projection on DataLoader.
/// </summary>
#if NET8_0_OR_GREATER
[Experimental(Experiments.Predicates)]
#endif
public static class HotChocolateExecutionPredicateDataLoaderExtensions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if NET6_0_OR_GREATER
using System.Linq.Expressions;
using CookieCrumble;
using GreenDonut;
Expand Down Expand Up @@ -38,7 +39,13 @@ public async Task Filter_With_Expression()
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#elif NET7_0
Snapshot.Create("NET7_0")
#else
Snapshot.Create("NET6_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down Expand Up @@ -70,7 +77,13 @@ public async Task Filter_With_Multi_Expression()
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#elif NET7_0
Snapshot.Create("NET7_0")
#else
Snapshot.Create("NET6_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down Expand Up @@ -102,7 +115,11 @@ public async Task Filter_With_Filtering()
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#else
Snapshot.Create("NET6_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down Expand Up @@ -134,7 +151,11 @@ public async Task Filter_With_Expression_Null()
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#else
Snapshot.Create("NET6_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down Expand Up @@ -277,3 +298,4 @@ public static Snapshot AddResult(this Snapshot snapshot, IExecutionResult result
return snapshot;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Pagination\src\Pagination.Mappings\HotChocolate.Pagination.Mappings.csproj" />
<ProjectReference Include="..\..\src\Data\HotChocolate.Data.csproj" />
<ProjectReference Include="..\..\src\EntityFramework\HotChocolate.Data.EntityFramework.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Filter_With_Expression

## SQL

```text
SELECT "b"."Id", "b"."DisplayName", "b"."Name", "b"."Details_Country_Name"
FROM "Brands" AS "b"
WHERE ("b"."Id" = 1) AND ("b"."Name" LIKE 'Brand%')
```

## Result

```json
{
"data": {
"filterExpression": {
"name": "Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Filter_With_Expression

## SQL

```text
SELECT "b"."Id", "b"."DisplayName", "b"."Name", "b"."Details_Country_Name"
FROM "Brands" AS "b"
WHERE "b"."Id" = 1 AND ("b"."Name" LIKE 'Brand%')
```

## Result

```json
{
"data": {
"filterExpression": {
"name": "Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Filter_With_Expression_Null

## SQL

```text
SELECT "b"."Id", "b"."DisplayName", "b"."Name", "b"."Details_Country_Name"
FROM "Brands" AS "b"
WHERE "b"."Id" = 1
```

## Result

```json
{
"data": {
"brandByIdFilterNull": {
"name": "Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Filter_With_Filtering

## SQL

```text
SELECT "p"."Id", "p"."AvailableStock", "p"."BrandId", "p"."Description", "p"."ImageFileName", "p"."MaxStockThreshold", "p"."Name", "p"."OnReorder", "p"."Price", "p"."RestockThreshold", "p"."TypeId"
FROM "Products" AS "p"
WHERE "p"."BrandId" = 1
```

## Result

```json
{
"data": {
"filterContext": [
{
"name": "Product 0-0"
}
]
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Filter_With_Multi_Expression

## SQL

```text
SELECT "b"."Id", "b"."DisplayName", "b"."Name", "b"."Details_Country_Name"
FROM "Brands" AS "b"
WHERE ("b"."Id" = 1) AND (("b"."Name" LIKE 'Brand%') AND ("b"."Name" LIKE '%0'))
```

## Result

```json
{
"data": {
"multiFilterExpression": {
"name": "Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Filter_With_Multi_Expression

## SQL

```text
SELECT "b"."Id", "b"."DisplayName", "b"."Name", "b"."Details_Country_Name"
FROM "Brands" AS "b"
WHERE "b"."Id" = 1 AND ("b"."Name" LIKE 'Brand%') AND ("b"."Name" LIKE '%0')
```

## Result

```json
{
"data": {
"multiFilterExpression": {
"name": "Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public static class HotChocolatePaginationBatchingDataLoaderPredicateExtensions
/// <exception cref="ArgumentNullException">
/// Throws if the <paramref name="dataLoader"/> is <c>null</c>.
/// </exception>
#if NET8_0_OR_GREATER
[Experimental(Experiments.Predicates)]
#endif
public static IPagingDataLoader<TKey, Page<TValue>> Where<TKey, TValue>(
this IPagingDataLoader<TKey, Page<TValue>> dataLoader,
Expression<Func<TValue, bool>>? predicate)
Expand Down

0 comments on commit 5149561

Please sign in to comment.