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
Add GraphQLQuery record type for reusable query declarations with syntax highlighting (#638)
* add GraphQLQuery record type for reusable query declarations
* enable GraphQLQuery record from .NET 6.0 upwards
* document GraphQLQuery type
* optimize linebreaks in Readme
* fix code formatting in readme
> *GraphQLHttpClient* is meant to be used as a single longlived instance per endpoint (i.e. register as singleton in a DI system), which should be reused for multiple requests.
36
+
> *GraphQLHttpClient* is meant to be used as a single long-lived instance per endpoint (i.e. register as singleton in a DI system), which should be reused for multiple requests.
34
37
35
38
### Create a GraphQLRequest:
36
39
#### Simple Request:
37
40
```csharp
38
41
varheroRequest=newGraphQLRequest {
39
-
Query=@"
42
+
Query="""
40
43
{
41
44
hero {
42
45
name
43
46
}
44
-
}"
47
+
}
48
+
"""
45
49
};
46
50
```
47
51
48
52
#### OperationName and Variables Request:
49
53
50
54
```csharp
51
55
varpersonAndFilmsRequest=newGraphQLRequest {
52
-
Query=@"
56
+
Query="""
53
57
query PersonAndFilms($id: ID) {
54
58
person(id: $id) {
55
59
name
@@ -59,7 +63,8 @@ var personAndFilmsRequest = new GraphQLRequest {
59
63
}
60
64
}
61
65
}
62
-
}",
66
+
}
67
+
""",
63
68
OperationName="PersonAndFilms",
64
69
Variables=new {
65
70
id="cGVvcGxlOjE="
@@ -72,7 +77,7 @@ var personAndFilmsRequest = new GraphQLRequest {
72
77
>
73
78
> If you really need to send a *list of bytes* with a `byte[]` as a source, then convert it to a `List<byte>` first, which will tell the serializer to output a list of numbers instead of a base64-encoded string.
74
79
75
-
### Execute Query/Mutation:
80
+
### Execute Query/Mutation
76
81
77
82
```csharp
78
83
publicclassResponseType
@@ -102,7 +107,9 @@ var personName = graphQLResponse.Data.Person.Name;
102
107
Using the extension method for anonymously typed responses (namespace `GraphQL.Client.Abstractions`) you could achieve the same result with the following code:
0 commit comments