public void Dispose() { if (!_disposed) { DateTime endTime = _timestampProvider.UtcNow(); _builder.SetRequestDuration(endTime - _startTime); if (_context.Result is IReadOnlyQueryResult queryResult) { _context.Result = QueryResultBuilder.FromResult(queryResult) .AddExtension(_extensionKey, _builder.Build()) .Create(); } _disposed = true; } }
public void BuildTracingResult() { // arrange var builder = new ApolloTracingResultBuilder(); DateTimeOffset startTime = new DateTime( 636824022698524527, DateTimeKind.Utc); const long startTimestamp = 1113752384890500; Path rootPath = Path.New("root").Append("field"); var rosolverStatisticsA = new ApolloTracingResolverRecord { Path = rootPath.Append(0).Append("value").ToFieldPathArray(), ParentType = "ParentTypeA", FieldName = "FieldNameA", ReturnType = "ReturnTypeA", StartTimestamp = 1113752444890200, EndTimestamp = 1113752454811100 }; var rosolverStatisticsB = new ApolloTracingResolverRecord { Path = rootPath.Append(1).Append("value").ToFieldPathArray(), ParentType = "ParentTypeB", FieldName = "FieldNameB", ReturnType = "ReturnTypeB", StartTimestamp = 1113752464890200, EndTimestamp = 1113752484850000 }; TimeSpan duration = TimeSpan.FromMilliseconds(122); builder.SetRequestStartTime(startTime, startTimestamp); builder.SetParsingResult(1113752394890300, 1113752402820700); builder.SetValidationResult(1113752404890400, 1113752434898800); builder.AddResolverResult(rosolverStatisticsA); builder.AddResolverResult(rosolverStatisticsB); builder.SetRequestDuration(duration); // act OrderedDictionary result = builder.Build(); // assert result.Snapshot(); }