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
<Description>Newtonsoft JSON Supportt for FlurlGraphQL v2.0+ -- A GraphQL client extensions for Flurl.Http - lightweight, simplified, asynchronous, fluent GraphQL client API extensions for the amazing Flurl Http library!</Description>
- Improve configuration support for Defeault Json Processing now with Enum Flags to make enabling/disabling the GraphQL Json Defaults much easier.
22
+
23
+
Prior Release Notes:
21
24
- Improve handling of Enums so that automatic processing as SCREAMING_CASE is handled now without the need to have [EnumMember("")] attributes on every enum value when the names match.
22
25
- Improve handling of GraphQL Serialization to now automatically use CamelCase for System.Text.Json & Newtonsoft.Json; it was already being handled when de-serializing but not when serializing.
23
26
- Added new methods to help streamline the configuration of Json Serializer options/settings; a simple action/lambda can now be used to set Json Serialization Options/Settings.
24
-
25
-
Prior Release Notes:
26
27
- Fix issue with incorrect deserialization when using wrapper convenience class GraphQLEdge<T>.
27
28
- Newtonsoft JSON Compatibility implementation for FlurlGraphQL v2.0 using the all new Flurl v4.0+.
//For compatibility with FlurlGraphQL v1 behavior using Newtonsoft.Json it is case-insensitive by default but does not use Camel Case.
42
44
//This is also helpful since GraphQL Json (and Json in general) use CamelCase and nearly always mismatch C# Naming Pascal Case standards of C# Class Models, etc...
43
45
//NOTE: WE are operating on a copy of the original Json Settings so this does NOT mutate the core/original settings from Flurl or those specified for the GraphQL request, etc.
//For compatibility with FlurlGraphQL v1 behavior (using Newtonsoft.Json) we need to provide support for String to Enum conversion along with support for enum annotations
49
50
// via [EnumMember(Value ="CustomName")] annotation (compatible with Newtonsoft.Json). In addition, we now also support [Description("CustomName")] annotation for
50
51
// easier syntax that is arguably more intuitive to use.
51
-
//NOTE: For performance we KNOW we need ot add this if original options were not provided (e.g. null)
Copy file name to clipboardExpand all lines: FlurlGraphQL/FlurlGraphQL.csproj
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@
4
4
<!--NOTE: Just as with the base Flurl.Http.Newtonsoft library and Microsofts recommendation we now support net6 for the latest projects, but also netstandard2.1 which has proper Async streaming support,
5
5
in addition to netstandard2.0 + net461 for legacy support (because netstandard2.0 it had API compatibility issues prior to .NET Framework 4.7.x -->
<Description>GraphQL client extensions for Flurl.Http -- lightweight, simplified, asynchronous, fluent GraphQL client API extensions for the amazing Flurl Http library!</Description>
- Improve configuration support for Defeault Json Processing now with Enum Flags to make enabling/disabling the GraphQL Json Defaults much easier.
21
+
22
+
Prior Release Notes:
20
23
- Improve handling of Enums so that automatic processing as SCREAMING_CASE is handled now without the need to have [EnumMember("")] attributes on every enum value when the names match.
21
24
- Improve handling of GraphQL Serialization to now automatically use CamelCase for System.Text.Json & Newtonsoft.Json; it was already being handled when de-serializing but not when serializing.
22
25
- Added new methods to help streamline the configuration of Json Serializer options/settings; a simple action/lambda can now be used to set Json Serialization Options/Settings.
23
-
24
-
Prior Release Notes:
25
26
- Fix bug resulting in incorrect Exceptions when automatically enumerating (as IAsyncEnumerable) Connection Pages when a request returns with no results (NextPage = false & EndCursor = null).
26
27
- Fix issue with incorrect deserialization when using wrapper convenience class GraphQLEdge<T>.
//For compatibility with FlurlGraphQL v1 behavior (using Newtonsoft.Json) we always enable case-insensitive Field Matching with System.Text.Json.
37
40
//This is also helpful since GraphQL Json (and Json in general) use CamelCase and nearly always mismatch C# Naming Pascal Case standards of C# Class Models, etc...
38
41
//NOTE: WE are operating on a copy of the original Json Settings so this does NOT mutate the core/original settings from Flurl or those specified for the GraphQL request, etc.
//For compatibility when actually serializing we still need to enforce CamelCase (as noted above for parsing/de-serializing) because most JSON frameworks
42
46
// (e.g. HotChocolate for .NET) the GraphQL json is generally expected to be in camelCase format otherwise parsing on the GraphQL Server side may fail.
43
47
//This is likely a critical element missed by many developers so we enable it by default here to streamline and simplify working with GraphQL.
//For compatibility with FlurlGraphQL v1 behavior (using Newtonsoft.Json) we need to provide support for String to Enum conversion along with support for enum annotations
49
52
// via [EnumMember(Value ="CustomName")] annotation (compatible with Newtonsoft.Json). In addition, we now also support [Description("CustomName")] annotation for
50
53
// easier syntax that is arguably more intuitive to use.
51
-
//NOTE: For performance we KNOW we need ot add this if original options were not provided (e.g. null)
Copy file name to clipboardExpand all lines: README.md
+39-2Lines changed: 39 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,20 @@ To use this in your project, add the [FlurlGraphQL](https://www.nuget.org/packag
120
120
To use this in your project with `Newtonsoft.Json` processing then add the add the [FlurlGraphQL.Newtonsoft](https://www.nuget.org/packages/FlurlGraphQL.Newtonsoft/) NuGet package to your project.
121
121
122
122
## Release Notes:
123
+
### v2.0.5
124
+
- Improve configuration support for Defeault Json Processing now with Enum Flags to make enabling/disabling the GraphQL Json Defaults much easier.
125
+
126
+
### v2.0.4
127
+
- Improve handling of Enums so that automatic processing as SCREAMING_CASE is handled now without the need to have [EnumMember("")] attributes on every enum value when the names match.
128
+
- Improve handling of GraphQL Serialization to now automatically use CamelCase for System.Text.Json & Newtonsoft.Json; it was already being handled when de-serializing but not when serializing.
129
+
- Added new methods to help streamline the configuration of Json Serializer options/settings; a simple action/lambda can now be used to set Json Serialization Options/Settings.
130
+
131
+
### v.2.0.3
132
+
- Fix bug resulting in incorrect Exceptions when automatically enumerating (as IAsyncEnumerable) Connection Pages when a request returns with no results (NextPage = false & EndCursor = null).
133
+
134
+
### v2.0.2
135
+
- Fix issue with incorrect deserialization when using wrapper convenience class GraphQLEdge<T>.
136
+
123
137
### v2.0.1
124
138
- Fix issue with incorrect deserialization when using wrapper convenience class GraphQLEdge<T>
## Need direct control over the Json Serialization Settings?
652
-
Now with version 2.0 we dynamically inherit and implement all the settings from the base/core Flurl request!
666
+
Now with version 2.0 we dynamically inherit and implement all the settings from the base/core Flurl request!
667
+
In general, there is no need to explicitly set the settings for only GraphQL requests anymore, however you may continue to do so.
668
+
669
+
NOTE: However to streamlinea and simplify the most common Json serialization issues we still enforce some Json processing defaults via
670
+
the `JsonDefaults` enum flags that can be set on the default configuration using the `JsonProcessingDefaults` property:
671
+
-`EnableStringEnumHandling` -- Ensures that Enum String conversion is automatically handled as GraphQL uses sring enum values.
672
+
-`EnableScreamingCaseEnums` -- Ensures that Enum strings are automatically converted to SCREAMING_CASE as is the default for GraphQL enums (e.g. HotChocolate GraphQL Server).
673
+
- This has no effect if the above `EnableStringEnumHandling` is disabled; unless you manually implement the screaming case naming policies/strategy (e.g. `FlurlGraphQLSystemTextJsonScreamingCaseNamingPolicy`).
674
+
-`EnableCamelCaseSerialization` -- Ensures that the Json serialization is compatible with GraphQL JSON conventions which use camelCase and are usually case sensitive (e.g. HotChocolate GraphQL Server).
675
+
-`EnableCaseInsensitiveJsonHandling` -- Ensures that Json de-serialziation is not case sensitive because C# conventions for `PascalCase` will nearly always fail due to JSON conventions for `camelCase`.
676
+
- NOTE: This *ONLY* applies to `System.Text.Json` because case-insensitive matching cannot be disabled with `Newtonsoft.Json`.
677
+
-`EnableAll` -- a convenience flag used by default to ensure all of the above are enabled to greatly simplify the common pitfalls for Json handlingw between C# & GraphQL.
653
678
654
-
Therefore there is no need to explicitly set the settings for only GraphQL requests anymore, however you may continue to do so.
655
679
656
680
We still provide support to manually control the Json serializer settings specifically for individual GraphQL request processing.
657
681
658
682
*NOTE: These settings will impact both how the initial query paylaod is serialized before being sent to the GraphQL server
659
683
and how the response is parsed when being de-serailized back into your model.*
660
684
661
685
```csharp
686
+
//Control how default Json Options/Settings are initialzied (for either System.Text.Json or Newtonsoft)
687
+
//NOTE: If Enabled, these global GraphQL Defaults will be enforced on any settings specified, even at the Request level.
//Or Disable all default value enforcement so the system will use the Json Settings exactly as you specify in Flurl (or in Newtonsoft default configuration)
692
+
config.JsonProssingDefaults=JsonDefaults.None;
693
+
//Or some custom combination: this will remove Case-insensitivity, and CamelCase serialization....
0 commit comments