Beispiel #1
0
        static async Task DynamicExampleViewer(IGraphQLApiClient client)
        {
            dynamic result = await client.QueryDynamic(@"{ viewer { id email firstName lastName } }");

            dynamic viewer = result.viewer;

            Console.WriteLine($"(From dynamic) Viewer is {viewer.firstName} {viewer.lastName}");
            Console.WriteLine();
        }
Beispiel #2
0
        static async Task TypedQueryExampleViewer(IGraphQLApiClient client)
        {
            ViewerQuery result = await client.Query <ViewerQuery>(@"{ viewer { id email } }");

            Viewer viewer = result.Viewer;

            Console.WriteLine($"(From typed query) Viewer is {viewer.Id} with email {viewer.Email}");
            Console.WriteLine();
        }
Beispiel #3
0
        static async Task VariablesExampleWithAnonymousType(IGraphQLApiClient client)
        {
            var query =
                @"query ($count: Int!)
                  {
                      orders ( paging: { count: $count } )
                      {
                          id
                          company { name }
                      }
                  }";

            var fiveOrders = await client.Query(query, new { count = 5 });

            DumpResult(fiveOrders);
        }
Beispiel #4
0
        static async Task VariablesExampleWithKeyValuePairs(IGraphQLApiClient client)
        {
            var query =
                @"query ($count: Int!)
                  {
                      orders ( paging: { count: $count } )
                      {
                          id
                          company { name }
                      }
                  }";

            var vars = new Dictionary <string, object>
            {
                ["count"] = 2
            };

            var twoOrders = await client.Query(query, vars);

            DumpResult(twoOrders);
        }
Beispiel #5
0
        static async Task ExampleProducts(IGraphQLApiClient client)
        {
            var companies = await client.Query(@"{ products { id longDescription } }");

            DumpResult(companies);
        }