예제 #1
0
        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);
        }
예제 #2
0
        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"]);
        }
예제 #3
0
        public void TestDefaultConstructor()
        {
            var exception = new GraphQLClientException();

            Assert.Equal("The GraphQL request returns errors.", exception.Message);
        }