Skip to content

Commit

Permalink
Fixed compile and test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Oct 2, 2024
1 parent 8631e30 commit 41f2efb
Show file tree
Hide file tree
Showing 13 changed files with 710 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/CookieCrumble/src/CookieCrumble/QueryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace CookieCrumble;

public sealed class QueryInfo
{
public required string QueryText { get; init; }
public string QueryText { get; init; } = default!;

public required string ExpressionText { get; init; }
public string ExpressionText { get; init; } = default!;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if NET6_0_OR_GREATER
namespace HotChocolate.Execution.Projections;

internal class TypeContainer(List<TypeNode>? nodes = null)
Expand Down Expand Up @@ -53,3 +54,4 @@ public void Seal()
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public async Task Brand_With_Name_Selector_is_Null()
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#else
Snapshot.Create(postFix: "NET7_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down Expand Up @@ -502,7 +506,11 @@ public async Task Brand_Details_Requires_Brand_Name_With_Proper_Type()
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#else
Snapshot.Create(postFix: "NET7_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down Expand Up @@ -534,7 +542,11 @@ public async Task Brand_Details_Requires_Brand_Name_With_Proper_Type_With_Explic
}
""");

#if NET8_0_OR_GREATER
Snapshot.Create()
#else
Snapshot.Create(postFix: "NET7_0")
#endif
.AddSql(queries)
.AddResult(result)
.MatchMarkdownSnapshot();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Brand_Details_Requires_Brand_Name_With_Proper_Type

## SQL

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

## Result

```json
{
"data": {
"brandById": {
"details": "Brand Name:Brand0"
}
}
}
```

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

## SQL

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

## Result

```json
{
"data": {
"brandById": {
"details": "Brand Name:Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Brand_With_Name_Selector_is_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": {
"brandByIdSelectorNull": {
"name": "Brand0"
}
}
}
```

Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ public FieldResult<int, ExplicitCustomError> DoSomething(int status)

public sealed class ExplicitCustomError
{
public required string Message { get; set; }
public string Message { get; set; } = default!;
}

public class SimpleMutation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ public async Task Query_Owner_Animals()

var operationResult = result.ExpectOperationResult();

#if NET6_0
await Snapshot.Create("NET_6_0")
#elif NET7_0
await Snapshot.Create("NET_7_0")
#else
await Snapshot.Create()
#endif
.AddQueries(queries)
.Add(operationResult.WithExtensions(ImmutableDictionary<string, object?>.Empty))
.MatchMarkdownAsync();
Expand Down Expand Up @@ -121,13 +127,18 @@ ... on Cat {

var operationResult = result.ExpectOperationResult();

#if NET6_0
await Snapshot.Create("NET_6_0")
#elif NET7_0
await Snapshot.Create("NET_7_0")
#else
await Snapshot.Create()
#endif
.AddQueries(queries)
.Add(operationResult.WithExtensions(ImmutableDictionary<string, object?>.Empty))
.MatchMarkdownAsync();
}


private static async Task SeedAsync(string connectionString)
{
await using var context = new AnimalContext(connectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace HotChocolate.Data.TestContext;

public class AnimalContext(string connectionString) : DbContext
{
public DbSet<Owner> Owners { get; set; }
public DbSet<Dog> Dogs { get; set; }
public DbSet<Cat> Cats { get; set; }
public DbSet<Owner> Owners { get; set; } = default!;
public DbSet<Dog> Dogs { get; set; } = default!;
public DbSet<Cat> Cats { get; set; } = default!;

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql(connectionString);
Expand All @@ -35,7 +35,7 @@ public class Owner
public int Id { get; set; }

[MaxLength(100)]
public required string Name { get; set; }
public string Name { get; set; } = default!;

public List<Animal> Pets { get; set; } = new();
}
Expand All @@ -46,7 +46,7 @@ public abstract class Animal
public int Id { get; set; }

[MaxLength(100)]
public required string Name { get; set; }
public string Name { get; set; } = default!;

public int OwnerId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Query_Owner_Animals

## SQL 0

```sql
SELECT o."Id", o."Name"
FROM "Owners" AS o
ORDER BY o."Name", o."Id"
```

## Expression 0

```text
[Microsoft.EntityFrameworkCore.Query.QueryRootExpression].Select(root => new Owner() {Id = root.Id, Name = IIF((root.Name == null), null, root.Name)}).OrderBy(t => t.Name).ThenBy(t => t.Id)
```

## SQL 1

```sql
SELECT a."Id", a."AnimalType", a."Name", a."OwnerId", a."IsPurring", a."IsBarking"
FROM "Owners" AS o
INNER JOIN "Animal" AS a ON o."Id" = a."OwnerId"
WHERE o."Id" IN (6, 5, 4, 3, 2, 1)
ORDER BY a."Name", a."Id"
```

## Expression 1

```text
[Microsoft.EntityFrameworkCore.Query.QueryRootExpression].Where(t => value(HotChocolate.Data.InterfaceIntegrationTests+AnimalsByOwnerDataLoader+<>c__DisplayClass2_0).keys.Contains(t.Id)).SelectMany(t => t.Pets).OrderBy(t => t.Name).ThenBy(t => t.Id)
```

## Result 5

```json
{
"data": {
"owners": {
"nodes": [
{
"id": 1,
"name": "Owner 1",
"pets": {
"nodes": [
{
"__typename": "Cat",
"id": 1,
"name": "Cat 1"
},
{
"__typename": "Dog",
"id": 5,
"name": "Dog 1"
},
{
"__typename": "Dog",
"id": 6,
"name": "Dog 2"
}
]
}
},
{
"id": 2,
"name": "Owner 2",
"pets": {
"nodes": [
{
"__typename": "Cat",
"id": 2,
"name": "Cat 2"
},
{
"__typename": "Dog",
"id": 7,
"name": "Dog 3"
},
{
"__typename": "Dog",
"id": 8,
"name": "Dog 4"
}
]
}
},
{
"id": 3,
"name": "Owner 3",
"pets": {
"nodes": [
{
"__typename": "Cat",
"id": 3,
"name": "Cat 3 (Not Pure)"
},
{
"__typename": "Dog",
"id": 9,
"name": "Dog 5"
},
{
"__typename": "Dog",
"id": 10,
"name": "Dog 6"
}
]
}
},
{
"id": 4,
"name": "Owner 4 - No Pets",
"pets": {
"nodes": []
}
},
{
"id": 5,
"name": "Owner 5 - Only Cat",
"pets": {
"nodes": [
{
"__typename": "Cat",
"id": 4,
"name": "Only Cat"
}
]
}
},
{
"id": 6,
"name": "Owner 6 - Only Dog",
"pets": {
"nodes": [
{
"__typename": "Dog",
"id": 11,
"name": "Only Dog"
}
]
}
}
]
}
}
}
```

Loading

0 comments on commit 41f2efb

Please sign in to comment.