Skip to content

Commit d1312c6

Browse files
committed
add note on response type
1 parent 30d3e31 commit d1312c6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var graphQLClient = new GraphQLHttpClient("https://api.example.com/graphql", new
3030
```
3131

3232
> [!NOTE]
33-
> *GraphQLHttpClient* is meant to be used as a single longlived instance per endpoint (i.e. register as singleton in a DI system) to be reused for multiple requests.
33+
> *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.
3434
3535
### Create a GraphQLRequest:
3636
#### Simple Request:
@@ -68,7 +68,9 @@ var personAndFilmsRequest = new GraphQLRequest {
6868
```
6969

7070
> [!WARNING]
71-
> Be careful when using `byte[]` in your variables object, as most JSON serializers will treat that as binary data! 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.
71+
> Be careful when using `byte[]` in your variables object, as most JSON serializers will treat that as binary data.
72+
>
73+
> 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.
7274
7375
### Execute Query/Mutation:
7476

@@ -104,6 +106,11 @@ var graphQLResponse = await graphQLClient.SendQueryAsync(personAndFilmsRequest,
104106
var personName = graphQLResponse.Data.person.Name;
105107
```
106108

109+
> [!IMPORTANT]
110+
> Note that the field in the GraphQL response which gets deserialized into the response object is the `data` field.
111+
>
112+
> A common mistake is to try to directly use the `PersonType` object as response type (because thats the *thing* you actually want to query), but the returned response object contains a property `person` containing a `PersonType` object (like the `ResponseType` modelled above).
113+
107114
### Use Subscriptions
108115

109116
```csharp

0 commit comments

Comments
 (0)