Skip to content

Commit a3c531b

Browse files
committed
Updated Clients
1 parent 482f172 commit a3c531b

5 files changed

Lines changed: 1473 additions & 52 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text.Json.Serialization;
4+
using Linq2GraphQL.Client;
5+
6+
namespace StarWars.Client;
7+
8+
public static class IF
9+
{
10+
}
11+
12+

docs/StarWars.Client/Generated/Interfaces/Node.cs

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,96 @@
11
using System;
2-
using System.Collections.Generic;
2+
using System.Text.Json;
3+
using System.Text.Json.Nodes;
34
using System.Text.Json.Serialization;
45
using Linq2GraphQL.Client;
56
using Linq2GraphQL.Client.Converters;
67

78
namespace StarWars.Client;
89

9-
[JsonConverter(typeof(InterfaceConverter<Node__Concrete, Node>))]
10+
public static class NodeExtentions
11+
{
12+
13+
14+
[GraphInterface]
15+
public static Film Film(this Node value)
16+
{
17+
if (value.__TypeName == "Film")
18+
{
19+
return (Film)value;
20+
}
21+
return null;
22+
}
23+
24+
[GraphInterface]
25+
public static Person Person(this Node value)
26+
{
27+
if (value.__TypeName == "Person")
28+
{
29+
return (Person)value;
30+
}
31+
return null;
32+
}
33+
34+
[GraphInterface]
35+
public static Planet Planet(this Node value)
36+
{
37+
if (value.__TypeName == "Planet")
38+
{
39+
return (Planet)value;
40+
}
41+
return null;
42+
}
43+
44+
[GraphInterface]
45+
public static Species Species(this Node value)
46+
{
47+
if (value.__TypeName == "Species")
48+
{
49+
return (Species)value;
50+
}
51+
return null;
52+
}
53+
54+
[GraphInterface]
55+
public static Starship Starship(this Node value)
56+
{
57+
if (value.__TypeName == "Starship")
58+
{
59+
return (Starship)value;
60+
}
61+
return null;
62+
}
63+
64+
[GraphInterface]
65+
public static Vehicle Vehicle(this Node value)
66+
{
67+
if (value.__TypeName == "Vehicle")
68+
{
69+
return (Vehicle)value;
70+
}
71+
return null;
72+
}
73+
}
74+
75+
76+
internal class NodeConverter : InterfaceJsonConverter<Node>
77+
{
78+
public override Node Deserialize(string typeName, JsonObject json) => typeName switch
79+
{
80+
"Film" => json.Deserialize<Film>(),
81+
"Person" => json.Deserialize<Person>(),
82+
"Planet" => json.Deserialize<Planet>(),
83+
"Species" => json.Deserialize<Species>(),
84+
"Starship" => json.Deserialize<Starship>(),
85+
"Vehicle" => json.Deserialize<Vehicle>(),
86+
_ => json.Deserialize< Node__Concrete>()
87+
};
88+
}
89+
90+
91+
92+
93+
[JsonConverter(typeof(NodeConverter))]
1094
public interface Node
1195
{
1296
[JsonPropertyName("id")]

0 commit comments

Comments
 (0)