|
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Text.Json; |
4 | 4 | using System.Text.Json.Serialization; |
| 5 | +using System.Xml.Linq; |
5 | 6 | using Linq2GraphQL.Client; |
| 7 | +using Linq2GraphQL.Client.Common; |
6 | 8 |
|
7 | 9 | namespace Linq2GraphQL.TestClient; |
8 | 10 |
|
9 | 11 | public static class OrderExtensions |
10 | 12 | { |
11 | 13 | [GraphMethod("orderHello")] |
12 | | - public static string OrderHello(this Order order, [GraphArgument("String!")] string name, [GraphArgument("Int!")] int first) |
| 14 | + public static string OrderHello(this Order order, [GraphArgument("String!")] string name, [GraphArgument("Int!")] int first) |
13 | 15 | { |
14 | | - var ll = ""; |
15 | | - if (name != null) { ll += name.GetHashCode().ToString(); } |
16 | | - if(first != null) { ll += first.GetHashCode().ToString(); } |
17 | | - |
18 | | - var argHascode = ll.GetHashCode(); |
19 | | - if (argHascode < 0) { argHascode = argHascode * -1; } |
20 | | - |
21 | | - var vall = order.__AdditionalProperties["Arg" + argHascode]; |
22 | | - return vall.Deserialize<string>(); |
23 | | - |
| 16 | + return order.GetMethodValue<string>("orderHello", name, first); |
24 | 17 | } |
25 | 18 |
|
26 | 19 | [GraphMethod("orderAddress")] |
27 | | - public static Address OrderAddress(this Order order, [GraphArgument("AddressType!")] AddressType addressType) |
| 20 | + public static Address OrderAddress(this Order order, [GraphArgument("AddressType!")] AddressType addressType) |
28 | 21 | { |
29 | | - return order?.OrderAddress; |
| 22 | + return order.GetMethodValue<Address>("orderAddress", addressType); |
30 | 23 | } |
31 | 24 |
|
32 | 25 | } |
33 | 26 |
|
34 | | -public partial class Order |
| 27 | +public partial class Order : GraphQLTypeBase |
35 | 28 | { |
| 29 | + |
| 30 | + private LazyProperty<string> _orderHello = new(); |
36 | 31 | /// <summary> |
37 | 32 | /// Do not use in Query, only to retrive result |
38 | 33 | /// </summary> |
39 | 34 | [GraphShadowProperty] |
40 | | - [JsonPropertyName("orderHello")] |
41 | | - public string OrderHello { get; set; } |
| 35 | + public string OrderHello => _orderHello.Value(() => GetFirstMethodValue<string>("orderHello")); |
42 | 36 |
|
| 37 | + |
| 38 | + private LazyProperty<Address> _orderAddress = new(); |
43 | 39 | /// <summary> |
44 | 40 | /// Do not use in Query, only to retrive result |
45 | 41 | /// </summary> |
46 | 42 | [GraphShadowProperty] |
47 | | - [JsonPropertyName("orderAddress")] |
48 | | - public Address OrderAddress { get; set; } |
| 43 | + public Address OrderAddress => _orderAddress.Value(() => GetFirstMethodValue<Address>("orderAddress")); |
| 44 | + |
| 45 | + [JsonPropertyName("orderId")] |
| 46 | + public Guid OrderId { get; set; } |
49 | 47 |
|
50 | | - [JsonPropertyName("orderId")] |
51 | | - public Guid OrderId { get; set; } |
| 48 | + [JsonPropertyName("customer")] |
| 49 | + public Customer Customer { get; set; } |
52 | 50 |
|
53 | | - [JsonPropertyName("customer")] |
54 | | - public Customer Customer { get; set; } |
| 51 | + [JsonPropertyName("address")] |
| 52 | + public Address Address { get; set; } |
55 | 53 |
|
56 | | - [JsonPropertyName("address")] |
57 | | - public Address Address { get; set; } |
| 54 | + [JsonPropertyName("orderDate")] |
| 55 | + public DateTimeOffset OrderDate { get; set; } |
58 | 56 |
|
59 | | - [JsonPropertyName("orderDate")] |
60 | | - public DateTimeOffset OrderDate { get; set; } |
| 57 | + [JsonPropertyName("lines")] |
| 58 | + public List<OrderLine> Lines { get; set; } |
61 | 59 |
|
62 | | - [JsonPropertyName("lines")] |
63 | | - public List<OrderLine> Lines { get; set; } |
64 | 60 |
|
65 | | - [JsonExtensionData] |
66 | | - public Dictionary<string, JsonElement> __AdditionalProperties { get; set; } |
67 | 61 |
|
68 | 62 | } |
0 commit comments