Skip to content

Commit bb88224

Browse files
authored
Fix code formatting in README
1 parent c6452e1 commit bb88224

File tree

1 file changed

+49
-46
lines changed

1 file changed

+49
-46
lines changed

README.md

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ then I do love-me-some-coffee!*
3232
var results = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
3333
.WithGraphQLQuery(@"
3434
query ($ids: [Int!], $friendsCount: Int!) {
35-
charactersById(ids: $ids) {
35+
charactersById(ids: $ids) {
3636
personalIdentifier
3737
name
3838
friends(first: $friendsCount) {
@@ -484,28 +484,32 @@ public class StarWarsCharacter
484484
var results = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
485485
.WithGraphQLQuery(@"
486486
query ($ids: [Int!], $friendsCount: Int!) {
487-
charactersById(ids: $ids) {
488-
friends(first: $friendsCount) {
489-
nodes {
490-
friends(first: $friendsCount) {
491-
nodes {
492-
name
493-
personalIdentifier
494-
}
495-
}
496-
}
487+
charactersById(ids: $ids) {
488+
name
489+
personalIdentifier
490+
friends(first: $friendsCount) {
491+
nodes {
492+
name
493+
personalIdentifier
494+
friends(first: $friendsCount) {
495+
nodes {
496+
name
497+
personalIdentifier
498+
}
499+
}
500+
}
501+
}
497502
}
498-
}
499503
}
500504
")
501505
.SetGraphQLVariables(new { ids = new[] { 1000, 2001 }, friendsCount = 3 })
502506
.PostGraphQLQueryAsync()
503507
.ReceiveGraphQLQueryResults<StarWarsCharacter>();
504508

505-
foreach (var result in results)
509+
foreach (var character in results)
506510
{
507511
//... process each of the 2 initial results by Id...
508-
foreach (var friend in result.Friends)
512+
foreach (var friend in character.Friends)
509513
{
510514
//... process each of the nested friend results, but without the need for
511515
// our Model to be complicated by the fact that this is a paginated result from GraphQL...
@@ -536,15 +540,15 @@ var json = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
536540
characterCreateOrUpdate(input: $newCharacter) {
537541
result {
538542
personalIdentifier
539-
name
540-
}
541-
errors {
542-
... on Error {
543-
errorCode
544-
message
545-
}
546-
}
547-
}
543+
name
544+
}
545+
errors {
546+
... on Error {
547+
errorCode
548+
message
549+
}
550+
}
551+
}
548552
}
549553
")
550554
.SetGraphQLVariables(new { newCharacter: newCharacterModel })
@@ -570,15 +574,14 @@ var batchResults = await "https://graphql-star-wars.azurewebsites.net/api/graphq
570574
query ($first: Int) {
571575
characters(first: $first) {
572576
nodes {
573-
personalIdentifier
574-
name
575-
height
576-
}
577-
}
578-
579-
charactersCount: characters {
577+
personalIdentifier
578+
name
579+
height
580+
}
581+
}
582+
charactersCount: characters {
580583
totalCount
581-
}
584+
}
582585
}
583586
")
584587
.SetGraphQLVariables(new { first = 2 })
@@ -598,39 +601,38 @@ You can always request the raw Json response that was returned by the GraphQL se
598601
Simply use the respective API based on if you want are using System.Text.Json (via `.ReceiveGraphQLRawSystemTextJsonResponse()`)
599602
or Newtonsoft.Json (via `.ReceiveGraphQLRawNewtonsoftJsonResponse()`).
600603

601-
*NOTE: You cannot receive `Newtonsoft.Json` raw json if the request was initialzied and executing using `System.Text.Json` serailizer and vice-versa;
604+
*NOTE: You cannot receive `Newtonsoft.Json` raw json if the request was initialzied and executing using the `System.Text.Json` serailizer and vice-versa;
602605
a runtime exception will be thrown becuase this would be a large performance impact that would likely go unnoticed if it was allowed.*
603606

604607
```csharp
605-
606608
//For System.Text.Json Raw GraphQL response processing you will get a `JsonObject` result back for RAW Json handling!
607609
var jsonObject = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
608610
.WithGraphQLQuery(@"
609611
query ($first: Int) {
610612
characters(first: $first) {
611613
nodes {
612-
personalIdentifier
613-
name
614-
height
615-
}
616-
}
614+
personalIdentifier
615+
name
616+
height
617+
}
618+
}
617619
}
618620
")
619621
.SetGraphQLVariables(new { first = 2 })
620622
.PostGraphQLQueryAsync()
621623
.ReceiveGraphQLRawSystemTextJsonResponse();
622624

623625
//OR For Newtonsoft.Json Raw GraphQL response processing you will get a `JObject` result back (just as with v1.x) for RAW Json handling!
624-
var jsonObject = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
626+
var jObject = await "https://graphql-star-wars.azurewebsites.net/api/graphql"
625627
.WithGraphQLQuery(@"
626628
query ($first: Int) {
627629
characters(first: $first) {
628630
nodes {
629-
personalIdentifier
630-
name
631-
height
632-
}
633-
}
631+
personalIdentifier
632+
name
633+
height
634+
}
635+
}
634636
}
635637
")
636638
.SetGraphQLVariables(new { first = 2 })
@@ -676,7 +678,7 @@ the `JsonDefaults` enum flags that can be set on the default configuration using
676678
- `EnableScreamingCaseEnums` -- Ensures that Enum strings are automatically converted to SCREAMING_CASE as is the default for GraphQL enums (e.g. HotChocolate GraphQL Server).
677679
- This has no effect if the above `EnableStringEnumHandling` is disabled; unless you manually implement the screaming case naming policies/strategy (e.g. `FlurlGraphQLSystemTextJsonScreamingCaseNamingPolicy`).
678680
- `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).
679-
- `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`.
681+
- `EnableCaseInsensitiveJsonHandling` -- Ensures that Json de-serialziation is not case sensitive because otherwise C# conventions for `PascalCase` will nearly always fail due to JSON conventions for `camelCase`.
680682
- NOTE: This *ONLY* applies to `System.Text.Json` because case-insensitive matching cannot be disabled with `Newtonsoft.Json`.
681683
- `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.
682684

@@ -689,6 +691,7 @@ and how the response is parsed when being de-serailized back into your model.*
689691
```csharp
690692
//Control how default Json Options/Settings are initialzied (for either System.Text.Json or Newtonsoft)
691693
//NOTE: If Enabled, these global GraphQL Defaults will be enforced on any settings specified, even at the Request level.
694+
//NOTE: These are usually be set in your program.cs or other bootstrapping code on application startup.
692695
FlurlGraphQLConfig.ConfigureDefaults(config =>
693696
{
694697
config.JsonProcessingDefaults = JsonDefaults.EnableAll;
@@ -707,7 +710,7 @@ and how the response is parsed when being de-serailized back into your model.*
707710
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
708711
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
709712
WriteIndented = true,
710-
//NOTE: THIS settings will not actually have any effect as the Framework always switches it ON to enable `case insensitive` processing.
713+
//NOTE: THIS settings will not actually have any effect as the FlurlGraphQL framework always switches it ON to enable `case insensitive` processing.
711714
// This is due to the fact that GraphQL Json and C# often have different naming conventions for the Json so the vast majority of requests
712715
// would fail if not enabled automatically!
713716
PropertyNameCaseInsensitive = true

0 commit comments

Comments
 (0)