You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-56Lines changed: 58 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# FlurlGraphQL
2
-
`FlurlGraphQL`` is a lightweight, simplified, asynchronous, fluent GraphQL client querying API extensions for the amazing Flurl Http library!
2
+
`FlurlGraphQL` is a lightweight, simplified, asynchronous, fluent GraphQL client querying API extensions for the amazing Flurl Http library!
3
3
4
4
This makes it super easy to execute ad-hoc and simple or advanced queries against a GraphQL API such as the awesome [HotChocolate .NET GraphQL Server](https://chillicream.com/docs/hotchocolate/v13).
5
5
@@ -50,13 +50,13 @@ var results = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
50
50
```
51
51
52
52
### Now Flurl v4.0+ compatible
53
-
FlurlGraphQL is now fullup updated to support Flurl v4.0+ with some significant performance improvements. Just as when upgrading to Flurl v4+,
53
+
FlurlGraphQL is now fully updated to support Flurl v4.0+ with some significant performance improvements. Just as when upgrading to Flurl v4+,
54
54
there may be breaking changes such as those highlighted in the [Flurl upgrade docs](https://flurl.dev/docs/upgrade/).
55
55
56
56
#### Key Changes are:
57
57
- Namespace, Project/Library, and NuGet name has now been simplified to `FlurlGraphQL` (vs `FlurlGraphQL.Querying` in v1.x).
58
-
- Default Json processing now uses System.Text.Json for serialization/de-serialization.
59
-
- The use of System.Text.Json brings along numerous changes associated with its use so it is best to refer to
58
+
- Default Json processing now uses `System.Text.Json` for serialization/de-serialization.
59
+
- The use of `System.Text.Json` brings along numerous changes associated with its use so it is best to refer to
-`System.Text.Json` processing with Json transformation strategy is now **~10X faster** than the original Newtonsoft.Json processing
62
62
- The new `Newtonsoft.Json` processing has also been optimized and which now benchmarks at **~2X faster***-- using the new Json transformation strategy (vs Converter)*.
@@ -66,24 +66,26 @@ there may be breaking changes such as those highlighted in the [Flurl upgrade do
66
66
-`Newtonsoft.Json` is still fully supported but requires explicitly referencing the `FlurlGraphQL.Newtonsoft` library also available on Nuget.
67
67
- To then enable `Newtonsoft.Json` processing you need to either:
68
68
1. Initialize your global Flurl settings and/or clients with the out-of-the-box Flurl `NewtonsoftJsonSerializer` via Flurl Global or Request level Configuration.
69
-
- Flurl Global Config Example: `clientOrRequest.Settings.JsonSerializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings())`
69
+
- Flurl Global Config Example: `FlurlHttp.Clients.UseNewtonsoft();`
70
+
- Flurl Request or Client level Example: `clientOrRequest.WithSettigns(settings => settings.JsonSerializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings()))...`
70
71
- Doing this will automatically implement Newtonsoft processing for any/all GraphQL requests as the defautl also.
72
+
- See Flurl docs for more info: [Flurl.Http.Newtonsoft](https://github.com/tmenier/Flurl/tree/dev/src/Flurl.Http.Newtonsoft#flurlhttpnewtonsoft)
71
73
2. Or initialize it at the request level using the `.UseGraphQLNewtonsoftJson(...)` extension method available in ``FlurlGraphQL.Newtonsoft``.
72
74
- The Json processing can always be customized/overridden at the request level for any specific GraphQL Request to use either
73
-
System.Text.Json (via `.UseGraphQLSystemTextJson()`) or Newtonsoft.Json via (`.UseGraphQLNewtonsoftJson()`).
74
-
- Dynamics are now only supported when using Newtonsoft.Json
75
+
`System.Text.Json` (via `.UseGraphQLSystemTextJson()`) or `Newtonsoft.Json` via (`.UseGraphQLNewtonsoftJson()`).
76
+
- Dynamics are now only supported when using `Newtonsoft.Json` which is consistent with Flurl v4+.
75
77
- Retrieving the Raw Json responses now have dedicated APIs due to the different Json object models that each Json processing library uses.
76
-
- If using System.Text.Json then you must now use the `.ReceiveGraphQLRawSystemTextJsonResponse()` method which returns a `JsonObject`.
77
-
- If using Newtonsoft.Json then you must now use the `.ReceiveGraphQLRawNewtonsoftJsonResponse()` method which returns a `JObject`.
78
+
- If using `System.Text.Json` then you must now use the `.ReceiveGraphQLRawSystemTextJsonResponse()` method which returns a `JsonObject`.
79
+
- If using `Newtonsoft.Json` then you must now use the `.ReceiveGraphQLRawNewtonsoftJsonResponse()` method which returns a `JObject`.
78
80
79
81
80
82
## Performance with System.Text.Json vs Newtonsoft.Json
81
-
The System.Text.Json processing with Json transformation strategy is now **~10X faster** than the original Newtonsoft.Json processing.
83
+
The `System.Text.Json` processing with the new Json transformation strategy is now **~10X faster** than the original `Newtonsoft.Json` processing in my tests; your results will vary and may be higher.
82
84
83
-
And the newly optimized Newtonsoft.Json processing with new Json transformation strategy (vs Converter) also now benchmarks **~2X faster**.
85
+
And the newly optimized `Newtonsoft.Json` processing with new Json transformation strategy (vs Converter in original implementation) also now benchmarks **~2X faster**; a suprising benefit.
84
86
85
-
The following Benchmarks were run using .NET 6. As one might assume older versions of .NET are slower while newer versions are even faster.
86
-
For example, .NET 4.6.1 is quite slow compared to .NET 6, however .NET 8 is noticeably faster.
87
+
The following Benchmarks were run using .NET 6. And, as one might assume newer versions are likely even faster.
88
+
For example, .NET 4.6.1 is quite slow compared to .NET 6, and .NET 8 is noticeably faster.
87
89
88
90
// * Benchmark.NET Summary using .NET 6 *
89
91
@@ -228,15 +230,15 @@ These interfaces both expose `PageInfo` & `TotalCount` properties that may optio
228
230
### Cursor Paging Example to simply retrieve a single Page...
229
231
230
232
Cursor paging is the approach that is strongly recommended by GraphQL.org however, offset based paging (aka CollectionSegment -
231
-
*using from HotChocolate .NET GraphQL Server naming convention*)) is availble also (see below)[#offsetslice-paging-results-via-collectionsegment].
233
+
*using from HotChocolate .NET GraphQL Server naming convention*)) is availble also [(see below)](#offsetslice-paging-results-via-collectionsegment).
@@ -245,7 +247,7 @@ var results = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
245
247
nodes {
246
248
personalIdentifier
247
249
name
248
-
height
250
+
height
249
251
}
250
252
}
251
253
}
@@ -441,7 +443,7 @@ foreach (var pageTask in graphqlPagesTasks)
441
443
```
442
444
443
445
### Data Models with Nested Paginated results...
444
-
In GraphQL it's easy to expose nested selections of a result than itself is a paginated set of data. Thats why de-serializing this into
446
+
In GraphQL it's easy to expose nested selections of a result that itself is a paginated set of data. Thats why de-serializing this into
445
447
a normal model is complex and usually results in dedicated data models that are cluttered / polluted with unecessary elements such as `Nodes`, `Items`, `Edges`, or `PageInfo`, `Cursor`, etc.
446
448
447
449
You can still use these models if you like but in many cases with these nested data elements we primarily care about the results and
@@ -464,18 +466,18 @@ public class StarWarsCharacter
0 commit comments