예제 #1
0
        public async Task TestPostBatch()
        {
            Func <string, IQuery <Pokemon> > query = (string name) => new Query <Pokemon>("pokemon")
                                                     .Alias(name)
                                                     .AddArguments(new { name })
                                                     .AddField(p => p.Name);

            using var client = new GraphQLClient(URL);

            IReadOnlyDictionary <string, JToken> batch = await client.PostBatch(new IQuery[] { query("Pikachu"), query("Bulbasaur") });

            Pokemon pikachu = batch["Pikachu"].ToObject <Pokemon>();

            Assert.NotNull(pikachu);
            Assert.Equal("Pikachu", pikachu.Name);

            Pokemon bulbasaur = batch["Bulbasaur"].ToObject <Pokemon>();

            Assert.NotNull(bulbasaur);
            Assert.Equal("Bulbasaur", bulbasaur.Name);
        }