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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Validate(

foreach (var pattern in feature.Patterns)
{
var objectField = schema.QueryType.Fields[pattern.FieldName];
var objectField = pattern.Type.Fields[pattern.FieldName];
var validationContext = new ValidateIsSelectedPatternContext(schema, objectField, pattern.Pattern);
ValidateIsSelectedPatternVisitor.Instance.Visit(pattern.Pattern, validationContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,30 @@ public async Task IsSelected_Pattern_Root_Lists()
result.MatchMarkdownSnapshot();
}

[Fact]
public async Task IsSelected_Pattern_On_NonQueryType_Should_Build_Schema()
{
// Arrange & Act - should not throw KeyNotFoundException
var result =
await new ServiceCollection()
.AddGraphQL()
.AddQueryType<QueryWithNestedIsSelected>()
.ExecuteRequestAsync(
"""
query {
metrics {
latency {
dataset {
p50
}
}
}
}
""");

result.MatchMarkdownSnapshot();
}

public class Query
{
public static User DummyUser { get; } =
Expand Down Expand Up @@ -1141,4 +1165,24 @@ public class Audit
public record Book(string Title, Author Author);

public record Author(string Name);

public sealed record MetricsInnerData(double P50, double P95);

public sealed record MetricsOuterGraph(List<MetricsInnerData> Dataset);

public class MetricsType
{
public MetricsOuterGraph? GetLatency(
[IsSelected("dataset { p50 }")] bool isP50Selected,
IResolverContext context)
{
((IMiddlewareContext)context).OperationResult.SetExtension("isSelected", isP50Selected);
return null;
}
}

public class QueryWithNestedIsSelected
{
public MetricsType GetMetrics() => new();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# IsSelected_Pattern_On_NonQueryType_Should_Build_Schema

```json
{
"data": {
"metrics": {
"latency": null
}
},
"extensions": {
"isSelected": true
}
}
```
Loading