Skip to content

Commit 64c1d6f

Browse files
authored
clarify example in readme readme
1 parent f2baba0 commit 64c1d6f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ Be careful when using `byte[]` in your variables object, as most JSON serializer
5151
### Execute Query/Mutation:
5252

5353
```csharp
54-
var graphQLClient = new GraphQLHttpClient("https://swapi.apis.guru/", new NewtonsoftJsonSerializer());
55-
5654
public class PersonAndFilmsResponse {
5755
public Person Person { get; set; }
5856
}
@@ -70,11 +68,18 @@ public class Person {
7068
}
7169
}
7270

71+
var graphQLClient = new GraphQLHttpClient("https://swapi.apis.guru/", new NewtonsoftJsonSerializer());
7372
var graphQLResponse = await graphQLClient.SendQueryAsync<PersonAndFilmsResponse>(personAndFilmsRequest);
7473

7574
var personName = graphQLResponse.Data.Person.Name;
7675
```
7776

77+
Using the extension method for anonymously typed responses (namespace `GraphQL.Client.Abstractions`) you could achieve the same result with the following code:
78+
79+
```csharp
80+
var graphQLResponse = await graphQLClient.SendQueryAsync(personAndFilmsRequest, () => new { person = new Person()} );
81+
var personName = graphQLResponse.Data.person.Name;
82+
```
7883

7984
### Use Subscriptions
8085

0 commit comments

Comments
 (0)