Пример #1
0
        private async ValueTask <RemoteSchemaDefinition?> FetchSchemaDefinitionAsync(
            CancellationToken cancellationToken)
        {
            using var writer = new ArrayWriter();

            IQueryRequest request =
                QueryRequestBuilder.New()
                .SetQuery(
                    $@"query GetSchemaDefinition($c: String!) {{
                            {SchemaDefinitionFieldNames.SchemaDefinitionField}(configuration: $c) {{
                                name
                                document
                                extensionDocuments
                            }}
                        }}")
                .SetVariableValue("c", new StringValueNode(_configuration.Value))
                .Create();

            HttpRequestMessage requestMessage = await HttpRequestClient
                                                .CreateRequestMessageAsync(writer, request, cancellationToken)
                                                .ConfigureAwait(false);

            HttpResponseMessage responseMessage = await _httpClient
                                                  .SendAsync(requestMessage, cancellationToken)
                                                  .ConfigureAwait(false);

            IQueryResult result = await HttpRequestClient
                                  .ParseResponseMessageAsync(responseMessage, cancellationToken)
                                  .ConfigureAwait(false);

            if (result.Errors is { Count : > 1 })