diff --git a/LinQL/SelectExtentions.cs b/LinQL/SelectExtentions.cs index deeab67..d5e82d7 100644 --- a/LinQL/SelectExtentions.cs +++ b/LinQL/SelectExtentions.cs @@ -62,7 +62,7 @@ public static OneOf On(this OneOf th public static T SelectAll(this T that) => that; /// - /// Instruct the query to get all scalar fields on this type. + /// Extract specific fields from a type. /// /// The type to select from. /// The type to project to. diff --git a/docs/Writing-Queries.md b/docs/Writing-Queries.md index eccd2a3..cbd76ea 100644 --- a/docs/Writing-Queries.md +++ b/docs/Writing-Queries.md @@ -29,6 +29,9 @@ public class ExampleType public IEnumerable Strings { get; set; } public ExampleType Nested { get; set; } + + [GraphQLOperation] + public ExampleType GetNestedById(int id) { get; set; } } ``` If you were to query: @@ -97,4 +100,9 @@ You can then of course do whatever you like with the results ```csharp (await Query((Root x) => x.ExampleTypes.Select(y => new { y.Number, y.Text, IsAvailable = y.IsTrue() }))) .Where(x => x.IsAvailable).ToList(); +``` + +Another scenario is where you have the results of an operation or a nested type that you need to retrieve fields from. In this instance you can use the `Project` helper method. +```csharp +(await Query((Root x) => new { Number = x.ExampleType.Number, Obj = x.ExampleType.GetByNumber(123).Project(y => new { y.Number, y.Text }) }); ``` \ No newline at end of file