titaniumit.graphql.filtering
0.1.42
See the version list below for details.
dotnet add package titaniumit.graphql.filtering --version 0.1.42
NuGet\Install-Package titaniumit.graphql.filtering -Version 0.1.42
<PackageReference Include="titaniumit.graphql.filtering" Version="0.1.42" />
paket add titaniumit.graphql.filtering --version 0.1.42
#r "nuget: titaniumit.graphql.filtering, 0.1.42"
// Install titaniumit.graphql.filtering as a Cake Addin #addin nuget:?package=titaniumit.graphql.filtering&version=0.1.42 // Install titaniumit.graphql.filtering as a Cake Tool #tool nuget:?package=titaniumit.graphql.filtering&version=0.1.42
Introduction
An extention on GraphQL.net to add filtering on clr types
Example graphql filters
Filters are based on a clrType/interface
Using AddFilter as argument. The graphql type for the filters are automaticly added
- FilterGraphType<typename>
- And/Or/Not types
- Condition type
- Any
Simple filters
condition:{
fieldName:Id
operator: equal
value: 1
}
condition:{
fieldName: DateField
operator: equal
value: "10-10-2023"
}
Operators on scalars
supported operators on scalartypes
- equal
- greater
- greaterOrEqual
- less
- lessOrEqual
- notEqual
Booleans
supported
- and
- or
- not
Collections
to filter collection members the any field on the filtertype is present that contains per colletion field a member.
Resolvers
Using filters in a Resolver.
Field<DiverGraphType>("Diver")
.AddFilter("filter").FilterType<Diver>()
.Resolve(ctx =>
{
var filter = ctx.GetFilterExpression<Diver>("filter");
var datasource = ctx.RequestServices!.GetRequiredService<IDivers>();
if (filter != null)
return datasource.Divers.SingleOrDefault(filter.Compile());
else
return null;
});
When getting a filter on parent for a child
Field<ListGraphType<DiveGraphType>>("Dives")
.Resolve( ctx => {
var datasource = ctx.RequestServices!.GetRequiredService<IDives>();
var expression = ctx.GetSubFilterExpression<Dive>();
if( expression != null){
return datasource.Dives.Where( d => d.Diver?.Id == ctx.Source.Id).Where(expression.Compile());
} else{
return datasource.Dives.Where( d => d.Diver?.Id == ctx.Source.Id);
}
});
query examples
query GetDiverFixedFilter {
diver(filter:{
condition:{
fieldName:id
operator: equal
value: 1
}
}){
name
email
id
}
}
query GetDiverByEmail {
diver(filter:{
condition:{
fieldName: email
operator: equal
value: "john@divers.down"
}
}){
name
email
id
}
}
query GetDiversWithCoarseFilters {
divers(filter:{
any:{
courses:{
condition:{
fieldName: name
operator:equal
value: "OpenWater"
}
}
}
}){
name
email
id
}
}
query GetDiverFilterById($id: ValueScalar!) {
diver(filter:{
condition:{
fieldName:id
operator: equal
value: $id
}
}){
id
}
}
query GetDiversWithDivesAt($location:ValueScalar!){
divers(filter: {
any:{
dives:{
condition:{
fieldName:location
operator:equal
value: $location
}
}
}
}){
name
dives{
start
end
}
}
}
Setup
Todo
- documentation
- more test cases
- custom filter functions
- configuration options like, casing.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- GraphQL (>= 7.9.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
-
net7.0
- GraphQL (>= 7.9.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
-
net8.0
- GraphQL (>= 7.9.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on titaniumit.graphql.filtering:
Package | Downloads |
---|---|
titaniumit.graphql.filtering.extentions
Add filter options to C# based GraphQL.net servers |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.43 | 129 | 9/30/2024 |
0.1.42 | 112 | 9/30/2024 |
0.1.41 | 109 | 9/30/2024 |
0.1.40 | 103 | 9/30/2024 |
0.1.39 | 152 | 6/20/2024 |
0.1.38 | 141 | 5/23/2024 |
0.1.37 | 130 | 5/23/2024 |
0.1.36 | 133 | 5/23/2024 |
0.1.35 | 136 | 5/23/2024 |
0.1.34 | 153 | 3/28/2024 |
0.1.33 | 136 | 1/25/2024 |
0.1.32 | 130 | 1/25/2024 |
0.1.31 | 132 | 1/19/2024 |
0.1.30 | 133 | 1/10/2024 |
0.1.29 | 155 | 1/3/2024 |
0.1.28 | 129 | 1/3/2024 |
0.1.27 | 119 | 1/3/2024 |
0.1.24 | 134 | 12/28/2023 |
0.1.23 | 112 | 12/28/2023 |
0.1.22 | 129 | 12/27/2023 |
0.1.21 | 103 | 12/27/2023 |
0.1.20 | 124 | 12/27/2023 |
0.1.19 | 146 | 12/27/2023 |
0.1.18 | 119 | 12/27/2023 |
0.1.17 | 122 | 12/27/2023 |
0.1.16 | 119 | 12/27/2023 |
0.1.15 | 117 | 12/27/2023 |
0.1.14 | 121 | 12/27/2023 |
0.1.13 | 118 | 12/27/2023 |
0.1.12 | 123 | 12/21/2023 |
0.1.11 | 143 | 12/19/2023 |
0.1.10 | 139 | 12/16/2023 |
0.1.9 | 177 | 11/16/2023 |
0.1.8 | 121 | 11/14/2023 |
0.0.10 | 121 | 11/13/2023 |
0.0.9 | 133 | 11/10/2023 |
0.0.8 | 130 | 11/9/2023 |
0.0.7 | 135 | 11/7/2023 |
0.0.6 | 144 | 11/3/2023 |
0.0.5 | 122 | 11/3/2023 |
0.0.4 | 116 | 11/3/2023 |
0.0.3 | 133 | 11/2/2023 |
0.0.2 | 137 | 11/2/2023 |
0.0.1 | 133 | 11/2/2023 |