Skip to content

Commit

Permalink
document GraphQLQuery type
Browse files Browse the repository at this point in the history
  • Loading branch information
rose-a committed Apr 22, 2024
1 parent bb3e486 commit 5c21773
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ var graphQLClient = new GraphQLHttpClient("https://api.example.com/graphql", new
#### Simple Request:
```csharp
var heroRequest = new GraphQLRequest {
Query = @"
Query = """
{
hero {
name
}
}"
}
"""
};
```

#### OperationName and Variables Request:

```csharp
var personAndFilmsRequest = new GraphQLRequest {
Query =@"
Query ="""
query PersonAndFilms($id: ID) {
person(id: $id) {
name
Expand All @@ -59,7 +60,8 @@ var personAndFilmsRequest = new GraphQLRequest {
}
}
}
}",
}
""",
OperationName = "PersonAndFilms",
Variables = new {
id = "cGVvcGxlOjE="
Expand Down Expand Up @@ -162,6 +164,25 @@ Currently, there is no native support for GraphQL formatting and syntax highligh

For Rider, JetBrains provides a [Plugin](https://plugins.jetbrains.com/plugin/8097-graphql), too.

To leverage syntax highlighting in variable declarations, the `GraphQLQuery` value record type is provided:

```csharp
GraphQLQuery query = new("""
query PersonAndFilms($id: ID) {
person(id: $id) {
name
filmConnection {
films {
title
}
}
}
}
""");

var graphQLResponse = await graphQLClient.SendQueryAsync<ResponseType>(query, new { id = "cGVvcGxlOjE=" });
```

## Useful Links:

* [StarWars Example Server (GitHub)](https://github.com/graphql/swapi-graphql)
Expand Down

0 comments on commit 5c21773

Please sign in to comment.