public async Task TestPost() { var query = new Query <Pokemon>("pokemon") .AddArguments(new { name = "pikachu" }) .AddField(p => p.Name); using var client = new GraphQLClient(URL); Pokemon pikachu = await client.Post <Pokemon>(query); Assert.NotNull(pikachu); Assert.Equal("Pikachu", pikachu.Name); }
public async Task TestError() { var query = new Query <Pokemon>("wrongQueryName") .AddArguments(new { name = "pikachu" }) .AddField(p => p.Name); using var client = new GraphQLClient(URL); GraphQLClientException exception = await Assert.ThrowsAsync <GraphQLClientException>(async() => await client.Post <Pokemon>(query)); Assert.Equal( $"The GraphQL request returns errors.{Environment.NewLine}Cannot query field \"wrongQueryName\" on type \"Query\".", exception.Message); }