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); }
public void TestConstructor() { var errors = new GraphQLError[] { new GraphQLError { Message = "First error.", Locations = new GraphQLLocation[] { new GraphQLLocation { Line = 1, Column = 2 } } }, new GraphQLError { Message = "Second error.", Locations = new GraphQLLocation[] { new GraphQLLocation { Line = 1, Column = 2 } } } }; var exception = new GraphQLClientException(errors); Assert.Equal($"The GraphQL request returns errors.{Environment.NewLine}First error.{Environment.NewLine}Second error.", exception.Message); Assert.Equal(errors, exception.Data["Errors"]); }
public void TestDefaultConstructor() { var exception = new GraphQLClientException(); Assert.Equal("The GraphQL request returns errors.", exception.Message); }