From a16288004463a97123d4d84b53b914540785ed89 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Wed, 22 May 2024 22:13:51 +0200 Subject: [PATCH] Adds Variable Batching (#6981) --- .../Extensions/CommonTestExtensions.cs | 4 +- .../Extensions/WriterExtensions.cs | 11 + .../OperationResultSnapshotValueFormatter.cs | 31 +- .../AnnotationBased/CertificationTests.cs | 2 +- .../CodeFirst/CertificationTests.cs | 2 +- .../DefaultHttpRequestInterceptor.cs | 2 +- .../DefaultSocketSessionInterceptor.cs | 8 +- .../DelegateHttpRequestInterceptor.cs | 2 +- .../AspNetCore/src/AspNetCore/ErrorHelper.cs | 20 +- .../src/AspNetCore/HeaderUtilities.cs | 2 +- .../src/AspNetCore/HttpMultipartMiddleware.cs | 4 +- .../src/AspNetCore/HttpPostMiddlewareBase.cs | 18 +- .../HttpRequestInterceptorDelegate.cs | 2 +- .../src/AspNetCore/IHttpRequestInterceptor.cs | 2 +- .../AspNetCore/ISocketSessionInterceptor.cs | 6 +- .../AggregateServerDiagnosticEventListener.cs | 2 +- .../IServerDiagnosticEvents.cs | 2 +- .../NoopServerDiagnosticEventListener.cs | 2 +- .../ServerDiagnosticEventListener.cs | 2 +- .../src/AspNetCore/MiddlewareBase.cs | 24 +- .../src/AspNetCore/MiddlewareHelper.cs | 32 +- .../Serialization/DefaultHttpRequestParser.cs | 43 +- .../DefaultHttpResponseFormatter.cs | 121 ++- .../Subscriptions/OperationSession.cs | 20 +- .../ApolloSubscriptionProtocolHandler.cs | 2 +- .../GraphQLOverWebSocketProtocolHandler.cs | 2 +- .../Protocols/IProtocolHandler.cs | 2 +- .../IOperationRequest.cs | 33 + .../Transport.Abstractions/IRequestBody.cs | 17 + .../OperationBatchRequest.cs | 129 ++++ .../OperationRequest.cs | 6 +- .../Transport.Abstractions/OperationResult.cs | 30 +- .../Utf8GraphQLResultProperties.cs | 10 + .../Serialization/Utf8JsonWriterHelper.cs | 210 ++++-- .../VariableBatchRequest.cs | 196 +++++ .../DefaultGraphQLHttpClient.cs | 64 +- .../src/Transport.Http/GraphQLHttpClient.cs | 4 +- .../GraphQLHttpClientExtensions.cs | 262 ++++++- .../src/Transport.Http/GraphQLHttpRequest.cs | 99 ++- .../src/Transport.Http/GraphQLHttpResponse.cs | 42 +- .../Transport.Http/HttpResources.Designer.cs | 70 +- .../src/Transport.Http/HttpResources.resx | 9 + .../AuthorizationHandlerTests.cs | 8 +- .../AuthorizeSchemaTests.cs | 8 +- .../ServerTestBase.cs | 18 +- ...che.cs => TestOperationDocumentStorage.cs} | 24 +- .../GraphQLOverHttpSpecTests.cs | 109 ++- .../HotChocolate.AspNetCore.Tests.csproj | 1 + .../HttpGetMiddlewareTests.cs | 8 +- .../HttpPostMiddlewareTests.cs | 340 +-------- .../AspNetCore.Tests/PersistedQueryTests.cs | 50 +- .../Subscriptions/OperationManagerTests.cs | 2 +- ...GraphQLOverHttpSpecTests.OperationBatch.md | 16 + .../GraphQLOverHttpSpecTests.VariableBatch.md | 16 + ...aMiddlewareTests.Download_GraphQL_SDL.snap | 2 - ...s.Download_GraphQL_SDL_Explicit_Route.snap | 2 - ...L_SDL_Explicit_Route_Explicit_Pattern.snap | 2 - .../GraphQLHttpClientConfigurationTests.cs | 6 +- .../GraphQLHttpClientTests.cs | 57 +- .../OperationRequestTests.cs | 2 +- .../VariableBatchRequestTests.cs | 299 ++++++++ .../Caching/CacheControlTypeInterceptor.cs | 41 +- ...QueryCacheQueryRequestBuilderExtensions.cs | 8 +- ...ryCacheRequestExecutorBuilderExtensions.cs | 1 - .../src/Caching/ICacheControlConstraints.cs | 2 +- .../src/Caching/QueryCacheMiddleware.cs | 2 +- .../src/Abstractions/ArgumentAttribute.cs | 2 - .../Execution/ExecutionResultExtensions.cs | 4 +- .../Execution/IExecutionRequest.cs | 17 + .../Execution/IExecutionResult.cs | 4 +- .../Execution/IOperationDocument.cs | 32 + .../Execution/IOperationDocumentStorage.cs | 44 ++ ...{IQueryRequest.cs => IOperationRequest.cs} | 29 +- .../{IQueryResult.cs => IOperationResult.cs} | 16 +- ...matter.cs => IOperationResultFormatter.cs} | 10 +- .../Core/src/Abstractions/Execution/IQuery.cs | 40 - .../Execution/IQueryRequestBuilder.cs | 145 ---- .../Execution/IQueryResultBuilder.cs | 40 - .../Execution/IReadStoredQueries.cs | 26 - .../Abstractions/Execution/IResponseStream.cs | 4 +- .../Execution/IResponseStreamFormatter.cs | 2 - .../Abstractions/Execution/ISourceStream~1.cs | 2 - .../Execution/IVariableValueCollection.cs | 4 +- .../Execution/IWriteStoredQueries.cs | 24 - .../Execution/OperationDocument.cs | 72 ++ .../Execution/OperationDocumentId.cs | 237 ++++++ .../Execution/OperationDocumentSourceText.cs | 62 ++ .../Execution/OperationRequest.cs | 468 ++++++++++++ .../Execution/OperationRequestBatch.cs | 38 + .../Execution/OperationRequestBuilder.cs | 522 +++++++++++++ .../OperationRequestBuilderExtensions.cs | 93 +++ .../{QueryResult.cs => OperationResult.cs} | 36 +- .../Execution/OperationResultBatch.cs | 70 ++ ...ltBuilder.cs => OperationResultBuilder.cs} | 60 +- .../OperationResultBuilderExtensions.cs | 88 +++ ...sultHelper.cs => OperationResultHelper.cs} | 4 +- .../Execution/OrderedDictionary.cs | 4 +- .../Abstractions/Execution/QueryDocument.cs | 51 -- .../Abstractions/Execution/QueryException.cs | 28 - .../Execution/QueryRequestBuilder.cs | 375 ---------- .../Execution/QueryRequestBuilderException.cs | 14 - .../QueryRequestBuilderExtensions.cs | 173 ----- .../Abstractions/Execution/QuerySourceText.cs | 50 -- .../Abstractions/Execution/ResponseStream.cs | 8 +- .../Execution/Tasks/ExecutionTask.cs | 2 - .../Execution/Tasks/IExecutionTask.cs | 2 - .../Execution/Tasks/IExecutionTaskContext.cs | 2 - ...ueryRequest.cs => VariableBatchRequest.cs} | 84 +-- .../Abstractions/Execution/VariableValue.cs | 15 +- .../Core/src/Abstractions/ExtensionData.cs | 2 - .../Core/src/Abstractions/FieldCoordinate.cs | 2 - .../GraphQLNonNullTypeAttribute.cs | 2 - .../HotChocolate.Abstractions.csproj | 3 - .../Core/src/Abstractions/IErrorBuilder.cs | 2 - .../Core/src/Abstractions/IExecutable.cs | 2 - .../Core/src/Abstractions/IHasContextData.cs | 2 - .../Abstractions/IHasReadOnlyContextData.cs | 2 - .../Core/src/Abstractions/IOptional.cs | 2 - .../Core/src/Abstractions/Optional.cs | 2 - .../Core/src/Abstractions/Path.cs | 2 - .../AbstractionResources.Designer.cs | 26 +- .../Properties/AbstractionResources.resx | 15 +- .../src/Abstractions/ScopedStateAttribute.cs | 2 - .../Abstractions/SingleValueExtensionData.cs | 4 +- .../src/Abstractions/WellKnownDirectives.cs | 4 - .../AuthorizeValidationResultAggregator.cs | 2 +- .../Authorization/AuthorizeValidationRule.cs | 13 +- .../AutoUpdateRequestExecutorProxy.cs | 25 +- .../Batching/BatchExecutor.Enumerable.cs | 272 ------- .../src/Execution/Batching/BatchExecutor.cs | 36 - .../Batching/CollectVariablesVisitationMap.cs | 99 --- .../Batching/CollectVariablesVisitor.cs | 327 -------- .../src/Execution/Batching/ExportDirective.cs | 7 - .../Batching/ExportDirectiveHelper.cs | 33 - .../Execution/Batching/ExportDirectiveType.cs | 20 - .../Execution/Batching/ExportedVariable.cs | 22 - .../Caching/DefaultComplexityAnalyzerCache.cs | 32 - .../Caching/IComplexityAnalyzerCache.cs | 54 -- ...ternalSchemaServiceCollectionExtensions.cs | 9 +- .../InternalServiceCollectionExtensions.cs | 2 - ...ecutorBuilderExtensions.Instrumentation.cs | 21 - ...estExecutorBuilderExtensions.UseRequest.cs | 11 +- ...uestExecutorServiceCollectionExtensions.cs | 3 - ...equestExecutorServiceProviderExtensions.cs | 30 +- ...aRequestExecutorBuilderExtensions.Types.cs | 5 - .../Core/src/Execution/ErrorHelper.cs | 52 +- .../ExecutionRequestExecutorExtensions.cs | 40 +- .../Extensions/ExecutionResultExtensions.cs | 4 +- .../Extensions/OperationContextExtensions.cs | 2 +- .../Execution/HotChocolate.Execution.csproj | 4 + .../Core/src/Execution/IRequestContext.cs | 14 +- .../Core/src/Execution/IRequestExecutor.cs | 10 +- .../AggregateExecutionDiagnosticEvents.cs | 2 +- .../ApolloTracingDiagnosticEventListener.cs | 235 ------ .../ApolloTracingResolverRecord.cs | 33 - .../ApolloTracingResultBuilder.cs | 106 --- .../ApolloTracingResultKeys.cs | 18 - .../ExecutionDiagnosticEventListener.cs | 2 +- .../IExecutionDiagnosticEvents.cs | 2 +- .../NoopExecutionDiagnosticEvents.cs | 2 +- .../Options/ComplexityAnalyzerSettings.cs | 84 --- .../IComplexityAnalyzerOptionsAccessor.cs | 12 - .../IRequestExecutorOptionsAccessor.cs | 1 - .../Options/RequestExecutorOptions.cs | 5 - .../Complexity/ComplexityAnalyzerCompiler.cs | 183 ----- .../Complexity/ComplexityAnalyzerDelegate.cs | 7 - .../Complexity/ComplexityCalculation.cs | 6 - .../Pipeline/Complexity/ComplexityContext.cs | 133 ---- .../Complexity/OperationComplexityAnalyzer.cs | 18 - .../Pipeline/DocumentCacheMiddleware.cs | 22 +- .../Pipeline/DocumentParserMiddleware.cs | 24 +- .../Pipeline/DocumentValidationMiddleware.cs | 6 +- .../Execution/Pipeline/ExceptionMiddleware.cs | 4 +- .../OnlyPersistedQueriesAllowedMiddleware.cs | 6 +- .../Pipeline/OperationCacheMiddleware.cs | 6 +- .../Pipeline/OperationComplexityMiddleware.cs | 170 ----- .../Pipeline/OperationExecutionMiddleware.cs | 231 ++++-- .../Pipeline/OperationResolverMiddleware.cs | 84 +-- .../PersistedQueryNotFoundMiddleware.cs | 10 +- .../src/Execution/Pipeline/PipelineTools.cs | 48 +- .../Pipeline/ReadPersistedQueryMiddleware.cs | 45 +- .../Pipeline/RequestClassMiddlewareFactory.cs | 6 +- .../Pipeline/WritePersistedQueryMiddleware.cs | 34 +- .../Processing/DefaultTransactionScope.cs | 2 +- .../Processing/DeferredExecutionTaskResult.cs | 4 +- .../Execution/Processing/DeferredStream.cs | 2 +- .../Processing/DeferredWorkScheduler.cs | 16 +- .../Execution/Processing/DeferredWorkState.cs | 14 +- .../OperationCompiler.BacklogItem.cs | 31 +- .../Processing/OperationContext.Pooling.cs | 25 +- .../src/Execution/Processing/QueryExecutor.cs | 6 +- .../Result/ResultBuilder.Pooling.cs | 2 + .../Processing/Result/ResultBuilder.cs | 16 +- .../SubscriptionExecutor.Subscription.cs | 28 +- .../Processing/SubscriptionExecutor.cs | 4 +- .../Processing/VariableValueCollection.cs | 17 +- .../Core/src/Execution/RequestContext.cs | 49 +- .../Core/src/Execution/RequestExecutor.cs | 216 +++++- .../src/Execution/RequestExecutorProxy.cs | 10 +- .../src/Execution/RequestExecutorResolver.cs | 41 +- .../EventStreamResultFormatter.cs | 341 +++++---- .../JsonResultFormatter.FieldNames.cs | 4 + .../Serialization/JsonResultFormatter.cs | 150 +++- .../MultiPartResultFormatter.Constants.cs | 30 - .../Serialization/MultiPartResultFormatter.cs | 264 +++---- .../src/Types.CursorPagination/IndexEdge.cs | 2 +- .../src/Types.Errors/IPayloadErrorFactory.cs | 2 +- .../Types.Json/JsonObjectTypeExtensions.cs | 4 +- .../Extensions/DirectiveTypeExtensions.cs | 12 - .../Properties/TypeResources.Designer.cs | 18 - .../src/Types/Properties/TypeResources.resx | 9 - .../Core/src/Types/SchemaBuilder.cs | 1 - .../Types/Types/Attributes/CostAttribute.cs | 114 --- .../Types/Types/Directives/CostDirective.cs | 160 ---- .../Types/Directives/CostDirectiveType.cs | 39 - .../CostInterfaceFieldDescriptorExtensions.cs | 96 --- .../CostObjectFieldDescriptorExtensions.cs | 96 --- .../Types/Directives/CostTypeInterceptor.cs | 208 ------ .../src/Types/Types/Directives/Directives.cs | 7 +- .../Types/Directives/MultiplierPathString.cs | 344 --------- .../Types/Directives/NullBubblingDirective.cs | 18 - .../Core/src/Types/Types/Scalars/DateType.cs | 2 +- .../Types/Types/Scalars/MultiplierPathType.cs | 124 ---- .../src/Types/Types/Scalars/ScalarNames.cs | 1 - .../Core/src/Types/Types/Scalars/Scalars.cs | 4 +- .../Utilities/DefaultTypeConverter.Setup.cs | 11 +- .../Core/src/Validation/DocumentValidator.cs | 7 +- .../Validation/DocumentValidatorContext.cs | 2 +- .../Core/src/Validation/IDocumentValidator.cs | 3 +- .../Validation/IDocumentValidatorContext.cs | 2 +- ...cs => OperationDocumentSourceTextTests.cs} | 37 +- ...mentTests.cs => OperationDocumentTests.cs} | 34 +- ...ests.cs => OperationResultBuilderTests.cs} | 20 +- .../Execution/QueryRequestBuilderTests.cs | 421 ++--------- ...urceTextTests.QueryDocument_ToSource.snap} | 0 ...urceTextTests.QueryDocument_ToString.snap} | 0 ...xtTests.QuerySourceText_WriteToAsync.snap} | 0 ...DocumentTests.QueryDocument_ToSource.snap} | 0 ...DocumentTests.QueryDocument_ToString.snap} | 0 ...mentTests.QueryDocument_WriteToAsync.snap} | 0 ...mpty_OperationRequestBuilderException.snap | 1 + ...nlyQueryDocIsSet_RequestHasOnlyQuery.snap} | 6 +- ...t_OnlyQueryIsSet_RequestHasOnlyQuery.snap} | 8 +- ...eryAndAddProperties_RequestIsCreated.snap} | 8 +- ...ueryAndInitialValue_RequestIsCreated.snap} | 8 +- ...t_QueryAndOperation_RequestIsCreated.snap} | 8 +- ...ryAndResetOperation_RequestIsCreated.snap} | 8 +- ...yAndResetProperties_RequestIsCreated.snap} | 11 +- ...ryAndResetVariables_RequestIsCreated.snap} | 8 +- ...st_QueryAndServices_RequestIsCreated.snap} | 8 +- ...ryAndSetNewProperty_RequestIsCreated.snap} | 8 +- ...ryAndSetNewVariable_RequestIsCreated.snap} | 8 +- ...ueryAndSetProperties_RequestIsCreated.snap | 16 + ...QueryAndSetProperty_RequestIsCreated.snap} | 8 +- ...AndTryAddProperties_PropertyIsNotSet.snap} | 8 +- ...eryAndTryAddProperties_PropertyIsSet.snap} | 8 +- ...BuildRequest_SetAll_RequestIsCreated.snap} | 8 +- ...tBuilderTests.Create_Result_Set_Data.snap} | 2 + ...BuilderTests.Create_Result_Set_Items.snap} | 2 + ...st_Empty_QueryRequestBuilderException.snap | 1 - ...QueryAndAddExtension_RequestIsCreated.snap | 16 - ...QueryAndAddVariables_RequestIsCreated.snap | 16 - ...ryAndResetProperties_RequestIsCreated.snap | 13 - ...QueryAndSetExtension_RequestIsCreated.snap | 15 - ...ryAndSetExtensions_RequestIsCreated_1.snap | 15 - ...ryAndSetExtensions_RequestIsCreated_2.snap | 15 - ...ryAndSetExtensions_RequestIsCreated_3.snap | 16 - ...ryAndSetExtensions_RequestIsCreated_4.snap | 15 - ...ryAndSetExtensions_RequestIsCreated_5.snap | 16 - ..._QueryAndSetVariable_RequestIsCreated.snap | 15 - ...QueryAndSetVariables_RequestIsCreated.snap | 15 - ...yAndTryAddExtension_ExtensionIsNotSet.snap | 15 - ...ueryAndTryAddExtension_ExtensionIsSet.snap | 15 - ...eryAndTryAddVariable_VariableIsNotSet.snap | 15 - ..._QueryAndTryAddVariable_VariableIsSet.snap | 15 - ...urceTextTests.QuerySourceText_WriteTo.snap | 3 - ...extTests.QuerySourceText_WriteToAsync.snap | 3 - .../AnnotationBasedAuthorizationTests.cs | 52 +- .../Batching/BatchQueryExecutorTests.cs | 439 ----------- .../Batching/CollectVariablesVisitorTests.cs | 143 ---- ...cutorTests.Add_Value_To_Variable_List.snap | 1 - ..._List_To_Single_Value_With_Converters.snap | 1 - ...ryExecutorTests.ExecuteExportLeafList.snap | 1 - ...ueryExecutorTests.ExecuteExportObject.snap | 1 - ...ExecutorTests.ExecuteExportObjectList.snap | 1 - ...ueryExecutorTests.ExecuteExportScalar.snap | 1 - ...ExecutorTests.ExecuteExportScalarList.snap | 39 - ...cuteExportScalarList_ExplicitVariable.snap | 39 - ...sVisitorTests.FindUndeclaredVariables.snap | 5 - ...UndeclaredVariablesFragmentDefinition.snap | 9 - ...FindUndeclaredVariablesInlineFragment.snap | 7 - .../test/Execution.Tests/CodeFirstTests.cs | 32 +- .../Core/test/Execution.Tests/DeferTests.cs | 28 +- ...cutorBuilderExtensions_Validation.Tests.cs | 66 +- .../DependencyInjectionTests.cs | 40 +- .../Errors/ErrorBehaviorTests.cs | 8 +- .../Errors/NullErrorPropagationTests.cs | 48 +- .../HotChocolate.Execution.Tests.csproj | 16 + .../Instrumentation/ApolloTracingTests.cs | 114 --- .../DiagnosticListenerTests.cs | 4 +- .../Cancellation/CancellationTests.cs | 8 +- .../VariableCoercionIntegrationTests.cs | 80 +- .../Integration/DataLoader/DataLoaderTests.cs | 92 +-- .../DataLoader/UseDataLoaderTests.cs | 10 +- .../Spec/InputObjectsCanBeVariablesTest.cs | 67 +- .../Integration/Spec/ListTypeTests.cs | 14 +- .../StarWarsCodeFirstTests.cs | 517 +++++++------ .../TypeConverter/TypeConverterTests.cs | 36 +- .../Execution.Tests/MiddlewareContextTests.cs | 37 +- .../Pipeline/ComplexityAnalyzerTests.cs | 593 --------------- .../Pipeline/DocumentCacheMiddlewareTests.cs | 36 +- .../Pipeline/DocumentParserMiddlewareTests.cs | 24 +- .../DocumentValidationMiddlewareTests.cs | 50 +- .../Pipeline/OperationCacheMiddlewareTests.cs | 30 +- .../RequestClassMiddlewareFactoryTests.cs | 2 +- .../Pipeline/TransactionScopeHandlerTests.cs | 42 +- .../SelectionIncludeConditionTests.cs | 116 ++- .../Execution.Tests/RequestExecutorTests.cs | 10 +- .../Execution.Tests/SchemaDirectiveTests.cs | 4 +- .../test/Execution.Tests/SchemaFirstTests.cs | 10 +- .../SourceObjectConversionTests.cs | 10 +- .../Core/test/Execution.Tests/StreamTests.cs | 24 +- .../Execution.Tests/TrueNullabilityTests.cs | 90 +-- .../__resources__/CostSchema.graphql | 2 + ...opedContextDataIsPassedAlongCorrectly.snap | 2 + ...ctConversionTests.ConvertSourceObject.snap | 2 + ...d_NullBubbling_Disabled_With_Variable.snap | 26 - ...eNullability_And_NullBubbling_Enabled.snap | 37 - ...yTests.Schema_With_TrueNullability.graphql | 4 +- .../SomeRequestMiddleware.cs | 4 +- .../CustomCursorHandlerTests.cs | 8 +- .../AnnotationBasedMutations.cs | 9 +- .../DateTimeZoneTypeTests.cs | 82 +-- ...rationTypeJsonRoundtripIntegrationTests.cs | 158 ++-- .../Types.NodaTime.Tests/DurationTypeTests.cs | 102 ++- ...stantTypeDateTimeOffsetIntegrationTests.cs | 60 +- .../InstantTypeGeneralIntegrationTests.cs | 47 +- .../Types.NodaTime.Tests/InstantTypeTests.cs | 64 +- .../IsoDayOfWeekTypeTests.cs | 85 ++- ...teTimeTypeFullRoundtripIntegrationTests.cs | 47 +- ...lDateTimeTypeGeneralIsoIntegrationTests.cs | 47 +- .../LocalDateTimeTypeTests.cs | 50 +- ...alDateTypeFullRoundtripIntegrationTests.cs | 62 +- .../LocalDateTypeTests.cs | 47 +- ...LocalTimeTypeGeneralIsoIntegrationTests.cs | 56 +- .../LocalTimeTypeTests.cs | 73 +- ...odaTimeRequestExecutorBuilderExtensions.cs | 4 +- ...setDateTimeTypeExtendedIntegrationTests.cs | 73 +- ...fsetDateTimeTypeGeneralIntegrationTests.cs | 67 +- ...fsetDateTimeTypeRfc3339IntegrationTests.cs | 67 +- .../OffsetDateTimeTypeTests.cs | 77 +- ...etDateTypeFullRoundtripIntegrationTests.cs | 67 +- .../OffsetDateTypeTests.cs | 55 +- .../OffsetTimeTypeExtendedIntegrationTests.cs | 67 +- .../OffsetTimeTypeRfc3339IntegrationTests.cs | 78 +- .../OffsetTimeTypeTests.cs | 53 +- ...eneralInvariantWithoutZIntegrationTests.cs | 63 +- .../Types.NodaTime.Tests/OffsetTypeTests.cs | 90 ++- ...eriodTypeNormalizingIsoIntegrationTests.cs | 58 +- .../Types.NodaTime.Tests/PeriodTypeTests.cs | 49 +- ...ZonedDateTimeTypeCustomIntegrationTests.cs | 49 +- .../ZonedDateTimeTypeTests.cs | 97 +-- .../CustomCollectionSegmentHandlerTests.cs | 6 +- .../ResolverContextStateExtensionTests.cs | 6 +- .../Resolvers/CustomResolverCompilerTests.cs | 6 +- .../Resolvers/ResolverServiceTests.cs | 158 ++-- .../test/Types.Tests/Types/ArgumentTests.cs | 8 +- .../Types/Directives/CostDirectiveTests.cs | 58 -- .../Directives/CostDirectiveTypeTests.cs | 256 ------- .../Directives/MultiplierPathStringTests.cs | 375 ---------- .../Types/InputObjectTypeAttributeTests.cs | 16 +- .../Types.Tests/Types/InputParserTests.cs | 15 +- .../test/Types.Tests/Types/JsonTypeTests.cs | 12 +- .../test/Types.Tests/Types/ListTypeTests.cs | 32 +- .../test/Types.Tests/Types/ObjectTypeTests.cs | 12 +- .../Types/OneOfIntegrationTests.cs | 96 +-- .../Types/Relay/IdAttributeTests.cs | 287 ++++---- .../Types/Relay/IdDescriptorTests.cs | 65 +- .../Types.Tests/Types/Relay/NodeTypeTests.cs | 128 ++-- ...ributeTests.Id_On_Objects_InvalidType.snap | 2 +- .../Types.Tests/Types/Scalars/AnyTypeTests.cs | 697 ++++++++++-------- .../Types/Scalars/MultiplierPathTypeTests.cs | 210 ------ .../Core/test/Utilities/SnapshotExtensions.cs | 4 +- .../Core/test/Utilities/TestConfiguration.cs | 4 +- .../Core/test/Utilities/TestHelper.cs | 22 +- .../DocumentValidatorTests.cs | 77 +- .../IntrospectionRuleTests.cs | 1 - .../__resources__/CostSchema.graphql | 2 + ...yWithOneAnonymousAndOneNamedOperation.snap | 4 +- ...rTests.QueryWithTypeSystemDefinitions.snap | 8 +- ...sts.TwoQueryOperationsWithTheSameName.snap | 4 +- .../Data.AutoMapper.Tests/ProjectToTests.cs | 36 +- .../RequestExecutorBuilderExtensions.cs | 4 +- ...ameworkResolverCompilerIntegrationTests.cs | 74 +- .../FilteringAndPaging.cs | 12 +- .../QueryableFilterVisitorBooleanTests.cs | 60 +- .../QueryableFilterVisitorComparableTests.cs | 528 ++++++------- .../QueryableFilterVisitorEnumTests.cs | 144 ++-- .../QueryableFilterVisitorExecutableTests.cs | 60 +- .../QueryableFilterVisitorExpressionTests.cs | 36 +- .../QueryableFilterVisitorIdTests.cs | 308 ++++---- .../QueryableFilterVisitorInterfacesTests.cs | 18 +- .../QueryableFilterVisitorListTests.cs | 72 +- .../QueryableFilterVisitorObjectTests.cs | 264 +++---- .../QueryableFilterVisitorStringTests.cs | 360 ++++----- .../QueryableFilterVisitorStructTests.cs | 90 +-- .../QueryableFilterVisitorVariablesTests.cs | 59 +- ...eate_NullableStringIdEqual_Expression.snap | 2 +- .../FilterVisitorTestBase.cs | 4 +- .../FilteringAndPaging.cs | 12 +- .../QueryableFilterVisitorBooleanTests.cs | 60 +- .../QueryableFilterVisitorComparableTests.cs | 528 ++++++------- .../QueryableFilterVisitorEnumTests.cs | 144 ++-- .../QueryableFilterVisitorExecutableTests.cs | 60 +- .../QueryableFilterVisitorExpressionTests.cs | 36 +- .../QueryableFilterVisitorInterfacesTests.cs | 18 +- .../QueryableFilterVisitorListTests.cs | 72 +- .../QueryableFilterVisitorObjectTests.cs | 246 +++---- .../QueryableFilterVisitorStringTests.cs | 360 ++++----- .../QueryableFilteringExtensionsTests.cs | 32 +- .../ProjectionVisitorTestBase.cs | 4 +- .../QueryableFirstOrDefaultTests.cs | 30 +- .../QueryableProjectionExtensionsTests.cs | 24 +- .../QueryableProjectionFilterTests.cs | 42 +- .../QueryableProjectionHashSetTest.cs | 12 +- .../QueryableProjectionInterfaceTypeTests.cs | 42 +- .../QueryableProjectionNestedTests.cs | 30 +- .../QueryableProjectionSetTest.cs | 12 +- .../QueryableProjectionSortedSetTest.cs | 12 +- .../QueryableProjectionSortingTests.cs | 24 +- .../QueryableProjectionUnionTypeTests.cs | 30 +- ...eryableProjectionVisitorExecutableTests.cs | 18 +- ...ryableProjectionVisitorIsProjectedTests.cs | 30 +- .../QueryableProjectionVisitorPagingTests.cs | 132 ++-- .../QueryableProjectionVisitorScalarTests.cs | 30 +- .../QueryableSingleOrDefaultTests.cs | 30 +- .../SelectionContextTests.cs | 10 +- .../QueryableFilterVisitorInterfacesTests.cs | 12 +- .../QueryableSortVisitorBooleanTests.cs | 36 +- .../QueryableSortVisitorComparableTests.cs | 24 +- .../QueryableSortVisitorEnumTests.cs | 24 +- .../QueryableSortVisitorExecutableTests.cs | 36 +- .../QueryableSortVisitorExpressionTests.cs | 24 +- .../QueryableSortVisitorObjectTests.cs | 120 +-- .../QueryableSortVisitorStringTests.cs | 24 +- .../QueryableSortVisitorVariablesTests.cs | 83 ++- .../QueryableSortVisitorBooleanTests.cs | 36 +- .../QueryableSortVisitorComparableTests.cs | 24 +- .../QueryableSortVisitorEnumTests.cs | 24 +- .../QueryableSortVisitorExecutableTests.cs | 36 +- .../QueryableSortVisitorExpressionTests.cs | 24 +- .../QueryableSortVisitorObjectTests.cs | 333 +++++---- .../QueryableSortVisitorStringTests.cs | 24 +- .../SortVisitorTestBase.cs | 4 +- .../QueryableSortingExtensionsTests.cs | 24 +- .../src/Diagnostics/ActivityEnricher.cs | 100 ++- .../ActivityExecutionDiagnosticListener.cs | 2 +- .../ActivityServerDiagnosticListener.cs | 2 +- .../Scopes/ExecuteOperationScope.cs | 2 +- .../Diagnostics/Scopes/ExecuteRequestScope.cs | 2 +- .../QueryInstrumentationTests.cs | 97 --- .../FusionRequestExecutorBuilderExtensions.cs | 4 - .../src/Core/Execution/Nodes/QueryPlan.cs | 2 +- .../src/Core/Execution/Nodes/Subscribe.cs | 2 +- .../Pipeline/OperationExecutionMiddleware.cs | 3 +- .../Fusion/src/Core/FusionOptions.cs | 2 +- .../Fusion/src/Core/Utilities/ErrorHelper.cs | 4 +- .../Fusion/test/Core.Tests/DataTests.cs | 8 +- .../test/Core.Tests/DemoIntegrationTests.cs | 361 +++++---- .../Fusion/test/Core.Tests/ErrorTests.cs | 64 +- .../test/Core.Tests/EventStreamTests.cs | 8 +- .../Fusion/test/Core.Tests/FileUploadTests.cs | 30 +- .../Fusion/test/Core.Tests/InterfaceTests.cs | 24 +- .../test/Core.Tests/IntrospectionTests.cs | 8 +- .../Fusion/test/Core.Tests/UnionTests.cs | 40 +- .../src/Language.Web/GraphQLRequest.cs | 7 +- .../Utf8GraphQLRequestParser.Json.cs | 4 +- .../Utf8GraphQLRequestParser.Request.cs | 2 +- .../Utf8GraphQLRequestParser.Utilities.cs | 35 +- .../Parser/GraphQLRequestParserTests.cs | 4 +- ..._Kitchen_Sink_Query_AllProps_No_Cache.snap | 176 ++--- .../FilterVisitorTestBase.cs | 4 +- .../FilteringAndPaging.cs | 12 +- .../IntegrationTests.cs | 6 +- .../QueryableFilterVisitorBooleanTests.cs | 60 +- .../QueryableFilterVisitorComparableTests.cs | 528 ++++++------- .../QueryableFilterVisitorEnumTests.cs | 144 ++-- .../QueryableFilterVisitorExecutableTests.cs | 60 +- .../QueryableFilterVisitorInterfacesTests.cs | 18 +- .../QueryableFilterVisitorListTests.cs | 66 +- .../QueryableFilterVisitorObjectTests.cs | 246 +++---- .../QueryableFilterVisitorStringTests.cs | 366 ++++----- .../QueryableSortVisitorBooleanTests.cs | 36 +- .../QueryableSortVisitorComparableTests.cs | 24 +- .../QueryableSortVisitorEnumTests.cs | 24 +- .../QueryableSortVisitorExecutableTests.cs | 36 +- .../QueryableSortVisitorExpressionTests.cs | 12 +- .../QueryableSortVisitorObjectTests.cs | 494 ++++++------- .../QueryableSortVisitorStringTests.cs | 24 +- .../SortVisitorTestBase.cs | 4 +- .../FilterVisitorTestBase.cs | 4 +- .../MongoDbAggregateFluentTests.cs | 28 +- .../MongoDbCollectionTests.cs | 28 +- .../MongoDbFilterCombinatorTests.cs | 8 +- .../MongoDbFilterVisitorBooleanTests.cs | 60 +- .../MongoDbFilterVisitorComparableTests.cs | 556 +++++++------- .../MongoDbFilterVisitorDateOnlyTests.cs | 60 +- .../MongoDbFilterVisitorEnumTests.cs | 144 ++-- .../MongoDbFilterVisitorListTests.cs | 144 ++-- .../MongoDbFilterVisitorObjectIdTests.cs | 530 ++++++------- .../MongoDbFilterVisitorObjectTests.cs | 246 +++---- .../MongoDbFilterVisitorStringTests.cs | 360 ++++----- .../MongoDbFilterVisitorTimeOnlyTests.cs | 60 +- .../MongoDbFindFluentTests.cs | 40 +- ...MongoDbCursorPagingAggregateFluentTests.cs | 4 +- .../MongoDbCursorPagingFindFluentTests.cs | 4 +- .../MongoDbOffsetPagingAggregateTests.cs | 4 +- .../MongoDbOffsetPagingFindFluentTests.cs | 4 +- .../VisitorTestBase.cs | 4 +- .../MongoDbProjectionObjectsTests.cs | 14 +- ...ongoDbProjectionVisitorIsProjectedTests.cs | 26 +- .../MongoDbProjectionVisitorPagingTests.cs | 120 +-- .../MongoDbProjectionVisitorScalarTests.cs | 18 +- .../ProjectionVisitorTestBase.cs | 4 +- .../MongoDbAggregateFluentTests.cs | 28 +- .../MongoDbCollectionTests.cs | 28 +- .../MongoDbFindFluentTests.cs | 40 +- .../MongoDbSortVisitorBooleanTests.cs | 24 +- .../MongoDbSortVisitorComparableTests.cs | 24 +- .../MongoDbSortVisitorEnumTests.cs | 24 +- .../MongoDbSortVisitorObjectTests.cs | 96 +-- .../MongoDbSortVisitorStringTests.cs | 24 +- .../SortVisitorTestBase.cs | 4 +- .../test/Types.MongoDb/BsonTypeTests.cs | 688 +++++++++-------- .../test/Types.MongoDb/ObjectIdTypeTests.cs | 21 +- .../IntegrationTests.cs | 47 +- ...QueriesRequestExecutorBuilderExtensions.cs | 4 +- ...istedQueriesServiceCollectionExtensions.cs | 39 +- .../FileSystemQueryStorage.cs | 74 +- ...QueriesRequestExecutorBuilderExtensions.cs | 23 +- ...istedQueriesServiceCollectionExtensions.cs | 38 +- .../InMemoryQueryStorage.cs | 67 +- ...QueriesRequestExecutorBuilderExtensions.cs | 89 +-- ...istedQueriesServiceCollectionExtensions.cs | 48 +- .../RedisQueryStorage.cs | 57 +- .../FileSystemQueryStorageTests.cs | 66 +- .../IntegrationTests.cs | 16 +- .../ServiceCollectionTests.cs | 12 +- ...ntegrationTests.ExecutePersistedQuery.snap | 2 + ...nTests.ExecutePersistedQuery_NotFound.snap | 7 +- ....AddFileSystemQueryStorage_1_Services.snap | 6 +- ....AddFileSystemQueryStorage_2_Services.snap | 6 +- ...OnlyFileSystemQueryStorage_1_Services.snap | 6 +- ...OnlyFileSystemQueryStorage_2_Services.snap | 6 +- .../InMemoryQueryStorageTests.cs | 24 +- .../IntegrationTests.cs | 23 +- .../RequestExecutorBuilderTests.cs | 15 +- .../ServiceCollectionTests.cs | 18 +- .../IntegrationTests.cs | 89 +-- .../RedisQueryStorageTests.cs | 62 +- .../RequestExecutorBuilderTests.cs | 78 +- .../ServiceCollectionExtensionsTests.cs | 50 +- ...ntegrationTests.ExecutePersistedQuery.snap | 2 + ...s.ExecutePersistedQuery_ApplicationDI.snap | 2 + ...ePersistedQuery_ApplicationDI_Default.snap | 2 + ...ecutePersistedQuery_Before_Expiration.snap | 2 + ...nTests.ExecutePersistedQuery_NotFound.snap | 7 +- ...nsTests.AddRedisQueryStorage_Services.snap | 10 +- .../FilterVisitorTestBase.cs | 4 +- .../FilteringAndPaging.cs | 12 +- .../QueryableFilterVisitorBooleanTests.cs | 60 +- .../QueryableFilterVisitorComparableTests.cs | 528 ++++++------- .../QueryableFilterVisitorEnumTests.cs | 144 ++-- .../QueryableFilterVisitorExecutableTests.cs | 60 +- .../QueryableFilterVisitorInterfacesTests.cs | 18 +- .../QueryableFilterVisitorListTests.cs | 48 +- .../QueryableFilterVisitorObjectTests.cs | 246 +++---- .../QueryableFilterVisitorStringTests.cs | 360 ++++----- .../RavenAsyncDocumentQueryTests.cs | 4 +- .../RavenDocumentQueryTests.cs | 4 +- .../VisitorTestBase.cs | 4 +- .../ProjectionVisitorTestBase.cs | 4 +- .../QueryableFirstOrDefaultTests.cs | 30 +- .../QueryableProjectionFilterTests.cs | 42 +- .../QueryableProjectionHashSetTest.cs | 12 +- .../QueryableProjectionInterfaceTypeTests.cs | 42 +- .../QueryableProjectionNestedTests.cs | 30 +- .../QueryableProjectionSetTest.cs | 12 +- .../QueryableProjectionSortedSetTest.cs | 12 +- .../QueryableProjectionSortingTests.cs | 24 +- .../QueryableProjectionUnionTypeTests.cs | 30 +- ...eryableProjectionVisitorExecutableTests.cs | 18 +- ...ryableProjectionVisitorIsProjectedTests.cs | 30 +- .../QueryableProjectionVisitorPagingTests.cs | 132 ++-- .../QueryableProjectionVisitorScalarTests.cs | 30 +- .../QueryableSingleOrDefaultTests.cs | 30 +- .../QueryableSortVisitorBooleanTests.cs | 36 +- .../QueryableSortVisitorComparableTests.cs | 24 +- .../QueryableSortVisitorEnumTests.cs | 24 +- .../QueryableSortVisitorExecutableTests.cs | 36 +- .../QueryableSortVisitorExpressionTests.cs | 12 +- .../QueryableSortVisitorObjectTests.cs | 238 +++--- .../QueryableSortVisitorStringTests.cs | 24 +- .../SortVisitorTestBase.cs | 4 +- .../FilterVisitorTestBase.cs | 4 +- .../QueryableFilterVisitorContainsTests.cs | 24 +- .../QueryableFilterVisitorDistanceTests.cs | 12 +- .../QueryableFilterVisitorIntersectTests.cs | 12 +- .../QueryableFilterVisitorOverlapsTests.cs | 12 +- .../QueryableFilterVisitorTouchesTests.cs | 12 +- .../QueryableFilterVisitorWithinTests.cs | 12 +- .../FilterVisitorTestBase.cs | 4 +- .../QueryableFilterVisitorTests.cs | 6 +- ...ospectionClientTests.IntrospectServer.snap | 2 - .../Core/Serialization/BuiltInScalarNames.cs | 1 - .../IInMemoryRequestInterceptor.cs | 2 +- .../DependencyInjection/InMemoryClient.cs | 12 +- .../Transport.InMemory/InMemoryConnection.cs | 2 +- .../InMemoryClientBuilderExtensionsTests.cs | 2 +- .../InMemoryClientTests.cs | 17 +- .../IntegrationTests.cs | 9 +- .../TestHelper/TestServerHelper.cs | 11 +- .../CodeGeneration.CSharp/CSharpGenerator.cs | 3 +- .../src/CodeGeneration/BuiltInScalarNames.cs | 1 - .../Utilities/OperationDocumentHelper.cs | 3 +- ...st.Execute_StarWarsIntrospection_Test.snap | 47 -- .../src/blog/2019-04-11-integration-tests.md | 4 +- .../2021-07-20-rider-language-injection.md | 2 +- .../execution-engine/custom-context-data.md | 2 +- .../v11/api-reference/aspnetcore.md | 4 +- .../v11/api-reference/custom-context-data.md | 2 +- .../v11/api-reference/dependency-injection.md | 4 +- .../api-reference/migrate-from-10-to-11.md | 4 +- .../schema-configuration.md | 2 +- .../v11/security/authorization.md | 2 +- .../v12/api-reference/custom-context-data.md | 2 +- .../api-reference/migrate-from-10-to-11.md | 4 +- .../schema-configuration.md | 2 +- .../v12/security/authorization.md | 2 +- .../v12/server/dependency-injection.md | 6 +- .../hotchocolate/v12/server/global-state.md | 4 +- .../hotchocolate/v12/server/interceptors.md | 22 +- .../hotchocolate/v12/server/introspection.md | 4 +- .../v13/api-reference/custom-context-data.md | 2 +- .../schema-configuration.md | 2 +- .../v13/migrating/migrate-from-10-to-11.md | 4 +- .../v13/migrating/migrate-from-12-to-13.md | 12 +- .../v13/performance/persisted-queries.md | 4 +- .../v13/security/authorization.md | 2 +- .../v13/server/dependency-injection.md | 6 +- .../hotchocolate/v13/server/global-state.md | 4 +- .../hotchocolate/v13/server/interceptors.md | 22 +- .../hotchocolate/v13/server/introspection.md | 4 +- 653 files changed, 15331 insertions(+), 19577 deletions(-) create mode 100644 src/HotChocolate/AspNetCore/src/Transport.Abstractions/IOperationRequest.cs create mode 100644 src/HotChocolate/AspNetCore/src/Transport.Abstractions/IRequestBody.cs create mode 100644 src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationBatchRequest.cs create mode 100644 src/HotChocolate/AspNetCore/src/Transport.Abstractions/VariableBatchRequest.cs rename src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/{PersistedQueryCache.cs => TestOperationDocumentStorage.cs} (52%) create mode 100644 src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.OperationBatch.md create mode 100644 src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.VariableBatch.md create mode 100644 src/HotChocolate/AspNetCore/test/Transport.Http.Tests/VariableBatchRequestTests.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IExecutionRequest.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocument.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocumentStorage.cs rename src/HotChocolate/Core/src/Abstractions/Execution/{IQueryRequest.cs => IOperationRequest.cs} (58%) rename src/HotChocolate/Core/src/Abstractions/Execution/{IQueryResult.cs => IOperationResult.cs} (85%) rename src/HotChocolate/Core/src/Abstractions/Execution/{IQueryResultFormatter.cs => IOperationResultFormatter.cs} (89%) delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IQuery.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequestBuilder.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultBuilder.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IReadStoredQueries.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/IWriteStoredQueries.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationDocument.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentId.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentSourceText.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationRequest.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBatch.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilder.cs create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilderExtensions.cs rename src/HotChocolate/Core/src/Abstractions/Execution/{QueryResult.cs => OperationResult.cs} (77%) create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBatch.cs rename src/HotChocolate/Core/src/Abstractions/Execution/{QueryResultBuilder.cs => OperationResultBuilder.cs} (69%) create mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilderExtensions.cs rename src/HotChocolate/Core/src/Abstractions/Execution/{QueryResultHelper.cs => OperationResultHelper.cs} (97%) delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/QueryDocument.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/QueryException.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilder.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderException.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderExtensions.cs delete mode 100644 src/HotChocolate/Core/src/Abstractions/Execution/QuerySourceText.cs rename src/HotChocolate/Core/src/Abstractions/Execution/{QueryRequest.cs => VariableBatchRequest.cs} (54%) delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.Enumerable.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitationMap.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitor.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/ExportDirective.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveHelper.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveType.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Batching/ExportedVariable.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Caching/DefaultComplexityAnalyzerCache.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Caching/IComplexityAnalyzerCache.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingDiagnosticEventListener.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResolverRecord.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultBuilder.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultKeys.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Options/ComplexityAnalyzerSettings.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Options/IComplexityAnalyzerOptionsAccessor.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerCompiler.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerDelegate.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityCalculation.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityContext.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Pipeline/Complexity/OperationComplexityAnalyzer.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Pipeline/OperationComplexityMiddleware.cs delete mode 100644 src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.Constants.cs delete mode 100644 src/HotChocolate/Core/src/Types/Extensions/DirectiveTypeExtensions.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Attributes/CostAttribute.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/CostDirective.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/CostDirectiveType.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/CostInterfaceFieldDescriptorExtensions.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/CostObjectFieldDescriptorExtensions.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/CostTypeInterceptor.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/MultiplierPathString.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Directives/NullBubblingDirective.cs delete mode 100644 src/HotChocolate/Core/src/Types/Types/Scalars/MultiplierPathType.cs rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/{QuerySourceTextTests.cs => OperationDocumentSourceTextTests.cs} (61%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/{QueryDocumentTests.cs => OperationDocumentTests.cs} (67%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/{QueryResultBuilderTests.cs => OperationResultBuilderTests.cs} (72%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryDocumentTests.QueryDocument_ToSource.snap => OperationDocumentSourceTextTests.QueryDocument_ToSource.snap} (100%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryDocumentTests.QueryDocument_ToString.snap => OperationDocumentSourceTextTests.QueryDocument_ToString.snap} (100%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryDocumentTests.QueryDocument_WriteTo.snap => OperationDocumentSourceTextTests.QuerySourceText_WriteToAsync.snap} (100%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryDocumentTests.QueryDocument_WriteToAsync.snap => OperationDocumentTests.QueryDocument_ToSource.snap} (100%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QuerySourceTextTests.QueryDocument_ToString.snap => OperationDocumentTests.QueryDocument_ToString.snap} (100%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QuerySourceTextTests.QueryDocument_ToSource.snap => OperationDocumentTests.QueryDocument_WriteToAsync.snap} (100%) create mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_Empty_OperationRequestBuilderException.snap rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap => OperationRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap} (96%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap} (62%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap} (67%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap} (70%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap} (62%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap => OperationRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap} (62%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap} (54%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap} (62%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap} (62%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap} (65%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap} (65%) create mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap => OperationRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap} (65%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap => OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap} (65%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap} (65%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap => OperationRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap} (67%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryResultBuilderTests.Create_Result_Set_Data.snap => OperationResultBuilderTests.Create_Result_Set_Data.snap} (82%) rename src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/{QueryResultBuilderTests.Create_Result_Set_Items.snap => OperationResultBuilderTests.Create_Result_Set_Items.snap} (82%) delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_Empty_QueryRequestBuilderException.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddExtension_RequestIsCreated.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddVariables_RequestIsCreated.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtension_RequestIsCreated.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_1.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_2.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_3.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_4.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_5.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariable_RequestIsCreated.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariables_RequestIsCreated.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsNotSet.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsSet.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsNotSet.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsSet.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteTo.snap delete mode 100644 src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteToAsync.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/BatchQueryExecutorTests.cs delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/CollectVariablesVisitorTests.cs delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Add_Value_To_Variable_List.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Convert_List_To_Single_Value_With_Converters.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportLeafList.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObject.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObjectList.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalar.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList_ExplicitVariable.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariables.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesFragmentDefinition.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesInlineFragment.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Instrumentation/ApolloTracingTests.cs delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/Pipeline/ComplexityAnalyzerTests.cs delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable.snap delete mode 100644 src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Enabled.snap delete mode 100644 src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTests.cs delete mode 100644 src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTypeTests.cs delete mode 100644 src/HotChocolate/Core/test/Types.Tests/Types/Directives/MultiplierPathStringTests.cs delete mode 100644 src/HotChocolate/Core/test/Types.Tests/Types/Scalars/MultiplierPathTypeTests.cs diff --git a/src/CookieCrumble/src/CookieCrumble/Extensions/CommonTestExtensions.cs b/src/CookieCrumble/src/CookieCrumble/Extensions/CommonTestExtensions.cs index 39a4d889ef7..6a65c19aab8 100644 --- a/src/CookieCrumble/src/CookieCrumble/Extensions/CommonTestExtensions.cs +++ b/src/CookieCrumble/src/CookieCrumble/Extensions/CommonTestExtensions.cs @@ -16,10 +16,10 @@ public static ValueTask CreateExceptionExecutor( if (context.ContextData.TryGetValue("ex", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("ex", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/CookieCrumble/src/CookieCrumble/Extensions/WriterExtensions.cs b/src/CookieCrumble/src/CookieCrumble/Extensions/WriterExtensions.cs index e508430092f..22662281191 100644 --- a/src/CookieCrumble/src/CookieCrumble/Extensions/WriterExtensions.cs +++ b/src/CookieCrumble/src/CookieCrumble/Extensions/WriterExtensions.cs @@ -20,6 +20,17 @@ public static void AppendLine(this IBufferWriter snapshot) snapshot.GetSpan(1)[0] = (byte)'\n'; snapshot.Advance(1); } + + public static void AppendLine(this IBufferWriter snapshot, bool appendWhenTrue) + { + if (!appendWhenTrue) + { + return; + } + + snapshot.GetSpan(1)[0] = (byte)'\n'; + snapshot.Advance(1); + } public static void AppendSeparator(this IBufferWriter snapshot) { diff --git a/src/CookieCrumble/src/CookieCrumble/Formatters/OperationResultSnapshotValueFormatter.cs b/src/CookieCrumble/src/CookieCrumble/Formatters/OperationResultSnapshotValueFormatter.cs index 352d9668297..1682c34ae9d 100644 --- a/src/CookieCrumble/src/CookieCrumble/Formatters/OperationResultSnapshotValueFormatter.cs +++ b/src/CookieCrumble/src/CookieCrumble/Formatters/OperationResultSnapshotValueFormatter.cs @@ -8,24 +8,43 @@ internal sealed class OperationResultSnapshotValueFormatter : SnapshotValueForma { protected override void Format(IBufferWriter snapshot, OperationResult value) { + var next = false; + + if(value.RequestIndex.HasValue) + { + snapshot.Append("RequestIndex: "); + snapshot.Append(value.RequestIndex.Value.ToString()); + next = true; + } + + if(value.VariableIndex.HasValue) + { + snapshot.AppendLine(appendWhenTrue: next); + snapshot.Append("VariableIndex: "); + snapshot.Append(value.VariableIndex.Value.ToString()); + next = true; + } + if (value.Data.ValueKind is JsonValueKind.Object) { - snapshot.Append("Data:"); - snapshot.AppendLine(); + snapshot.AppendLine(appendWhenTrue: next); + snapshot.Append("Data: "); snapshot.Append(value.Data.ToString()); + next = true; } if (value.Errors.ValueKind is JsonValueKind.Array) { - snapshot.Append("Errors:"); - snapshot.AppendLine(); + snapshot.AppendLine(appendWhenTrue: next); + snapshot.Append("Errors: "); snapshot.Append(value.Errors.ToString()); + next = true; } if (value.Extensions.ValueKind is JsonValueKind.Object) { - snapshot.Append("Extensions:"); - snapshot.AppendLine(); + snapshot.AppendLine(appendWhenTrue: next); + snapshot.Append("Extensions: "); snapshot.Append(value.Extensions.ToString()); } } diff --git a/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/AnnotationBased/CertificationTests.cs b/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/AnnotationBased/CertificationTests.cs index a4e785174f3..55e6e046bfe 100644 --- a/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/AnnotationBased/CertificationTests.cs +++ b/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/AnnotationBased/CertificationTests.cs @@ -33,7 +33,7 @@ public async Task Subgraph_SDL() // assert Assert.IsType( Assert.IsType( - Assert.IsType(result).Data) + Assert.IsType(result).Data) .GetValueOrDefault("_service")) .GetValueOrDefault("sdl") .MatchSnapshot(); diff --git a/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/CodeFirst/CertificationTests.cs b/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/CodeFirst/CertificationTests.cs index 261e70ff7c9..b417b572dcd 100644 --- a/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/CodeFirst/CertificationTests.cs +++ b/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/CertificationSchema/CodeFirst/CertificationTests.cs @@ -33,7 +33,7 @@ public async Task Subgraph_SDL() """); // assert - var queryResult = Assert.IsType(result); + var queryResult = Assert.IsType(result); var data = Assert.IsType(queryResult.Data); var service = Assert.IsType(data.GetValueOrDefault("_service")); service.GetValueOrDefault("sdl").MatchSnapshot(); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultHttpRequestInterceptor.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultHttpRequestInterceptor.cs index 0f3701f7338..d53424b863a 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultHttpRequestInterceptor.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultHttpRequestInterceptor.cs @@ -13,7 +13,7 @@ public class DefaultHttpRequestInterceptor : IHttpRequestInterceptor public virtual ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { var userState = new UserState(context.User); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultSocketSessionInterceptor.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultSocketSessionInterceptor.cs index 486f0556c7a..23bce5b0ac9 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultSocketSessionInterceptor.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/DefaultSocketSessionInterceptor.cs @@ -18,13 +18,13 @@ public virtual ValueTask OnConnectAsync( public virtual ValueTask OnRequestAsync( ISocketSession session, string operationSessionId, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken = default) { var context = session.Connection.HttpContext; var userState = new UserState(context.User); var serviceScopeFactory = session.Connection.RequestServices.GetService(); - + requestBuilder.TryAddGlobalState(nameof(IServiceScopeFactory), serviceScopeFactory); requestBuilder.TryAddGlobalState(nameof(CancellationToken), session.Connection.RequestAborted); requestBuilder.TryAddGlobalState(nameof(HttpContext), context); @@ -47,10 +47,10 @@ public virtual ValueTask OnRequestAsync( return default; } - public virtual ValueTask OnResultAsync( + public virtual ValueTask OnResultAsync( ISocketSession session, string operationSessionId, - IQueryResult result, + IOperationResult result, CancellationToken cancellationToken = default) => new(result); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/DelegateHttpRequestInterceptor.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/DelegateHttpRequestInterceptor.cs index b9104392019..ba265326a39 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/DelegateHttpRequestInterceptor.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/DelegateHttpRequestInterceptor.cs @@ -14,7 +14,7 @@ public DelegateHttpRequestInterceptor(HttpRequestInterceptorDelegate interceptor public override async ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { await _interceptor(context, requestExecutor, requestBuilder, cancellationToken); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/ErrorHelper.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/ErrorHelper.cs index bd839086af7..6cf4f8533b1 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/ErrorHelper.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/ErrorHelper.cs @@ -25,14 +25,14 @@ public static IError NoSupportedAcceptMediaType() .SetCode(ErrorCodes.Server.NoSupportedAcceptMediaType) .Build(); - public static IQueryResult TypeNameIsEmpty() - => QueryResultBuilder.CreateError( + public static IOperationResult TypeNameIsEmpty() + => OperationResultBuilder.CreateError( new Error( ErrorHelper_TypeNameIsEmpty, code: ErrorCodes.Server.TypeParameterIsEmpty)); - public static IQueryResult InvalidTypeName(string typeName) - => QueryResultBuilder.CreateError( + public static IOperationResult InvalidTypeName(string typeName) + => OperationResultBuilder.CreateError( new Error( ErrorHelper_InvalidTypeName, code: ErrorCodes.Server.InvalidTypeName, @@ -41,8 +41,8 @@ public static IQueryResult InvalidTypeName(string typeName) { nameof(typeName), typeName }, })); - public static IQueryResult TypeNotFound(string typeName) - => QueryResultBuilder.CreateError( + public static IOperationResult TypeNotFound(string typeName) + => OperationResultBuilder.CreateError( new Error( string.Format(ErrorHelper_TypeNotFound, typeName), code: ErrorCodes.Server.TypeDoesNotExist, @@ -51,8 +51,8 @@ public static IQueryResult TypeNotFound(string typeName) { nameof(typeName), typeName }, })); - public static IQueryResult InvalidAcceptMediaType(string headerValue) - => QueryResultBuilder.CreateError( + public static IOperationResult InvalidAcceptMediaType(string headerValue) + => OperationResultBuilder.CreateError( new Error( string.Format(ErrorHelper_InvalidAcceptMediaType, headerValue), code: ErrorCodes.Server.InvalidAcceptHeaderValue, @@ -61,8 +61,8 @@ public static IQueryResult InvalidAcceptMediaType(string headerValue) { nameof(headerValue), headerValue }, })); - public static IQueryResult MultiPartRequestPreflightRequired() - => QueryResultBuilder.CreateError( + public static IOperationResult MultiPartRequestPreflightRequired() + => OperationResultBuilder.CreateError( new Error( ErrorHelper_MultiPartRequestPreflightRequired, code: ErrorCodes.Server.MultiPartPreflightRequired)); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/HeaderUtilities.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/HeaderUtilities.cs index dcf7f2535a2..5901715673a 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/HeaderUtilities.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/HeaderUtilities.cs @@ -165,7 +165,7 @@ public AcceptHeaderResult(string headerValue) public AcceptMediaType[] AcceptMediaTypes { get; } - public IQueryResult? ErrorResult { get; } + public IOperationResult? ErrorResult { get; } [MemberNotNullWhen(true, nameof(ErrorResult))] public bool HasError { get; } diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/HttpMultipartMiddleware.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/HttpMultipartMiddleware.cs index 1c1bcf5d750..a21464b3123 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/HttpMultipartMiddleware.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/HttpMultipartMiddleware.cs @@ -18,7 +18,7 @@ public sealed class HttpMultipartMiddleware : HttpPostMiddlewareBase private const string _operations = "operations"; private const string _map = "map"; private readonly FormOptions _formOptions; - private readonly IQueryResult _multipartRequestError = MultiPartRequestPreflightRequired(); + private readonly IOperationResult _multipartRequestError = MultiPartRequestPreflightRequired(); public HttpMultipartMiddleware( HttpRequestDelegate next, @@ -185,7 +185,7 @@ private static void InsertFilesIntoRequest( GraphQLRequest request, IDictionary fileMap) { - if (!(request.Variables is Dictionary mutableVariables)) + if (request.Variables is not [Dictionary mutableVariables,]) { throw new InvalidOperationException( HttpMultipartMiddleware_InsertFilesIntoRequest_VariablesImmutable); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/HttpPostMiddlewareBase.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/HttpPostMiddlewareBase.cs index 90e56f1c782..f8975cdabb8 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/HttpPostMiddlewareBase.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/HttpPostMiddlewareBase.cs @@ -99,7 +99,7 @@ protected async Task HandleRequestAsync(HttpContext context) statusCode = HttpStatusCode.NotAcceptable; var error = ErrorHelper.NoSupportedAcceptMediaType(); - result = QueryResultBuilder.CreateError(error); + result = OperationResultBuilder.CreateError(error); DiagnosticEvents.HttpRequestError(context, error); goto HANDLE_RESULT; } @@ -120,7 +120,7 @@ protected async Task HandleRequestAsync(HttpContext context) // GraphQL error result. statusCode = HttpStatusCode.BadRequest; var errors = errorHandler.Handle(ex.Errors); - result = QueryResultBuilder.CreateError(errors); + result = OperationResultBuilder.CreateError(errors); DiagnosticEvents.ParserErrors(context, errors); goto HANDLE_RESULT; } @@ -128,7 +128,7 @@ protected async Task HandleRequestAsync(HttpContext context) { statusCode = HttpStatusCode.InternalServerError; var error = errorHandler.CreateUnexpectedError(ex).Build(); - result = QueryResultBuilder.CreateError(error); + result = OperationResultBuilder.CreateError(error); DiagnosticEvents.HttpRequestError(context, error); goto HANDLE_RESULT; } @@ -145,7 +145,7 @@ protected async Task HandleRequestAsync(HttpContext context) { statusCode = HttpStatusCode.BadRequest; var error = errorHandler.Handle(ErrorHelper.RequestHasNoElements()); - result = QueryResultBuilder.CreateError(error); + result = OperationResultBuilder.CreateError(error); DiagnosticEvents.HttpRequestError(context, error); break; } @@ -178,7 +178,7 @@ protected async Task HandleRequestAsync(HttpContext context) { var error = errorHandler.Handle(ErrorHelper.InvalidRequest()); statusCode = HttpStatusCode.BadRequest; - result = QueryResultBuilder.CreateError(error); + result = OperationResultBuilder.CreateError(error); DiagnosticEvents.HttpRequestError(context, error); } @@ -221,7 +221,7 @@ protected async Task HandleRequestAsync(HttpContext context) { var error = errorHandler.Handle(ErrorHelper.InvalidRequest()); statusCode = HttpStatusCode.BadRequest; - result = QueryResultBuilder.CreateError(error); + result = OperationResultBuilder.CreateError(error); DiagnosticEvents.HttpRequestError(context, error); } break; @@ -231,7 +231,7 @@ protected async Task HandleRequestAsync(HttpContext context) { // This allows extensions to throw GraphQL exceptions in the GraphQL interceptor. statusCode = null; // we let the serializer determine the status code. - result = QueryResultBuilder.CreateError(ex.Errors); + result = OperationResultBuilder.CreateError(ex.Errors); foreach (var error in ex.Errors) { @@ -242,7 +242,7 @@ protected async Task HandleRequestAsync(HttpContext context) { statusCode = HttpStatusCode.InternalServerError; var error = errorHandler.CreateUnexpectedError(ex).Build(); - result = QueryResultBuilder.CreateError(error); + result = OperationResultBuilder.CreateError(error); DiagnosticEvents.HttpRequestError(context, error); } @@ -262,7 +262,7 @@ protected async Task HandleRequestAsync(HttpContext context) // to the HTTP response stream. Debug.Assert(result is not null, "No GraphQL result was created."); - if (result is IQueryResult queryResult) + if (result is IOperationResult queryResult) { formatScope = DiagnosticEvents.FormatHttpResponse(context, queryResult); } diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/HttpRequestInterceptorDelegate.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/HttpRequestInterceptorDelegate.cs index 7d4fa2068b6..67300851fb6 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/HttpRequestInterceptorDelegate.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/HttpRequestInterceptorDelegate.cs @@ -5,5 +5,5 @@ namespace HotChocolate.AspNetCore; public delegate ValueTask HttpRequestInterceptorDelegate( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/IHttpRequestInterceptor.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/IHttpRequestInterceptor.cs index de29f910279..3050023fc52 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/IHttpRequestInterceptor.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/IHttpRequestInterceptor.cs @@ -26,6 +26,6 @@ public interface IHttpRequestInterceptor ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken); } diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/ISocketSessionInterceptor.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/ISocketSessionInterceptor.cs index dd111481ad1..d9af946aab2 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/ISocketSessionInterceptor.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/ISocketSessionInterceptor.cs @@ -47,7 +47,7 @@ ValueTask OnConnectAsync( ValueTask OnRequestAsync( ISocketSession session, string operationSessionId, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken = default); /// @@ -69,10 +69,10 @@ ValueTask OnRequestAsync( /// /// Returns the result that shall be send to the client. /// - ValueTask OnResultAsync( + ValueTask OnResultAsync( ISocketSession session, string operationSessionId, - IQueryResult result, + IOperationResult result, CancellationToken cancellationToken = default); /// diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/AggregateServerDiagnosticEventListener.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/AggregateServerDiagnosticEventListener.cs index 039023a4230..5f0dbf09438 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/AggregateServerDiagnosticEventListener.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/AggregateServerDiagnosticEventListener.cs @@ -87,7 +87,7 @@ public void ParserErrors(HttpContext context, IReadOnlyList errors) } } - public IDisposable FormatHttpResponse(HttpContext context, IQueryResult result) + public IDisposable FormatHttpResponse(HttpContext context, IOperationResult result) { var scopes = new IDisposable[_listeners.Length]; diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/IServerDiagnosticEvents.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/IServerDiagnosticEvents.cs index 0bc4513baab..f70a952c3f7 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/IServerDiagnosticEvents.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/IServerDiagnosticEvents.cs @@ -124,7 +124,7 @@ void StartOperationBatchRequest( /// /// A scope that will be disposed when GraphQL query result is written to the response stream. /// - IDisposable FormatHttpResponse(HttpContext context, IQueryResult result); + IDisposable FormatHttpResponse(HttpContext context, IOperationResult result); /// /// Called when starting to establish a GraphQL WebSocket session. diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/NoopServerDiagnosticEventListener.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/NoopServerDiagnosticEventListener.cs index 527f1f091ef..2387107c8e0 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/NoopServerDiagnosticEventListener.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/NoopServerDiagnosticEventListener.cs @@ -37,7 +37,7 @@ public void ParserErrors(HttpContext context, IReadOnlyList errors) { } - public IDisposable FormatHttpResponse(HttpContext context, IQueryResult result) => EmptyScope; + public IDisposable FormatHttpResponse(HttpContext context, IOperationResult result) => EmptyScope; public IDisposable WebSocketSession(HttpContext context) => EmptyScope; diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/ServerDiagnosticEventListener.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/ServerDiagnosticEventListener.cs index 7276c34e80d..c4b43872714 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/ServerDiagnosticEventListener.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Instrumentation/ServerDiagnosticEventListener.cs @@ -57,7 +57,7 @@ public virtual void ParserErrors(HttpContext context, IReadOnlyList erro } /// - public virtual IDisposable FormatHttpResponse(HttpContext context, IQueryResult result) + public virtual IDisposable FormatHttpResponse(HttpContext context, IOperationResult result) => EmptyScope; /// diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareBase.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareBase.cs index 96a3a5fdb74..9d6844a8af6 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareBase.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareBase.cs @@ -54,7 +54,7 @@ protected MiddlewareBase( /// Gets the request executor proxy. /// protected RequestExecutorProxy ExecutorProxy => _executorProxy; - + /// /// Gets the response formatter. /// @@ -118,7 +118,7 @@ protected static async Task ExecuteSingleAsync( { diagnosticEvents.StartSingleRequest(context, request); - var requestBuilder = QueryRequestBuilder.From(request); + var requestBuilder = OperationRequestBuilder.From(request); requestBuilder.SetFlags(flags); await requestInterceptor.OnCreateAsync( @@ -128,7 +128,7 @@ await requestInterceptor.OnCreateAsync( context.RequestAborted); return await requestExecutor.ExecuteAsync( - requestBuilder.Create(), + requestBuilder.Build(), context.RequestAborted); } @@ -143,12 +143,12 @@ protected static async Task ExecuteOperationBatchAsync( { diagnosticEvents.StartOperationBatchRequest(context, request, operationNames); - var requestBatch = new IQueryRequest[operationNames.Count]; + var requestBatch = new IOperationRequest[operationNames.Count]; for (var i = 0; i < operationNames.Count; i++) { - var requestBuilder = QueryRequestBuilder.From(request); - requestBuilder.SetOperation(operationNames[i]); + var requestBuilder = OperationRequestBuilder.From(request); + requestBuilder.SetOperationName(operationNames[i]); requestBuilder.SetFlags(flags); await requestInterceptor.OnCreateAsync( @@ -157,11 +157,11 @@ await requestInterceptor.OnCreateAsync( requestBuilder, context.RequestAborted); - requestBatch[i] = requestBuilder.Create(); + requestBatch[i] = requestBuilder.Build(); } return await requestExecutor.ExecuteBatchAsync( - requestBatch, + new OperationRequestBatch(requestBatch, services: context.RequestServices), cancellationToken: context.RequestAborted); } @@ -175,11 +175,11 @@ protected static async Task ExecuteBatchAsync( { diagnosticEvents.StartBatchRequest(context, requests); - var requestBatch = new IQueryRequest[requests.Count]; + var requestBatch = new IOperationRequest[requests.Count]; for (var i = 0; i < requests.Count; i++) { - var requestBuilder = QueryRequestBuilder.From(requests[i]); + var requestBuilder = OperationRequestBuilder.From(requests[i]); requestBuilder.SetFlags(flags); await requestInterceptor.OnCreateAsync( @@ -188,11 +188,11 @@ await requestInterceptor.OnCreateAsync( requestBuilder, context.RequestAborted); - requestBatch[i] = requestBuilder.Create(); + requestBatch[i] = requestBuilder.Build(); } return await requestExecutor.ExecuteBatchAsync( - requestBatch, + new OperationRequestBatch(requestBatch, services: context.RequestServices), cancellationToken: context.RequestAborted); } diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareHelper.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareHelper.cs index 3fee7fe3422..26eef44940b 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareHelper.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/MiddlewareHelper.cs @@ -127,13 +127,13 @@ public static async Task ParseSingleRequestFromBodyAsync( using (diagnosticEvents.ParseHttpRequest(context)) { try - { - request = + { + request = await requestParser.ParsePersistedOperationRequestAsync( operationId, - context.Request.Body, + context.Request.Body, context.RequestAborted); - + } catch (GraphQLRequestException ex) { @@ -212,7 +212,7 @@ public static async Task ExecuteRequestAsync( { diagnosticEvents.StartSingleRequest(context, request); - var requestBuilder = QueryRequestBuilder.From(request); + var requestBuilder = OperationRequestBuilder.From(request); requestBuilder.SetFlags(flags); await requestInterceptor.OnCreateAsync( @@ -222,7 +222,7 @@ await requestInterceptor.OnCreateAsync( context.RequestAborted); var result = await requestExecutor.ExecuteAsync( - requestBuilder.Create(), + requestBuilder.Build(), context.RequestAborted); return new ExecuteRequestResult(result); @@ -235,16 +235,16 @@ await requestInterceptor.OnCreateAsync( { diagnosticEvents.HttpRequestError(context, error); } - + return new ExecuteRequestResult( - QueryResultBuilder.CreateError(ex.Errors)); + OperationResultBuilder.CreateError(ex.Errors)); } catch (Exception ex) { var error = errorHandler.CreateUnexpectedError(ex).Build(); diagnosticEvents.HttpRequestError(context, error); return new ExecuteRequestResult( - QueryResultBuilder.CreateError(error), + OperationResultBuilder.CreateError(error), HttpStatusCode.InternalServerError); } } @@ -275,7 +275,7 @@ public static async Task WriteResultAsync( // to the HTTP response stream. Debug.Assert(result is not null, "No GraphQL result was created."); - if (result is IQueryResult queryResult) + if (result is IOperationResult queryResult) { formatScope = diagnosticEvents.FormatHttpResponse(context, queryResult); } @@ -308,7 +308,7 @@ public ValidateAcceptContentTypeResult( } public ValidateAcceptContentTypeResult( - IQueryResult errorResult, + IOperationResult errorResult, HttpStatusCode statusCode) { IsValid = false; @@ -324,7 +324,7 @@ public ValidateAcceptContentTypeResult( AcceptMediaType[] acceptMediaTypes) { IsValid = false; - Error = QueryResultBuilder.CreateError(error); + Error = OperationResultBuilder.CreateError(error); StatusCode = statusCode; RequestFlags = GraphQLRequestFlags.None; AcceptMediaTypes = acceptMediaTypes; @@ -334,7 +334,7 @@ public ValidateAcceptContentTypeResult( [MemberNotNullWhen(false, nameof(StatusCode))] public bool IsValid { get; } - public IQueryResult? Error { get; } + public IOperationResult? Error { get; } public HttpStatusCode? StatusCode { get; } @@ -356,7 +356,7 @@ public ParseRequestResult(GraphQLRequest request) public ParseRequestResult(IReadOnlyList errors, HttpStatusCode statusCode) { IsValid = false; - Error = QueryResultBuilder.CreateError(errors); + Error = OperationResultBuilder.CreateError(errors); StatusCode = statusCode; Request = null; } @@ -364,7 +364,7 @@ public ParseRequestResult(IReadOnlyList errors, HttpStatusCode statusCod public ParseRequestResult(IError error, HttpStatusCode statusCode) { IsValid = false; - Error = QueryResultBuilder.CreateError(error); + Error = OperationResultBuilder.CreateError(error); StatusCode = statusCode; Request = null; } @@ -376,7 +376,7 @@ public ParseRequestResult(IError error, HttpStatusCode statusCode) public GraphQLRequest? Request { get; } - public IQueryResult? Error { get; } + public IOperationResult? Error { get; } public HttpStatusCode? StatusCode { get; } } diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpRequestParser.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpRequestParser.cs index 9530b558531..4a92f9f8543 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpRequestParser.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpRequestParser.cs @@ -1,8 +1,6 @@ // ReSharper disable RedundantSuppressNullableWarningExpression using System.Buffers; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using Microsoft.AspNetCore.Http; using HotChocolate.Language; using HotChocolate.Utilities; @@ -138,12 +136,10 @@ public GraphQLRequest ParseRequestFromParams(IQueryCollection parameters) document = result.Document; } - IReadOnlyDictionary? variables = null; - - // if we find variables we do need to parse them + IReadOnlyList>? variableSet = null; if ((string?)parameters[_variablesKey] is { Length: > 0, } sv) { - variables = ParseVariables(sv); + variableSet = ParseVariables(sv); } if (extensions is null && @@ -157,7 +153,7 @@ public GraphQLRequest ParseRequestFromParams(IQueryCollection parameters) queryId, queryHash, operationName, - variables, + variableSet, extensions); } catch (SyntaxException ex) @@ -177,10 +173,10 @@ public GraphQLRequest ParsePersistedOperationRequestFromParams(string operationI try { - IReadOnlyDictionary? variables = null; + IReadOnlyList>? variableSet = null; if ((string?)parameters[_variablesKey] is { Length: > 0, } sv) { - variables = ParseVariables(sv); + variableSet = ParseVariables(sv); } IReadOnlyDictionary? extensions = null; @@ -195,7 +191,7 @@ public GraphQLRequest ParsePersistedOperationRequestFromParams(string operationI operationId, null, operationName, - variables, + variableSet, extensions); } catch (SyntaxException ex) @@ -329,32 +325,9 @@ internal static IReadOnlyList EnsureValidQueryId(IReadOnlyList 96 and < 123 or > 64 and < 91: - case > 47 and < 58: - case 45 or 95: - return true; - - default: - return false; + throw ErrorHelper.InvalidQueryIdFormat(); } } } \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpResponseFormatter.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpResponseFormatter.cs index dd3b6150003..1b261aa4c97 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpResponseFormatter.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Serialization/DefaultHttpResponseFormatter.cs @@ -159,44 +159,60 @@ public async ValueTask FormatAsync( throw ThrowHelper.Formatter_InvalidAcceptMediaType(); } - if (result.Kind is SingleResult) + switch (result) { - var queryResult = (IQueryResult)result; - var statusCode = (int)OnDetermineStatusCode(queryResult, format, proposedStatusCode); + case IOperationResult operationResult: + { + var statusCode = (int)OnDetermineStatusCode(operationResult, format, proposedStatusCode); - response.ContentType = format.ContentType; - response.StatusCode = statusCode; + response.ContentType = format.ContentType; + response.StatusCode = statusCode; - if (result.ContextData is not null && - result.ContextData.TryGetValue(CacheControlHeaderValue, out var value) && - value is string cacheControlHeaderValue) - { - response.Headers.CacheControl = cacheControlHeaderValue; + if (result.ContextData is not null && + result.ContextData.TryGetValue(CacheControlHeaderValue, out var value) && + value is string cacheControlHeaderValue) + { + response.Headers.CacheControl = cacheControlHeaderValue; + } + + OnWriteResponseHeaders(operationResult, format, response.Headers); + + await format.Formatter.FormatAsync(result, response.Body, cancellationToken); + break; } - OnWriteResponseHeaders(queryResult, format, response.Headers); + case OperationResultBatch resultBatch: + { + var statusCode = (int)OnDetermineStatusCode(resultBatch, format, proposedStatusCode); + + response.ContentType = format.ContentType; + response.StatusCode = statusCode; + response.Headers.CacheControl = HttpHeaderValues.NoCache; + OnWriteResponseHeaders(resultBatch, format, response.Headers); + await response.Body.FlushAsync(cancellationToken); + + await format.Formatter.FormatAsync(result, response.Body, cancellationToken); + break; + } - await format.Formatter.FormatAsync(result, response.Body, cancellationToken); - } - else if (result.Kind is DeferredResult or BatchResult or SubscriptionResult) - { - var responseStream = (IResponseStream)result; - var statusCode = (int)OnDetermineStatusCode(responseStream, format, proposedStatusCode); + case IResponseStream responseStream: + { + var statusCode = (int)OnDetermineStatusCode(responseStream, format, proposedStatusCode); - response.ContentType = format.ContentType; - response.StatusCode = statusCode; - response.Headers.CacheControl = HttpHeaderValues.NoCache; - OnWriteResponseHeaders(responseStream, format, response.Headers); + response.ContentType = format.ContentType; + response.StatusCode = statusCode; + response.Headers.CacheControl = HttpHeaderValues.NoCache; + OnWriteResponseHeaders(responseStream, format, response.Headers); + await response.Body.FlushAsync(cancellationToken); - await response.Body.FlushAsync(cancellationToken); + await format.Formatter.FormatAsync(result, response.Body, cancellationToken); + break; + } - await format.Formatter.FormatAsync(result, response.Body, cancellationToken); - } - else - { - // we should not hit this point except in the case that we introduce a new - // ExecutionResultKind and forget to update this method. - throw ThrowHelper.Formatter_ResultKindNotSupported(); + default: + // we should not hit this point except in the case that we introduce a new + // ExecutionResultKind and forget to update this method. + throw ThrowHelper.Formatter_ResultKindNotSupported(); } } @@ -204,7 +220,7 @@ public async ValueTask FormatAsync( /// Determines which status code shall be returned for this result. /// /// - /// The . + /// The . /// /// /// Provides information about the transport format that is applied. @@ -216,7 +232,7 @@ public async ValueTask FormatAsync( /// Returns the that the formatter must use. /// protected virtual HttpStatusCode OnDetermineStatusCode( - IQueryResult result, + IOperationResult result, FormatInfo format, HttpStatusCode? proposedStatusCode) { @@ -309,7 +325,7 @@ protected virtual HttpStatusCode OnDetermineStatusCode( /// the the formatter starts writing the response body. /// /// - /// The . + /// The . /// /// /// Provides information about the transport format that is applied. @@ -318,7 +334,7 @@ protected virtual HttpStatusCode OnDetermineStatusCode( /// The header dictionary. /// protected virtual void OnWriteResponseHeaders( - IQueryResult result, + IOperationResult result, FormatInfo format, IHeaderDictionary headers) { } @@ -373,6 +389,45 @@ protected virtual void OnWriteResponseHeaders( IResponseStream responseStream, FormatInfo format, IHeaderDictionary headers) { } + + /// + /// Determines which status code shall be returned for a result batch. + /// + /// + /// The . + /// + /// + /// Provides information about the transport format that is applied. + /// + /// + /// The proposed status code of the middleware. + /// + /// + /// Returns the that the formatter must use. + /// + protected virtual HttpStatusCode OnDetermineStatusCode( + OperationResultBatch resultBatch, + FormatInfo format, + HttpStatusCode? proposedStatusCode) + => HttpStatusCode.OK; + + /// + /// Override to write response headers to the response message before + /// the the formatter starts writing the response body. + /// + /// + /// The . + /// + /// + /// Provides information about the transport format that is applied. + /// + /// + /// The header dictionary. + /// + protected virtual void OnWriteResponseHeaders( + OperationResultBatch resultBatch, + FormatInfo format, + IHeaderDictionary headers) { } private FormatInfo? TryGetFormatter( IExecutionResult result, diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/OperationSession.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/OperationSession.cs index 48d3f4a9656..b421740a3cf 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/OperationSession.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/OperationSession.cs @@ -50,11 +50,11 @@ private async Task SendResultsAsync(GraphQLRequest request, CancellationToken ca { var requestBuilder = CreateRequestBuilder(request); await _interceptor.OnRequestAsync(_session, Id, requestBuilder, ct); - await using var result = await _executor.ExecuteAsync(requestBuilder.Create(), ct); + await using var result = await _executor.ExecuteAsync(requestBuilder.Build(), ct); switch (result) { - case IQueryResult queryResult: + case IOperationResult queryResult: if (queryResult.Data is null && queryResult.Errors is { Count: > 0, }) { await _session.Protocol.SendErrorMessageAsync( @@ -127,33 +127,33 @@ await _session.Protocol.SendErrorMessageAsync( } } - private static IQueryRequestBuilder CreateRequestBuilder(GraphQLRequest request) + private static OperationRequestBuilder CreateRequestBuilder(GraphQLRequest request) { - var requestBuilder = new QueryRequestBuilder(); + var requestBuilder = new OperationRequestBuilder(); if (request.Query is not null) { - requestBuilder.SetQuery(request.Query); + requestBuilder.SetDocument(request.Query); } if (request.OperationName is not null) { - requestBuilder.SetOperation(request.OperationName); + requestBuilder.SetOperationName(request.OperationName); } if (request.QueryId is not null) { - requestBuilder.SetQueryId(request.QueryId); + requestBuilder.SetDocumentId(request.QueryId); } if (request.QueryHash is not null) { - requestBuilder.SetQueryHash(request.QueryHash); + requestBuilder.SetDocumentHash(request.QueryHash); } if (request.Variables is not null) { - requestBuilder.SetVariableValues(request.Variables); + requestBuilder.SetVariableValuesSet(request.Variables); } if (request.Extensions is not null) @@ -164,7 +164,7 @@ private static IQueryRequestBuilder CreateRequestBuilder(GraphQLRequest request) return requestBuilder; } - private async Task SendResultMessageAsync(IQueryResult result, CancellationToken ct) + private async Task SendResultMessageAsync(IOperationResult result, CancellationToken ct) { result = await _interceptor.OnResultAsync(_session, Id, result, ct); await _session.Protocol.SendResultMessageAsync(_session, Id, result, ct); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/Apollo/ApolloSubscriptionProtocolHandler.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/Apollo/ApolloSubscriptionProtocolHandler.cs index e303ea24486..9c56e0b5300 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/Apollo/ApolloSubscriptionProtocolHandler.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/Apollo/ApolloSubscriptionProtocolHandler.cs @@ -236,7 +236,7 @@ public ValueTask SendKeepAliveMessageAsync( public async ValueTask SendResultMessageAsync( ISocketSession session, string operationSessionId, - IQueryResult result, + IOperationResult result, CancellationToken cancellationToken) { using var arrayWriter = new ArrayWriter(); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/GraphQLOverWebSocket/GraphQLOverWebSocketProtocolHandler.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/GraphQLOverWebSocket/GraphQLOverWebSocketProtocolHandler.cs index 3b1788ca919..edd4e5d6395 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/GraphQLOverWebSocket/GraphQLOverWebSocketProtocolHandler.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/GraphQLOverWebSocket/GraphQLOverWebSocketProtocolHandler.cs @@ -212,7 +212,7 @@ public ValueTask SendKeepAliveMessageAsync( public async ValueTask SendResultMessageAsync( ISocketSession session, string operationSessionId, - IQueryResult result, + IOperationResult result, CancellationToken cancellationToken) { using var arrayWriter = new ArrayWriter(); diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/IProtocolHandler.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/IProtocolHandler.cs index 7cd3006a4ba..d6e621e6459 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/IProtocolHandler.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Subscriptions/Protocols/IProtocolHandler.cs @@ -63,7 +63,7 @@ ValueTask SendKeepAliveMessageAsync( ValueTask SendResultMessageAsync( ISocketSession session, string operationSessionId, - IQueryResult result, + IOperationResult result, CancellationToken cancellationToken = default); /// diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/IOperationRequest.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/IOperationRequest.cs new file mode 100644 index 00000000000..c76bcef9659 --- /dev/null +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/IOperationRequest.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using HotChocolate.Language; + +namespace HotChocolate.Transport; + +public interface IOperationRequest : IRequestBody +{ + /// + /// Gets the ID of a previously persisted query that should be executed. + /// + string? Id { get; } + + /// + /// Gets the query string or document containing the operation to execute. + /// + string? Query { get; } + + /// + /// Gets the name of the operation to execute. + /// + string? OperationName { get; } + + /// + /// Gets a dictionary containing extension values to include with the operation. + /// + IReadOnlyDictionary? Extensions { get; } + + /// + /// Gets an representing the extension values to include with the + /// operation. + /// + ObjectValueNode? ExtensionsNode { get; } +} \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/IRequestBody.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/IRequestBody.cs new file mode 100644 index 00000000000..7a0ab9c5faf --- /dev/null +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/IRequestBody.cs @@ -0,0 +1,17 @@ +using System.Text.Json; + +namespace HotChocolate.Transport; + +/// +/// Represents a GraphQL request body that can be sent over a WebSocket connection or HTTP connection. +/// +public interface IRequestBody +{ + /// + /// Writes a serialized version of this request to a . + /// + /// + /// The JSON writer. + /// + void WriteTo(Utf8JsonWriter writer); +} \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationBatchRequest.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationBatchRequest.cs new file mode 100644 index 00000000000..92305062f1d --- /dev/null +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationBatchRequest.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using HotChocolate.Transport.Serialization; + +namespace HotChocolate.Transport; + +/// +/// Represents a GraphQL batch request that can be sent over a WebSocket or HTTP connection. +/// +/// +/// A list of operation requests to execute. +/// +public readonly struct OperationBatchRequest( + IReadOnlyList requests) + : IRequestBody + , IEquatable +{ + /// + /// Gets the list of operation requests to execute. + /// + public IReadOnlyList Requests { get; } = + requests ?? throw new ArgumentNullException(nameof(requests)); + + /// + /// Writes the request to the specified . + /// + /// + /// The writer to write the request to. + /// + /// + /// Thrown if the is . + /// + public void WriteTo(Utf8JsonWriter writer) + { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + Utf8JsonWriterHelper.WriteOperationRequest(writer, this); + } + + /// + /// Determines whether the specified + /// is equal to the current . + /// + /// + /// The to compare with the current . + /// + /// + /// if the specified + /// is equal to the current ; + /// otherwise, . + /// + public bool Equals(OperationBatchRequest other) + { + if(Requests.Count != other.Requests.Count) + { + return false; + } + + for (var i = 0; i < Requests.Count; i++) + { + if (!Requests[i].Equals(other.Requests[i])) + { + return false; + } + } + + return true; + } + + /// + /// Determines whether the specified + /// is equal to the current . + /// + /// + /// The to compare with the current . + /// + /// + /// if the specified is equal to the + /// current ; otherwise, . + /// + public override bool Equals(object? obj) + => obj is OperationBatchRequest other && Equals(other); + + /// + /// Gets the hash code for the current . + /// + /// + /// The hash code for the current . + /// + public override int GetHashCode() + { + var hash = new HashCode(); + foreach (var request in Requests) + { + hash.Add(request); + } + return hash.ToHashCode(); + } + + /// + /// Determines whether two specified objects are equal. + /// + /// + /// The first to compare. + /// + /// + /// The second to compare. + /// + /// + public static bool operator ==(OperationBatchRequest left, OperationBatchRequest right) + => left.Equals(right); + + /// + /// Determines whether two specified objects are not equal. + /// + /// + /// The first to compare. + /// + /// + /// The second to compare. + /// + /// + public static bool operator !=(OperationBatchRequest left, OperationBatchRequest right) + => !left.Equals(right); +} \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationRequest.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationRequest.cs index e5d78b49985..82b494fb811 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationRequest.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationRequest.cs @@ -7,9 +7,9 @@ namespace HotChocolate.Transport; /// -/// Represents a GraphQL operation request that can be sent over a WebSocket connection. +/// Represents a GraphQL operation request that can be sent over a WebSocket or HTTP connection. /// -public readonly struct OperationRequest : IEquatable +public readonly struct OperationRequest : IEquatable, IOperationRequest { /// /// Initializes a new instance of the struct. @@ -193,4 +193,4 @@ public override int GetHashCode() /// public static bool operator !=(OperationRequest left, OperationRequest right) => !left.Equals(right); -} +} \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationResult.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationResult.cs index 6902f802778..8564a152cb0 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationResult.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationResult.cs @@ -31,18 +31,38 @@ public sealed class OperationResult : IDisposable /// A object representing any extensions returned by the /// operation. /// + /// + /// The request index of this result. This is only set if the result is part of a batched operation. + /// + /// + /// The variable index of this result. This is only set if the result is part of a variable batch operation. + /// public OperationResult( IDisposable? memoryOwner = default, JsonElement data = default, JsonElement errors = default, - JsonElement extensions = default) + JsonElement extensions = default, + int? requestIndex = default, + int? variableIndex = default) { _memoryOwner = memoryOwner; Data = data; Errors = errors; Extensions = extensions; + RequestIndex = requestIndex; + VariableIndex = variableIndex; } + /// + /// Gets the request index of this result. This is only set if the result is part of a batched operation. + /// + public int? RequestIndex { get; } + + /// + /// Gets the variable index of this result. This is only set if the result is part of a variable batch operation. + /// + public int? VariableIndex { get; } + /// /// Gets the object representing the data returned by /// the operation. @@ -80,7 +100,9 @@ public static OperationResult Parse(JsonDocument document) document, root.TryGetProperty(DataProp, out var data) ? data : default, root.TryGetProperty(ErrorsProp, out var errors) ? errors : default, - root.TryGetProperty(ExtensionsProp, out var extensions) ? extensions : default); + root.TryGetProperty(ExtensionsProp, out var extensions) ? extensions : default, + root.TryGetProperty(RequestIndexProp, out var requestIndex) ? requestIndex.GetInt32() : null, + root.TryGetProperty(VariableIndexProp, out var variableIndex) ? variableIndex.GetInt32() : null); } public static OperationResult Parse(ReadOnlySpan span) @@ -99,7 +121,9 @@ public static OperationResult Parse(ReadOnlySpan span) null, root.TryGetProperty(DataProp, out var data) ? data : default, root.TryGetProperty(ErrorsProp, out var errors) ? errors : default, - root.TryGetProperty(ExtensionsProp, out var extensions) ? extensions : default); + root.TryGetProperty(ExtensionsProp, out var extensions) ? extensions : default, + root.TryGetProperty(RequestIndexProp, out var requestIndex) ? requestIndex.GetInt32() : null, + root.TryGetProperty(VariableIndexProp, out var variableIndex) ? variableIndex.GetInt32() : null); } } diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8GraphQLResultProperties.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8GraphQLResultProperties.cs index ea15d9be28b..3d2898bfd94 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8GraphQLResultProperties.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8GraphQLResultProperties.cs @@ -24,4 +24,14 @@ internal static class Utf8GraphQLResultProperties /// Gets the extensions property name. /// public static ReadOnlySpan ExtensionsProp => "extensions"u8; + + /// + /// Gets the request index property name. + /// + public static ReadOnlySpan RequestIndexProp => "requestIndex"u8; + + /// + /// Gets the variable index property name. + /// + public static ReadOnlySpan VariableIndexProp => "variableIndex"u8; } diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8JsonWriterHelper.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8JsonWriterHelper.cs index 58bb4af4104..641c3ce29d0 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8JsonWriterHelper.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8JsonWriterHelper.cs @@ -13,6 +13,31 @@ namespace HotChocolate.Transport.Serialization; /// internal static class Utf8JsonWriterHelper { + public static void WriteOperationRequest(Utf8JsonWriter writer, OperationBatchRequest batchRequest) + { + writer.WriteStartArray(); + + foreach (var request in batchRequest.Requests) + { + switch (request) + { + case OperationRequest operationRequest: + WriteOperationRequest(writer, operationRequest); + break; + + case VariableBatchRequest variableBatchRequest: + WriteOperationRequest(writer, variableBatchRequest); + break; + + default: + throw new NotSupportedException( + "The operation request type is not supported."); + } + } + + writer.WriteEndArray(); + } + public static void WriteOperationRequest(Utf8JsonWriter writer, OperationRequest request) { writer.WriteStartObject(); @@ -56,6 +81,50 @@ public static void WriteOperationRequest(Utf8JsonWriter writer, OperationRequest writer.WriteEndObject(); } + + public static void WriteOperationRequest(Utf8JsonWriter writer, VariableBatchRequest request) + { + writer.WriteStartObject(); + + if (request.Id is not null) + { + writer.WriteString(Utf8GraphQLRequestProperties.IdProp, request.Id); + } + + if (request.Query is not null) + { + writer.WriteString(Utf8GraphQLRequestProperties.QueryProp, request.Query); + } + + if (request.OperationName is not null) + { + writer.WriteString(Utf8GraphQLRequestProperties.OperationNameProp, request.OperationName); + } + + if (request.ExtensionsNode is not null) + { + writer.WritePropertyName(Utf8GraphQLRequestProperties.ExtensionsProp); + WriteFieldValue(writer, request.ExtensionsNode); + } + else if (request.Extensions is not null) + { + writer.WritePropertyName(Utf8GraphQLRequestProperties.ExtensionsProp); + WriteFieldValue(writer, request.Extensions); + } + + if (request.VariablesNode is not null) + { + writer.WritePropertyName(Utf8GraphQLRequestProperties.VariablesProp); + WriteFieldValue(writer, request.VariablesNode); + } + else if (request.Variables is not null) + { + writer.WritePropertyName(Utf8GraphQLRequestProperties.VariablesProp); + WriteFieldValue(writer, request.Variables); + } + + writer.WriteEndObject(); + } internal static void WriteFieldValue( Utf8JsonWriter writer, @@ -119,6 +188,10 @@ internal static void WriteFieldValue( case byte[] bytes: writer.WriteBase64StringValue(bytes); break; + + case IReadOnlyList> list: + WriteList(writer, list); + break; case IList list: WriteList(writer, list); @@ -204,6 +277,20 @@ private static void WriteDictionary( writer.WriteEndObject(); } + + private static void WriteList( + Utf8JsonWriter writer, + IReadOnlyList list) + { + writer.WriteStartArray(); + + for (var i = 0; i < list.Count; i++) + { + WriteFieldValue(writer, list[i]); + } + + writer.WriteEndArray(); + } private static void WriteList( Utf8JsonWriter writer, @@ -221,82 +308,88 @@ private static void WriteList( internal static IReadOnlyList WriteFilesMap( Utf8JsonWriter writer, - OperationRequest operationRequest, + IRequestBody requestBody, int? operation = null) { - if (operationRequest.VariablesNode is not null) + Dictionary? files = null; + CollectFiles(requestBody, ref files); + + if (files is null) { - Dictionary? files = null; - CollectFiles(operationRequest.VariablesNode, FilePath.Root, ref files); - - if (files is not null) - { - var fileInfos = new List(); - var index = 0; - - writer.WriteStartObject(); - - foreach (var item in files) - { - var name = index.ToString(); - fileInfos.Add(new FileReferenceInfo(item.Key, name)); + return Array.Empty(); + } + + var fileInfos = new List(); + var index = 0; - writer.WritePropertyName(name); - writer.WriteStartArray(); + writer.WriteStartObject(); - foreach (var path in item.Value) - { - writer.WriteStringValue(path.ToString(operation)); - } + foreach (var item in files) + { + var name = index.ToString(); + fileInfos.Add(new FileReferenceInfo(item.Key, name)); - writer.WriteEndArray(); + writer.WritePropertyName(name); + writer.WriteStartArray(); - index++; - } + foreach (var path in item.Value) + { + writer.WriteStringValue(path.ToString(operation)); + } - writer.WriteEndObject(); + writer.WriteEndArray(); - return fileInfos; - } + index++; } - if (operationRequest.Variables is not null) - { - Dictionary? files = null; - CollectFiles(operationRequest.Variables, FilePath.Root, ref files); - - if (files is not null) - { - var fileInfos = new List(); - var index = 0; + writer.WriteEndObject(); - writer.WriteStartObject(); + return fileInfos; + } - foreach (var item in files) + private static void CollectFiles(IRequestBody requestBody, ref Dictionary? files) + { + switch (requestBody) + { + case OperationRequest operationRequest: + if (operationRequest.Variables is not null) { - var name = index.ToString(); - fileInfos.Add(new FileReferenceInfo(item.Key, name)); + CollectFiles(operationRequest.Variables, FilePath.Root, ref files); + break; + } - writer.WritePropertyName(name); - writer.WriteStartArray(); + if (operationRequest.VariablesNode is not null) + { + CollectFiles(operationRequest.VariablesNode, FilePath.Root, ref files); + } + break; - foreach (var path in item.Value) + case VariableBatchRequest variableBatchRequest: + if (variableBatchRequest.Variables is not null) + { + foreach (var variableSet in variableBatchRequest.Variables) { - writer.WriteStringValue(path.ToString(operation)); + CollectFiles(variableSet, FilePath.Root, ref files); } - - writer.WriteEndArray(); - - index++; + break; } - writer.WriteEndObject(); + if (variableBatchRequest.VariablesNode is not null) + { + foreach (var variableSet in variableBatchRequest.VariablesNode) + { + CollectFiles(variableSet, FilePath.Root, ref files); + } + } + break; - return fileInfos; - } + case OperationBatchRequest batchRequest: + foreach (var request in batchRequest.Requests) + { + CollectFiles(request, ref files); + } + break; } - - return Array.Empty(); } private static void CollectFiles( @@ -428,14 +521,9 @@ private static void CollectFile( } } - private abstract class FilePath + private abstract class FilePath(FilePath? parent) { - protected FilePath(FilePath? parent) - { - Parent = parent; - } - - public FilePath? Parent { get; } + public FilePath? Parent { get; } = parent; public FilePath Append(string name) => new NameFilePath(this, name); diff --git a/src/HotChocolate/AspNetCore/src/Transport.Abstractions/VariableBatchRequest.cs b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/VariableBatchRequest.cs new file mode 100644 index 00000000000..94fb4a739ad --- /dev/null +++ b/src/HotChocolate/AspNetCore/src/Transport.Abstractions/VariableBatchRequest.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using HotChocolate.Language; +using HotChocolate.Transport.Serialization; + +namespace HotChocolate.Transport; + +/// +/// Represents a GraphQL operation request that can be sent over a WebSocket connection. +/// +public readonly struct VariableBatchRequest : IOperationRequest, IEquatable +{ + /// + /// Initializes a new instance of the struct. + /// + /// + /// The query document containing the operation to execute. + /// + /// + /// The ID of a previously persisted query that should be executed. + /// + /// + /// The name of the operation to execute. + /// + /// + /// A list of dictionaries representing the sets of variable values to use when executing the operation. + /// + /// + /// A dictionary containing extension values to include with the operation. + /// + /// + /// Thrown if the query, ID, and extensions parameters are all null. + /// + public VariableBatchRequest( + string? query, + string? id, + string? operationName, + IReadOnlyList? variables, + ObjectValueNode? extensions) + { + Query = query; + Id = id; + OperationName = operationName; + VariablesNode = variables; + ExtensionsNode = extensions; + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// The query string containing the operation to execute. + /// + /// + /// The ID of a previously persisted query that should be executed. + /// + /// + /// The name of the operation to execute. + /// + /// + /// A list of dictionaries representing the sets of variable values to use when executing the operation. + /// + /// + /// A dictionary containing extension values to include with the operation. + /// + /// + /// Thrown if the query, ID, and extensions parameters are all null. + /// + public VariableBatchRequest( + string? query = null, + string? id = null, + string? operationName = null, + IReadOnlyList>? variables = null, + IReadOnlyDictionary? extensions = null) + { + Query = query; + Id = id; + OperationName = operationName; + Variables = variables; + Extensions = extensions; + } + + /// + /// Empty Operation Request. + /// + public static OperationRequest Empty { get; } = new(); + + /// + /// Gets the ID of a previously persisted query that should be executed. + /// + public string? Id { get; } + + /// + /// Gets the query string or document containing the operation to execute. + /// + public string? Query { get; } + + /// + /// Gets the name of the operation to execute. + /// + public string? OperationName { get; } + + /// + /// Gets a list of dictionaries representing the sets of variable values to use when executing the operation. + /// + public IReadOnlyList>? Variables { get; } + + /// + /// Gets a list of representing the sets of variable values to + /// use when executing the operation. + /// + public IReadOnlyList? VariablesNode { get; } + + /// + /// Gets a dictionary containing extension values to include with the operation. + /// + public IReadOnlyDictionary? Extensions { get; } + + /// + /// Gets an representing the extension values to include with the + /// operation. + /// + public ObjectValueNode? ExtensionsNode { get; } + + /// + /// Writes a serialized version of this request to a . + /// + /// + /// The JSON writer. + /// + public void WriteTo(Utf8JsonWriter writer) + { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + Utf8JsonWriterHelper.WriteOperationRequest(writer, this); + } + + /// + /// Determines whether this object is equal to another object. + /// + /// + /// The object to compare with this object. + /// + /// + /// if the two objects are equal; otherwise, . + /// + public bool Equals(OperationRequest other) + => Id == other.Id && + Query == other.Query && + Equals(Variables, other.Variables) && + Equals(Extensions, other.Extensions) && + Equals(VariablesNode, other.VariablesNode) && + Equals(ExtensionsNode, other.ExtensionsNode); + + /// + public override bool Equals(object? obj) + => obj is OperationRequest other && Equals(other); + + /// + public override int GetHashCode() + => HashCode.Combine(Id, Query, Variables, Extensions, VariablesNode, ExtensionsNode); + + /// + /// Determines whether two objects are equal. + /// + /// + /// The first object to compare. + /// + /// + /// The second object to compare. + /// + /// + /// if the two objects are equal; otherwise, . + /// + public static bool operator ==(VariableBatchRequest left, VariableBatchRequest right) + => left.Equals(right); + + /// + /// Determines whether two objects are not equal. + /// + /// + /// The first object to compare. + /// + /// + /// The second object to compare. + /// + /// + /// if the two objects are not equal; otherwise, . + /// + public static bool operator !=(VariableBatchRequest left, VariableBatchRequest right) + => !left.Equals(right); +} \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/DefaultGraphQLHttpClient.cs b/src/HotChocolate/AspNetCore/src/Transport.Http/DefaultGraphQLHttpClient.cs index 98346b15a67..6b5985b67b3 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/DefaultGraphQLHttpClient.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/DefaultGraphQLHttpClient.cs @@ -120,6 +120,21 @@ private static HttpRequestMessage CreateRequestMessage( { var method = request.Method; + if(method == GraphQLHttpMethod.Get) + { + if (request.Body is not OperationRequest) + { + throw new InvalidOperationException( + HttpResources.DefaultGraphQLHttpClient_BatchNotAllowed); + } + + if (request.EnableFileUploads) + { + throw new NotSupportedException( + HttpResources.DefaultGraphQLHttpClient_FileUploadNotAllowed); + } + } + var message = new HttpRequestMessage { Method = method, @@ -150,7 +165,7 @@ private static HttpRequestMessage CreateRequestMessage( } else if (method == GraphQLHttpMethod.Get) { - message.RequestUri = CreateGetRequestUri(arrayWriter, requestUri, request.Operation); + message.RequestUri = CreateGetRequestUri(arrayWriter, requestUri, request.Body); } else { @@ -167,15 +182,14 @@ private static HttpContent CreatePostContent( GraphQLHttpRequest request) { using var jsonWriter = new Utf8JsonWriter(arrayWriter, JsonOptionDefaults.WriterOptions); - request.Operation.WriteTo(jsonWriter); + request.Body.WriteTo(jsonWriter); jsonWriter.Flush(); var content = new ByteArrayContent(arrayWriter.GetInternalBuffer(), 0, arrayWriter.Length); #if NET7_0_OR_GREATER content.Headers.ContentType = new MediaTypeHeaderValue(ContentType.Json, "utf-8"); #else - content.Headers.ContentType = - new MediaTypeHeaderValue(ContentType.Json) { CharSet = "utf-8", }; + content.Headers.ContentType = new MediaTypeHeaderValue(ContentType.Json) { CharSet = "utf-8", }; #endif return content; } @@ -228,7 +242,7 @@ private static HttpContent CreateMultipartContent( private static void WriteOperationJson(ArrayWriter arrayWriter, GraphQLHttpRequest request) { using var jsonWriter = new Utf8JsonWriter(arrayWriter, JsonOptionDefaults.WriterOptions); - request.Operation.WriteTo(jsonWriter); + request.Body.WriteTo(jsonWriter); } private static IReadOnlyList WriteFileMapJson( @@ -236,67 +250,71 @@ private static IReadOnlyList WriteFileMapJson( GraphQLHttpRequest request) { using var jsonWriter = new Utf8JsonWriter(arrayWriter, JsonOptionDefaults.WriterOptions); - return Utf8JsonWriterHelper.WriteFilesMap(jsonWriter, request.Operation); + return Utf8JsonWriterHelper.WriteFilesMap(jsonWriter, request.Body); } private static Uri CreateGetRequestUri( ArrayWriter arrayWriter, Uri baseAddress, - OperationRequest request) + IRequestBody body) { + if(body is not OperationRequest or) + { + throw new InvalidOperationException( + HttpResources.DefaultGraphQLHttpClient_BatchNotAllowed); + } + var sb = new StringBuilder(); var appendAmpersand = false; sb.Append(baseAddress); sb.Append('?'); - if (!string.IsNullOrWhiteSpace(request.Id)) + if (!string.IsNullOrWhiteSpace(or.Id)) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("id="); - sb.Append(Uri.EscapeDataString(request.Id!)); + sb.Append(Uri.EscapeDataString(or.Id!)); } - if (!string.IsNullOrWhiteSpace(request.Query)) + if (!string.IsNullOrWhiteSpace(or.Query)) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("query="); - sb.Append(Uri.EscapeDataString(request.Query!)); + sb.Append(Uri.EscapeDataString(or.Query!)); } - if (!string.IsNullOrWhiteSpace(request.OperationName)) + if (!string.IsNullOrWhiteSpace(or.OperationName)) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("operationName="); - sb.Append(Uri.EscapeDataString(request.OperationName!)); + sb.Append(Uri.EscapeDataString(or.OperationName!)); } - if (request.VariablesNode is not null) + if (or.VariablesNode is not null) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("variables="); - sb.Append( - Uri.EscapeDataString(FormatDocumentAsJson(arrayWriter, request.VariablesNode))); + sb.Append(Uri.EscapeDataString(FormatDocumentAsJson(arrayWriter, or.VariablesNode))); } - else if (request.Variables is not null) + else if (or.Variables is not null) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("variables="); - sb.Append(Uri.EscapeDataString(JsonSerializer.Serialize(request.Variables))); + sb.Append(Uri.EscapeDataString(JsonSerializer.Serialize(or.Variables))); } - if (request.ExtensionsNode is not null) + if (or.ExtensionsNode is not null) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("extensions="); - sb.Append( - Uri.EscapeDataString(FormatDocumentAsJson(arrayWriter, request.ExtensionsNode))); + sb.Append(Uri.EscapeDataString(FormatDocumentAsJson(arrayWriter, or.ExtensionsNode))); } - else if (request.Extensions is not null) + else if (or.Extensions is not null) { AppendAmpersand(sb, ref appendAmpersand); sb.Append("extensions="); - sb.Append(Uri.EscapeDataString(JsonSerializer.Serialize(request.Extensions))); + sb.Append(Uri.EscapeDataString(JsonSerializer.Serialize(or.Extensions))); } return new Uri(sb.ToString()); diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClient.cs b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClient.cs index c22a75679df..7a637a3c531 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClient.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClient.cs @@ -39,9 +39,7 @@ public void Dispose() /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - protected virtual void Dispose(bool disposing) - { - } + protected virtual void Dispose(bool disposing) { } /// /// Creates a new instance. diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClientExtensions.cs b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClientExtensions.cs index 227eb16b2d5..101506153a3 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClientExtensions.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClientExtensions.cs @@ -95,7 +95,7 @@ public static Task GetAsync( ? GetAsync(client, operation, cancellationToken) : GetAsync(client, operation, uri, cancellationToken); } - + /// /// Sends a GraphQL GET request to the specified GraphQL endpoint. /// @@ -129,7 +129,7 @@ public static Task GetAsync( ? GetAsync(client, operation, cancellationToken) : GetAsync(client, operation, uri, cancellationToken); } - + /// /// Sends a GraphQL GET request to the specified GraphQL endpoint. /// @@ -159,7 +159,7 @@ public static Task GetAsync( ? GetAsync(client, operation, cancellationToken) : GetAsync(client, operation, uri, cancellationToken); } - + /// /// Sends a GraphQL GET request to the specified GraphQL endpoint. /// @@ -214,12 +214,12 @@ public static Task GetAsync( { throw new ArgumentNullException(nameof(client)); } - + var request = new GraphQLHttpRequest(operation) { Method = GraphQLHttpMethod.Get, }; - + return client.SendAsync(request, cancellationToken); } @@ -256,12 +256,12 @@ public static Task GetAsync( { throw new ArgumentNullException(nameof(uri)); } - + var request = new GraphQLHttpRequest(operation, new Uri(uri)) { Method = GraphQLHttpMethod.Get, }; - + return client.SendAsync(request, cancellationToken); } @@ -298,12 +298,12 @@ public static Task GetAsync( { throw new ArgumentNullException(nameof(uri)); } - + var request = new GraphQLHttpRequest(operation, uri) { Method = GraphQLHttpMethod.Get, }; - + return client.SendAsync(request, cancellationToken); } @@ -418,7 +418,7 @@ public static Task PostAsync( ? PostAsync(client, operation, cancellationToken) : PostAsync(client, operation, uri, cancellationToken); } - + /// /// Sends a GraphQL POST request to the specified GraphQL endpoint. /// @@ -452,7 +452,7 @@ public static Task PostAsync( ? PostAsync(client, operation, cancellationToken) : PostAsync(client, operation, uri, cancellationToken); } - + /// /// Sends a GraphQL POST request to the specified GraphQL endpoint. /// @@ -511,11 +511,69 @@ public static Task PostAsync( { throw new ArgumentNullException(nameof(client)); } - + var request = new GraphQLHttpRequest(operation) { Method = GraphQLHttpMethod.Post, }; return client.SendAsync(request, cancellationToken); } + /// + /// Sends a GraphQL POST request to the specified GraphQL endpoint. + /// + /// + /// The to send the request with. + /// + /// + /// The GraphQL variable batch request. + /// + /// + /// A cancellation token to cancel the operation. + /// + /// + /// A representing the asynchronous operation. + /// + public static Task PostAsync( + this GraphQLHttpClient client, + VariableBatchRequest batch, + CancellationToken cancellationToken = default) + { + if (client == null) + { + throw new ArgumentNullException(nameof(client)); + } + + var request = new GraphQLHttpRequest(batch) { Method = GraphQLHttpMethod.Post, }; + return client.SendAsync(request, cancellationToken); + } + + /// + /// Sends a GraphQL POST request to the specified GraphQL endpoint. + /// + /// + /// The to send the request with. + /// + /// + /// The GraphQL operation batch request. + /// + /// + /// A cancellation token to cancel the operation. + /// + /// + /// A representing the asynchronous operation. + /// + public static Task PostAsync( + this GraphQLHttpClient client, + OperationBatchRequest batch, + CancellationToken cancellationToken = default) + { + if (client == null) + { + throw new ArgumentNullException(nameof(client)); + } + + var request = new GraphQLHttpRequest(batch) { Method = GraphQLHttpMethod.Post, }; + return client.SendAsync(request, cancellationToken); + } + /// /// Sends a GraphQL POST request to the specified GraphQL endpoint. /// @@ -549,12 +607,96 @@ public static Task PostAsync( { throw new ArgumentNullException(nameof(uri)); } - + var request = new GraphQLHttpRequest(operation, new Uri(uri)) { Method = GraphQLHttpMethod.Post, }; - + + return client.SendAsync(request, cancellationToken); + } + + /// + /// Sends a GraphQL POST request to the specified GraphQL endpoint. + /// + /// + /// The to send the request with. + /// + /// + /// The GraphQL variable batch request. + /// + /// + /// The GraphQL request URI. + /// + /// + /// A cancellation token to cancel the operation. + /// + /// + /// A representing the asynchronous operation. + /// + public static Task PostAsync( + this GraphQLHttpClient client, + VariableBatchRequest batch, + string uri, + CancellationToken cancellationToken = default) + { + if (client == null) + { + throw new ArgumentNullException(nameof(client)); + } + + if (uri == null) + { + throw new ArgumentNullException(nameof(uri)); + } + + var request = new GraphQLHttpRequest(batch, new Uri(uri)) + { + Method = GraphQLHttpMethod.Post, + }; + + return client.SendAsync(request, cancellationToken); + } + + /// + /// Sends a GraphQL POST request to the specified GraphQL endpoint. + /// + /// + /// The to send the request with. + /// + /// + /// The GraphQL operation batch request. + /// + /// + /// The GraphQL request URI. + /// + /// + /// A cancellation token to cancel the operation. + /// + /// + /// A representing the asynchronous operation. + /// + public static Task PostAsync( + this GraphQLHttpClient client, + OperationBatchRequest batch, + string uri, + CancellationToken cancellationToken = default) + { + if (client == null) + { + throw new ArgumentNullException(nameof(client)); + } + + if (uri == null) + { + throw new ArgumentNullException(nameof(uri)); + } + + var request = new GraphQLHttpRequest(batch, new Uri(uri)) + { + Method = GraphQLHttpMethod.Post, + }; + return client.SendAsync(request, cancellationToken); } @@ -591,12 +733,96 @@ public static Task PostAsync( { throw new ArgumentNullException(nameof(uri)); } - + var request = new GraphQLHttpRequest(operation, uri) { Method = GraphQLHttpMethod.Post, }; - + return client.SendAsync(request, cancellationToken); - } -} \ No newline at end of file + } + + /// + /// Sends a GraphQL POST request to the specified GraphQL endpoint. + /// + /// + /// The to send the request with. + /// + /// + /// The GraphQL variable batch request. + /// + /// + /// The GraphQL request URI. + /// + /// + /// A cancellation token to cancel the operation. + /// + /// + /// A representing the asynchronous operation. + /// + public static Task PostAsync( + this GraphQLHttpClient client, + VariableBatchRequest batch, + Uri uri, + CancellationToken cancellationToken = default) + { + if (client == null) + { + throw new ArgumentNullException(nameof(client)); + } + + if (uri == null) + { + throw new ArgumentNullException(nameof(uri)); + } + + var request = new GraphQLHttpRequest(batch, uri) + { + Method = GraphQLHttpMethod.Post, + }; + + return client.SendAsync(request, cancellationToken); + } + + /// + /// Sends a GraphQL POST request to the specified GraphQL endpoint. + /// + /// + /// The to send the request with. + /// + /// + /// The GraphQL operation batch request. + /// + /// + /// The GraphQL request URI. + /// + /// + /// A cancellation token to cancel the operation. + /// + /// + /// A representing the asynchronous operation. + /// + public static Task PostAsync( + this GraphQLHttpClient client, + OperationBatchRequest batch, + Uri uri, + CancellationToken cancellationToken = default) + { + if (client == null) + { + throw new ArgumentNullException(nameof(client)); + } + + if (uri == null) + { + throw new ArgumentNullException(nameof(uri)); + } + + var request = new GraphQLHttpRequest(batch, uri) + { + Method = GraphQLHttpMethod.Post, + }; + + return client.SendAsync(request, cancellationToken); + } +} diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpRequest.cs b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpRequest.cs index 84eef6ea8ec..9b73a67ed52 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpRequest.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpRequest.cs @@ -29,43 +29,110 @@ public GraphQLHttpRequest(string query, Uri? requestUri = null) nameof(query)); } - Operation = new OperationRequest(query); + Body = new OperationRequest(query); Uri = requestUri; } /// /// Initializes a new instance of . /// - /// + /// /// The GraphQL request operation. /// /// /// The GraphQL request URI. /// /// - /// has no , , + /// has no , , /// or . /// - public GraphQLHttpRequest(OperationRequest operation, Uri? requestUri = null) + public GraphQLHttpRequest(OperationRequest body, Uri? requestUri = null) { - if (string.IsNullOrEmpty(operation.Id) && - string.IsNullOrEmpty(operation.Query) && - operation.Extensions is null && - operation.ExtensionsNode is null) + if (string.IsNullOrEmpty(body.Id) && + string.IsNullOrEmpty(body.Query) && + body.Extensions is null && + body.ExtensionsNode is null) { throw new ArgumentException( HttpResources.GraphQLHttpRequest_QueryIdAndExtensionsNullOrEmpty, - nameof(operation)); + nameof(body)); } - Operation = operation; + Body = body; + Uri = requestUri; + } + + /// + /// Initializes a new instance of . + /// + /// + /// The GraphQL request operation. + /// + /// + /// The GraphQL request URI. + /// + /// + /// has no , , + /// or . + /// + public GraphQLHttpRequest(VariableBatchRequest body, Uri? requestUri = null) + { + if (string.IsNullOrEmpty(body.Id) && + string.IsNullOrEmpty(body.Query) && + body.Extensions is null && + body.ExtensionsNode is null) + { + throw new ArgumentException( + HttpResources.GraphQLHttpRequest_QueryIdAndExtensionsNullOrEmpty, + nameof(body)); + } + + Body = body; + Uri = requestUri; + } + + /// + /// Initializes a new instance of . + /// + /// + /// The GraphQL request operation. + /// + /// + /// The GraphQL request URI. + /// + /// + /// has no . + /// + public GraphQLHttpRequest(OperationBatchRequest body, Uri? requestUri = null) + { + if (body.Requests is { Count: 0, }) + { + throw new ArgumentException( + HttpResources.GraphQLHttpRequest_RequiresOneOrMoreRequests, + nameof(body)); + } + + foreach (var request in body.Requests) + { + if (string.IsNullOrEmpty(request.Id) && + string.IsNullOrEmpty(request.Query) && + request.Extensions is null && + request.ExtensionsNode is null) + { + throw new ArgumentException( + HttpResources.GraphQLHttpRequest_QueryIdAndExtensionsNullOrEmpty, + nameof(body)); + } + } + + Body = body.Requests.Count > 1 ? body : body.Requests[0]; Uri = requestUri; } /// - /// Gets the GraphQL operation. + /// Gets the request body. /// - public OperationRequest Operation { get; } + public IRequestBody Body { get; } /// /// Gets or sets the HTTP method. @@ -91,6 +158,10 @@ operation.Extensions is null && /// Specifies that the request URI represents a persisted document URI. /// public bool PersistedDocumentUri { get; set; } - - public static implicit operator GraphQLHttpRequest(OperationRequest method) => new(method); + + public static implicit operator GraphQLHttpRequest(OperationRequest body) => new(body); + + public static implicit operator GraphQLHttpRequest(VariableBatchRequest body) => new(body); + + public static implicit operator GraphQLHttpRequest(OperationBatchRequest body) => new(body); } \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpResponse.cs b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpResponse.cs index dc0747a6ff1..1de962a08d8 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpResponse.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpResponse.cs @@ -6,6 +6,7 @@ using System.IO; #endif using System.Net.Http; +using System.Net.Http.Headers; using System.Runtime.CompilerServices; #if NET6_0_OR_GREATER using System.Text; @@ -43,6 +44,16 @@ public GraphQLHttpResponse(HttpResponseMessage message) _message = message ?? throw new ArgumentNullException(nameof(message)); } + /// + /// Gets the underlying . + /// + public HttpResponseMessage HttpResponseMessage => _message; + + /// + /// Gets the HTTP response version. + /// + public Version Version => _message.Version; + /// /// Gets the HTTP response status code. /// @@ -57,12 +68,41 @@ public GraphQLHttpResponse(HttpResponseMessage message) /// Gets the reason phrase which typically is sent by servers together with the status code. /// public string? ReasonPhrase => _message.ReasonPhrase; - + /// /// Throws an exception if the HTTP response was unsuccessful. /// public void EnsureSuccessStatusCode() => _message.EnsureSuccessStatusCode(); + /// + /// Gets the collection of HTTP response headers. + /// + /// + /// The collection of HTTP response headers. + /// + public HttpResponseHeaders Headers => _message.Headers; + + /// + /// Gets the HTTP content headers as defined in RFC 2616. + /// + /// + /// The content headers as defined in RFC 2616. + /// + public HttpContentHeaders ContentHeaders => _message.Content.Headers; + + #if NET6_0_OR_GREATER + /// + /// Gets the collection of trailing headers included in an HTTP response. + /// + /// + /// PROTOCOL_ERROR: The HTTP/2 response contains pseudo-headers in the Trailing Headers Frame. + /// + /// + /// The collection of trailing headers in the HTTP response. + /// + public HttpResponseHeaders TrailingHeaders => _message.TrailingHeaders; + #endif + /// /// Reads the GraphQL response as a . /// diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.Designer.cs b/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.Designer.cs index 2902458b202..cabd7579b31 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.Designer.cs +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,46 +11,32 @@ namespace HotChocolate.Transport.Http { using System; - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class HttpResources { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal HttpResources() { } - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HotChocolate.Transport.Http.HttpResources", typeof(HttpResources).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("HotChocolate.Transport.Http.HttpResources", typeof(HttpResources).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,30 +45,39 @@ internal HttpResources() { } } - /// - /// Looks up a localized string similar to The request URI is not set and the underlying HTTP client has no base address.. - /// internal static string DefaultGraphQLHttpClient_SendAsync_RequestUriIsNull { get { return ResourceManager.GetString("DefaultGraphQLHttpClient_SendAsync_RequestUriIsNull", resourceCulture); } } - /// - /// Looks up a localized string similar to Query, ID, and extensions cannot all be null. At least one must be provided for a valid GraphQL request. - /// + internal static string GraphQLHttpRequest_QueryNullOrEmpty { + get { + return ResourceManager.GetString("GraphQLHttpRequest_QueryNullOrEmpty", resourceCulture); + } + } + internal static string GraphQLHttpRequest_QueryIdAndExtensionsNullOrEmpty { get { return ResourceManager.GetString("GraphQLHttpRequest_QueryIdAndExtensionsNullOrEmpty", resourceCulture); } } - /// - /// Looks up a localized string similar to The provided GraphQL query is null or empty.. - /// - internal static string GraphQLHttpRequest_QueryNullOrEmpty { + internal static string GraphQLHttpRequest_RequiresOneOrMoreRequests { get { - return ResourceManager.GetString("GraphQLHttpRequest_QueryNullOrEmpty", resourceCulture); + return ResourceManager.GetString("GraphQLHttpRequest_RequiresOneOrMoreRequests", resourceCulture); + } + } + + internal static string DefaultGraphQLHttpClient_BatchNotAllowed { + get { + return ResourceManager.GetString("DefaultGraphQLHttpClient_BatchNotAllowed", resourceCulture); + } + } + + internal static string DefaultGraphQLHttpClient_FileUploadNotAllowed { + get { + return ResourceManager.GetString("DefaultGraphQLHttpClient_FileUploadNotAllowed", resourceCulture); } } } diff --git a/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.resx b/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.resx index 0ea767cf9f2..43d9e39572d 100644 --- a/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.resx +++ b/src/HotChocolate/AspNetCore/src/Transport.Http/HttpResources.resx @@ -27,4 +27,13 @@ Query, ID, and extensions cannot all be null. At least one must be provided for a valid GraphQL request + + The batch request must contain at least one request. + + + The request body must be of type `OperationRequest` for HTTP GET requests. + + + File uploads are not supported for HTTP GET requests. + \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizationHandlerTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizationHandlerTests.cs index 2209406057f..24ed79f9501 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizationHandlerTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizationHandlerTests.cs @@ -23,11 +23,11 @@ public async Task Authorize(AuthorizeResult authResult) .AddTypeExtension() .AddAuthorizationHandler() .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ bar }") + OperationRequestBuilder + .Create() + .SetDocument("{ bar }") .AddGlobalState("auth", authResult) - .Create()); + .Build()); result.MatchSnapshot(authResult); } diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizeSchemaTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizeSchemaTests.cs index a426c32234a..2f2d6cf6efe 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizeSchemaTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizeSchemaTests.cs @@ -20,11 +20,11 @@ public async Task AuthorizeOnExtension() .AddTypeExtension() .AddAuthorization() .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ bar }") + OperationRequestBuilder + .Create() + .SetDocument("{ bar }") .SetUser(new ClaimsPrincipal()) - .Create()); + .Build()); result.MatchSnapshot(); } diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs index 8b64ad992aa..c5975a0b4d7 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs @@ -11,14 +11,9 @@ namespace HotChocolate.AspNetCore.Tests.Utilities; -public abstract class ServerTestBase : IClassFixture +public abstract class ServerTestBase(TestServerFactory serverFactory) : IClassFixture { - protected ServerTestBase(TestServerFactory serverFactory) - { - ServerFactory = serverFactory; - } - - protected TestServerFactory ServerFactory { get; } + protected TestServerFactory ServerFactory { get; } = serverFactory; protected virtual TestServer CreateStarWarsServer( string pattern = "/graphql", @@ -36,17 +31,11 @@ protected virtual TestServer CreateStarWarsServer( .AddStarWarsTypes() .AddTypeExtension() .AddTypeExtension() - .AddExportDirectiveType() .AddStarWarsRepositories() .AddInMemorySubscriptions() .UseAutomaticPersistedQueryPipeline() .ConfigureSchemaServices( - s => s - .AddSingleton() - .AddSingleton( - c => c.GetRequiredService()) - .AddSingleton( - c => c.GetRequiredService())) + s => s.AddSingleton()) .ModifyOptions( o => { @@ -132,7 +121,6 @@ protected virtual TestServer CreateServer( .AddStarWarsTypes() .AddTypeExtension() .AddTypeExtension() - .AddExportDirectiveType() .AddStarWarsRepositories() .ModifyOptions( o => diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/PersistedQueryCache.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/TestOperationDocumentStorage.cs similarity index 52% rename from src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/PersistedQueryCache.cs rename to src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/TestOperationDocumentStorage.cs index c827dd0bcba..32939d68ed9 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/PersistedQueryCache.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/TestOperationDocumentStorage.cs @@ -3,13 +3,11 @@ namespace HotChocolate.AspNetCore.Tests.Utilities; -public class PersistedQueryCache - : IReadStoredQueries - , IWriteStoredQueries +public sealed class TestOperationDocumentStorage : IOperationDocumentStorage { private readonly Dictionary _cache = new(); - public PersistedQueryCache() + public TestOperationDocumentStorage() { _cache.Add( "60ddx_GGk4FDObSa6eK0sg", @@ -20,24 +18,24 @@ public PersistedQueryCache() Utf8GraphQLParser.Parse(@"query($if: Boolean) { hero { name @skip(if: $if) } }")); } - public async Task TryReadQueryAsync( - string queryId, + public async ValueTask TryReadAsync( + OperationDocumentId documentId, CancellationToken cancellationToken = default) { - if (_cache.TryGetValue(queryId, out var document)) + if (_cache.TryGetValue(documentId.Value, out var document)) { - return await Task.FromResult(new QueryDocument(document)); + return await Task.FromResult(new OperationDocument(document)); } return null; } - public Task WriteQueryAsync( - string queryId, - IQuery query, + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, CancellationToken cancellationToken = default) { - _cache[queryId] = Utf8GraphQLParser.Parse(query.AsSpan()); - return Task.CompletedTask; + _cache[documentId.Value] = Utf8GraphQLParser.Parse(document.AsSpan()); + return default; } } diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/GraphQLOverHttpSpecTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/GraphQLOverHttpSpecTests.cs index 941538841eb..cc80ca59b12 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/GraphQLOverHttpSpecTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/GraphQLOverHttpSpecTests.cs @@ -3,6 +3,8 @@ using CookieCrumble; using HotChocolate.AspNetCore.Serialization; using HotChocolate.AspNetCore.Tests.Utilities; +using HotChocolate.Transport; +using HotChocolate.Transport.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; using static System.Net.Http.HttpCompletionOption; @@ -11,13 +13,10 @@ namespace HotChocolate.AspNetCore; -public class GraphQLOverHttpSpecTests : ServerTestBase +public class GraphQLOverHttpSpecTests(TestServerFactory serverFactory) : ServerTestBase(serverFactory) { private static readonly Uri _url = new("http://localhost:5000/graphql"); - public GraphQLOverHttpSpecTests(TestServerFactory serverFactory) - : base(serverFactory) { } - [Theory] [InlineData(null, Latest, ContentType.GraphQLResponse)] [InlineData(null, Legacy, ContentType.Json)] @@ -466,12 +465,13 @@ public async Task EventStream_Sends_KeepAlive() client.Timeout = TimeSpan.FromSeconds(30); // act - using var request = new HttpRequestMessage(HttpMethod.Post, _url) - { - Content = JsonContent.Create( - new ClientQueryRequest { Query = "subscription {delay(count: 2, delay:15000)}", }), - Headers = { { "Accept", "text/event-stream" }, }, - }; + using var request = new HttpRequestMessage(HttpMethod.Post, _url); + request.Content = JsonContent.Create( + new ClientQueryRequest + { + Query = "subscription {delay(count: 2, delay:15000)}", + }); + request.Headers.Add("Accept", "text/event-stream"); using var response = await client.SendAsync(request, ResponseHeadersRead); @@ -502,6 +502,95 @@ public async Task EventStream_Sends_KeepAlive() """); } + [Fact] + public async Task OperationBatch() + { + // arrange + var server = CreateStarWarsServer(); + var client = new DefaultGraphQLHttpClient(server.CreateClient()); + var snapshot = new Snapshot(); + + // act + var request = new GraphQLHttpRequest( + new OperationBatchRequest( + [ + new OperationRequest( + """ + { + hero(episode: NEW_HOPE) { + name + } + } + """), + new OperationRequest( + """ + { + hero(episode: EMPIRE) { + name + } + } + """), + ]), + new Uri("http://localhost:5000/graphql")); + + using var response = await client.SendAsync(request); + + // assert + Assert.Equal(response.StatusCode, OK); + + var sortedResults = new SortedList<(int?, int?), OperationResult>(); + + await foreach (var result in response.ReadAsResultStreamAsync()) + { + sortedResults.Add((result.RequestIndex, result.VariableIndex), result); + } + + foreach (var result in sortedResults.Values) + { + snapshot.Add(result); + } + + await snapshot.MatchMarkdownAsync(); + } + + [Fact] + public async Task VariableBatch() + { + // arrange + var server = CreateStarWarsServer(); + var client = new DefaultGraphQLHttpClient(server.CreateClient()); + var snapshot = new Snapshot(); + + // act + var request = new GraphQLHttpRequest( + new VariableBatchRequest( + """ + query($episode: Episode!) { + hero(episode: $episode) { + name + } + } + """, + variables: + [ + new Dictionary { { "episode", "NEW_HOPE" }, }, + new Dictionary { { "episode", "EMPIRE" }, }, + ]), + new Uri("http://localhost:5000/graphql")); + + using var response = await client.SendAsync(request); + + // assert + Assert.Equal(response.StatusCode, OK); + + await foreach (var result in response.ReadAsResultStreamAsync()) + { + snapshot.Add(result); + } + + await snapshot.MatchMarkdownAsync(); + } + private HttpClient GetClient(HttpTransportVersion serverTransportVersion) { var server = CreateStarWarsServer( diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HotChocolate.AspNetCore.Tests.csproj b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HotChocolate.AspNetCore.Tests.csproj index f69423e5b56..44feab59d34 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HotChocolate.AspNetCore.Tests.csproj +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HotChocolate.AspNetCore.Tests.csproj @@ -9,6 +9,7 @@ + diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetMiddlewareTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetMiddlewareTests.cs index 2f43988cc8c..caf27114fd3 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetMiddlewareTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetMiddlewareTests.cs @@ -667,7 +667,7 @@ public async Task Get_ActivePersistedQuery() // assert result.MatchSnapshot(); } - + [Fact] public async Task Get_ActivePersistedQuery_Invalid_Id_Format() { @@ -761,7 +761,7 @@ public async Task Throw_Custom_GraphQL_Error() await server.GetAsync( new ClientQueryRequest { - Query = + Query = """ { hero { @@ -780,10 +780,10 @@ private class ErrorRequestInterceptor : DefaultHttpRequestInterceptor public override ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { throw new GraphQLException("MyCustomError"); } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpPostMiddlewareTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpPostMiddlewareTests.cs index 985e981b8d4..887d63f5351 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpPostMiddlewareTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpPostMiddlewareTests.cs @@ -190,35 +190,6 @@ await server.PostAsync( result.MatchSnapshot(); } - [Fact] - public async Task Complexity_Exceeded() - { - // arrange - var server = CreateStarWarsServer( - configureServices: c => c.AddGraphQLServer().ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1; - })); - - // act - var result = - await server.PostAsync( - new ClientQueryRequest - { - Query = @" - { - HERO: hero { - name - } - }", - }); - - // assert - result.MatchSnapshot(); - } - [Fact] public async Task SingleRequest_GetHeroName_With_EnumVariable() { @@ -280,7 +251,7 @@ await server.PostHttpAsync( private class CustomFormatter : DefaultHttpResponseFormatter { protected override void OnWriteResponseHeaders( - IQueryResult result, + IOperationResult result, FormatInfo format, IHeaderDictionary headers) { @@ -416,33 +387,6 @@ ... on Droid @defer(label: ""my_id"") Assert.True(listenerB.Triggered); } - [Fact] - public async Task Apollo_Tracing_Invalid_Field() - { - // arrange - var server = CreateStarWarsServer( - configureServices: s => s - .AddGraphQLServer() - .AddApolloTracing()); - - // act - var response = await server.PostRawAsync( - new ClientQueryRequest - { - Query = - @"{ - hero123(episode: NEW_HOPE) - { - name - } - }", - }, - enableApolloTracing: true); - - // assert - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - } - [Fact] public async Task Ensure_Multipart_Format_Is_Correct_With_Defer() { @@ -1016,286 +960,6 @@ public async Task Ensure_Middleware_Mapping() result.MatchSnapshot(); } - [Fact] - public async Task BatchRequest_GetHero_And_GetHuman() - { - // arrange - var server = CreateStarWarsServer(); - - // act - var result = - await server.PostAsync( - new List - { - new ClientQueryRequest - { - Query = @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - }", - }, - new ClientQueryRequest - { - Query = @" - query getHuman { - human(id: $id) { - name - } - }", - }, - }); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task BatchRequest_GetHero_And_GetHuman_MultiPart() - { - // arrange - var server = CreateStarWarsServer( - configureServices: sp => sp.AddHttpResponseFormatter()); - - // act - var response = - await server.SendPostRequestAsync( - JsonConvert.SerializeObject( - new List - { - new ClientQueryRequest - { - Query = @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - }", - }, - new ClientQueryRequest - { - Query = @" - query getHuman { - human(id: $id) { - name - } - }", - }, - }), - "/graphql"); - - if (response.StatusCode == HttpStatusCode.NotFound) - { - throw new Exception("GraphQL endpoint not found."); - } - - var result = await response.Content.ReadAsStringAsync(); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task OperationBatchRequest_GetHero_And_GetHuman() - { - // arrange - var server = CreateStarWarsServer(); - - // act - var result = - await server.PostOperationAsync( - new ClientQueryRequest - { - Query = - @"query getHero { - hero(episode: EMPIRE) { - id @export - } - } - - query getHuman { - human(id: $id) { - name - } - }", - }, - "getHero, getHuman"); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task BatchRequest_GetHero_And_GetHuman_MultiPart_Batching_Disabled() - { - // arrange - var server = CreateStarWarsServer( - configureServices: sp => sp.AddHttpResponseFormatter()); - - // act - var response = - await server.SendPostRequestAsync( - JsonConvert.SerializeObject( - new List - { - new ClientQueryRequest - { - Query = @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - }", - }, - new ClientQueryRequest - { - Query = @" - query getHuman { - human(id: $id) { - name - } - }", - }, - }), - path: "/batching"); - - if (response.StatusCode == HttpStatusCode.NotFound) - { - throw new Exception("GraphQL endpoint not found."); - } - - var result = await response.Content.ReadAsStringAsync(); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task OperationBatchRequest_GetHero_And_GetHuman_Batching_Disabled() - { - // arrange - var server = CreateStarWarsServer(); - - // act - var result = - await server.PostOperationAsync( - new ClientQueryRequest - { - Query = - @"query getHero { - hero(episode: EMPIRE) { - id @export - } - } - - query getHuman { - human(id: $id) { - name - } - }", - }, - "getHero, getHuman", - path: "/batching"); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task OperationBatchRequest_Invalid_BatchingParameter_1() - { - // arrange - var server = CreateStarWarsServer(); - - // act - var result = - await server.PostOperationAsync( - new ClientQueryRequest - { - Query = - @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - } - - query getHuman { - human(id: $id) { - name - } - }", - }, - "getHero", - createOperationParameter: s => "batchOperations=" + s); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task OperationBatchRequest_Invalid_BatchingParameter_2() - { - // arrange - var server = CreateStarWarsServer(); - - // act - var result = - await server.PostOperationAsync( - new ClientQueryRequest - { - Query = @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - } - - query getHuman { - human(id: $id) { - name - } - }", - }, - "getHero, getHuman", - createOperationParameter: s => "batchOperations=[" + s); - - // assert - result.MatchSnapshot(); - } - - [Fact] - public async Task OperationBatchRequest_Invalid_BatchingParameter_3() - { - // arrange - var server = CreateStarWarsServer(); - - // act - var result = - await server.PostOperationAsync( - new ClientQueryRequest - { - Query = @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - } - - query getHuman { - human(id: $id) { - name - } - }", - }, - "getHero, getHuman", - createOperationParameter: s => "batchOperations=" + s); - - // assert - result.MatchSnapshot(); - } - [Fact] public async Task Throw_Custom_GraphQL_Error() { @@ -1438,7 +1102,7 @@ public class ErrorRequestInterceptor : DefaultHttpRequestInterceptor public override ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { throw new GraphQLException("MyCustomError"); diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/PersistedQueryTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/PersistedQueryTests.cs index 2b7f9524043..d4b6f1521b1 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/PersistedQueryTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/PersistedQueryTests.cs @@ -25,7 +25,7 @@ public async Task HotChocolateStyle_MD5Hash_Success() var server = CreateStarWarsServer( configureServices: s => s .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -51,7 +51,7 @@ public async Task HotChocolateStyle_MD5Hash_NotFound() var server = CreateStarWarsServer( configureServices: s => s .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -79,7 +79,7 @@ public async Task HotChocolateStyle_Sha1Hash_Success() configureServices: s => s .AddSha1DocumentHashProvider(HashFormat.Hex) .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -106,7 +106,7 @@ public async Task HotChocolateStyle_Sha256Hash_Success() configureServices: s => s .AddSha256DocumentHashProvider(HashFormat.Hex) .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -132,7 +132,7 @@ public async Task ApolloStyle_MD5Hash_Success() var server = CreateStarWarsServer( configureServices: s => s .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -158,7 +158,7 @@ public async Task ApolloStyle_MD5Hash_NotFound() var server = CreateStarWarsServer( configureServices: s => s .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -186,7 +186,7 @@ public async Task ApolloStyle_Sha1Hash_Success() configureServices: s => s .AddSha1DocumentHashProvider(HashFormat.Hex) .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -213,7 +213,7 @@ public async Task ApolloStyle_Sha256Hash_Success() configureServices: s => s .AddSha256DocumentHashProvider(HashFormat.Hex) .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -238,7 +238,7 @@ public async Task Standard_Query_By_Default_Works() var server = CreateStarWarsServer( configureServices: s => s .AddGraphQL("StarWars") - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -262,7 +262,7 @@ public async Task Standard_Query_Not_Allowed() configureServices: s => s .AddGraphQL("StarWars") .ModifyRequestOptions(o => o.OnlyAllowPersistedQueries = true) - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -293,7 +293,7 @@ public async Task Standard_Query_Not_Allowed_Custom_Error() .SetMessage("Not allowed!") .Build(); }) - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline()); var query = "{ __typename }"; @@ -320,7 +320,7 @@ public async Task Standard_Query_Not_Allowed_Override_Per_Request() { o.OnlyAllowPersistedQueries = true; }) - .ConfigureSchemaServices(c => c.AddSingleton(storage)) + .ConfigureSchemaServices(c => c.AddSingleton(storage)) .UsePersistedQueryPipeline() .AddHttpRequestInterceptor()); @@ -348,22 +348,28 @@ private ClientQueryRequest CreateApolloStyleRequest(string hashName, string key) }, }; - private sealed class QueryStorage : IReadStoredQueries + private sealed class QueryStorage : IOperationDocumentStorage { - private readonly Dictionary> _cache = + private readonly Dictionary _cache = new(StringComparer.Ordinal); - public Task TryReadQueryAsync( - string queryId, + public ValueTask TryReadAsync( + OperationDocumentId documentId, CancellationToken cancellationToken = default) - => _cache.TryGetValue(queryId, out var value) - ? value - : Task.FromResult(null); + => _cache.TryGetValue(documentId.Value, out var value) + ? new ValueTask(value) + : new ValueTask(default(IOperationDocument)); + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + public void AddQuery(string key, string query) { - var doc = new QueryDocument(Utf8GraphQLParser.Parse(query)); - _cache.Add(key, Task.FromResult(doc)); + var doc = new OperationDocument(Utf8GraphQLParser.Parse(query)); + _cache.Add(key, doc); } } @@ -372,7 +378,7 @@ private sealed class AllowPersistedQueryInterceptor : DefaultHttpRequestIntercep public override ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { requestBuilder.AllowNonPersistedQuery(); diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Subscriptions/OperationManagerTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Subscriptions/OperationManagerTests.cs index cd633fcdcdc..ca999527f88 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Subscriptions/OperationManagerTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Subscriptions/OperationManagerTests.cs @@ -380,7 +380,7 @@ public ValueTask SendKeepAliveMessageAsync( public ValueTask SendResultMessageAsync( ISocketSession session, string operationSessionId, - IQueryResult result, + IOperationResult result, CancellationToken cancellationToken) => default; diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.OperationBatch.md b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.OperationBatch.md new file mode 100644 index 00000000000..4afdf98f586 --- /dev/null +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.OperationBatch.md @@ -0,0 +1,16 @@ +# OperationBatch + +## Result 1 + +```text +RequestIndex: 0 +Data: {"hero":{"name":"R2-D2"}} +``` + +## Result 2 + +```text +RequestIndex: 1 +Data: {"hero":{"name":"Luke Skywalker"}} +``` + diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.VariableBatch.md b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.VariableBatch.md new file mode 100644 index 00000000000..ce8e7875458 --- /dev/null +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/GraphQLOverHttpSpecTests.VariableBatch.md @@ -0,0 +1,16 @@ +# VariableBatch + +## Result 1 + +```text +VariableIndex: 0 +Data: {"hero":{"name":"R2-D2"}} +``` + +## Result 2 + +```text +VariableIndex: 1 +Data: {"hero":{"name":"Luke Skywalker"}} +``` + diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL.snap b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL.snap index 14274e4d0aa..f9929d65bf5 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL.snap +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL.snap @@ -121,8 +121,6 @@ enum Unit { "The `@defer` directive may be provided for fragment spreads and inline fragments to inform the executor to delay the execution of the current fragment to indicate deprioritization of the current fragment. A query with `@defer` directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred is delivered in a subsequent response. `@include` and `@skip` take precedence over `@defer`." directive @defer("If this argument label has a value other than null, it will be passed on to the result of this defer directive. This label is intended to give client applications a way to identify to which fragment a deferred result belongs to." label: String "Deferred when true." if: Boolean) on FRAGMENT_SPREAD | INLINE_FRAGMENT -directive @export(as: String) on FIELD - "The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such as asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take precedence over `@stream`." directive @stream("If this argument label has a value other than null, it will be passed on to the result of this stream directive. This label is intended to give client applications a way to identify to which fragment a streamed result belongs to." label: String "The initial elements that shall be send down to the consumer." initialCount: Int! = 0 "Streamed when true." if: Boolean) on FIELD diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route.snap b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route.snap index 14274e4d0aa..f9929d65bf5 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route.snap +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route.snap @@ -121,8 +121,6 @@ enum Unit { "The `@defer` directive may be provided for fragment spreads and inline fragments to inform the executor to delay the execution of the current fragment to indicate deprioritization of the current fragment. A query with `@defer` directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred is delivered in a subsequent response. `@include` and `@skip` take precedence over `@defer`." directive @defer("If this argument label has a value other than null, it will be passed on to the result of this defer directive. This label is intended to give client applications a way to identify to which fragment a deferred result belongs to." label: String "Deferred when true." if: Boolean) on FRAGMENT_SPREAD | INLINE_FRAGMENT -directive @export(as: String) on FIELD - "The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such as asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take precedence over `@stream`." directive @stream("If this argument label has a value other than null, it will be passed on to the result of this stream directive. This label is intended to give client applications a way to identify to which fragment a streamed result belongs to." label: String "The initial elements that shall be send down to the consumer." initialCount: Int! = 0 "Streamed when true." if: Boolean) on FIELD diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route_Explicit_Pattern.snap b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route_Explicit_Pattern.snap index 14274e4d0aa..f9929d65bf5 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route_Explicit_Pattern.snap +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_SDL_Explicit_Route_Explicit_Pattern.snap @@ -121,8 +121,6 @@ enum Unit { "The `@defer` directive may be provided for fragment spreads and inline fragments to inform the executor to delay the execution of the current fragment to indicate deprioritization of the current fragment. A query with `@defer` directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred is delivered in a subsequent response. `@include` and `@skip` take precedence over `@defer`." directive @defer("If this argument label has a value other than null, it will be passed on to the result of this defer directive. This label is intended to give client applications a way to identify to which fragment a deferred result belongs to." label: String "Deferred when true." if: Boolean) on FRAGMENT_SPREAD | INLINE_FRAGMENT -directive @export(as: String) on FIELD - "The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such as asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take precedence over `@stream`." directive @stream("If this argument label has a value other than null, it will be passed on to the result of this stream directive. This label is intended to give client applications a way to identify to which fragment a streamed result belongs to." label: String "The initial elements that shall be send down to the consumer." initialCount: Int! = 0 "Streamed when true." if: Boolean) on FIELD diff --git a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs index a12cd23f40a..9428add03ee 100644 --- a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs +++ b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs @@ -25,9 +25,11 @@ public async Task DefaultRequestVersion() await client.SendAsync(new("{ __typename }", new(CreateUrl(default))), default); } - class TestHttpMessageHandler(Func sender) : HttpMessageHandler + internal class TestHttpMessageHandler(Func sender) : HttpMessageHandler { - protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + protected override Task SendAsync( + HttpRequestMessage request, + CancellationToken cancellationToken) { return Task.FromResult(sender.Invoke(request)); } diff --git a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientTests.cs b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientTests.cs index 0a2a46be665..7d601356b29 100644 --- a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientTests.cs +++ b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientTests.cs @@ -37,8 +37,7 @@ public async Task Post_GraphQL_Query_With_RequestUri() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -68,8 +67,7 @@ public async Task Post_GraphQL_Query_With_RequestUriString() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -100,8 +98,7 @@ public async Task Post_GraphQL_Query_With_BaseAddress() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -137,8 +134,7 @@ public async Task Post_GraphQL_Query_With_Variables_With_RequestUri() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -174,8 +170,7 @@ public async Task Post_GraphQL_Query_With_Variables_With_RequestUriString() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -211,8 +206,7 @@ public async Task Post_GraphQL_Query_With_JsonElement_Variable() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"heroByTraits":{"name":"Luke Skywalker"}} + Data: {"heroByTraits":{"name":"Luke Skywalker"}} """); } @@ -247,8 +241,7 @@ public async Task Post_GraphQL_Query_With_Variables_With_BaseAddress() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -290,8 +283,7 @@ query B($episode: Episode!) { using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"B":"R2-D2"}} + Data: {"hero":{"B":"R2-D2"}} """); } @@ -321,8 +313,7 @@ public async Task Get_GraphQL_Query_With_RequestUri() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -352,8 +343,7 @@ public async Task Get_GraphQL_Query_With_RequestUriString() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -384,8 +374,7 @@ public async Task Get_GraphQL_Query_With_BaseAddress() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -421,8 +410,7 @@ public async Task Get_GraphQL_Query_With_Variables_With_RequestUri() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -458,8 +446,7 @@ public async Task Get_GraphQL_Query_With_Variables_With_RequestUriString() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -494,8 +481,7 @@ public async Task Get_GraphQL_Query_With_Variables_With_BaseAddress() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"name":"R2-D2"}} + Data: {"hero":{"name":"R2-D2"}} """); } @@ -537,8 +523,7 @@ query B($episode: Episode!) { using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"hero":{"B":"R2-D2"}} + Data: {"hero":{"B":"R2-D2"}} """); } @@ -593,8 +578,7 @@ mutation CreateReviewForEpisode( { result.MatchInlineSnapshot( """ - Data: - {"onReview":{"stars":5}} + Data: {"onReview":{"stars":5}} """); cts.Cancel(); } @@ -651,8 +635,7 @@ mutation CreateReviewForEpisode( { result.MatchInlineSnapshot( """ - Data: - {"onReview":{"stars":5}} + Data: {"onReview":{"stars":5}} """); cts.Cancel(); } @@ -695,8 +678,7 @@ public async Task Post_GraphQL_FileUpload() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"singleUpload":"abc"} + Data: {"singleUpload":"abc"} """); } @@ -740,8 +722,7 @@ public async Task Post_GraphQL_FileUpload_With_ObjectValueNode() using var body = await response.ReadAsResultAsync(cts.Token); body.MatchInlineSnapshot( """ - Data: - {"singleUpload":"abc"} + Data: {"singleUpload":"abc"} """); } } diff --git a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/OperationRequestTests.cs b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/OperationRequestTests.cs index 4476ec14ab1..3ce8de318fd 100644 --- a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/OperationRequestTests.cs +++ b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/OperationRequestTests.cs @@ -32,4 +32,4 @@ public async Task Should_WriteNullValues() """{"id":"abc","operationName":"myOperation","variables":{"abc":"def","hij":null}}""", result); } -} +} \ No newline at end of file diff --git a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/VariableBatchRequestTests.cs b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/VariableBatchRequestTests.cs new file mode 100644 index 00000000000..4562a0cc1aa --- /dev/null +++ b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/VariableBatchRequestTests.cs @@ -0,0 +1,299 @@ +using System.Text; +using System.Text.Json; +using CookieCrumble; +using HotChocolate.AspNetCore.Tests.Utilities; +using static HotChocolate.AspNetCore.Tests.Utilities.TestServerExtensions; + +namespace HotChocolate.Transport.Http; + +public class VariableBatchRequestTestss(TestServerFactory serverFactory) : ServerTestBase(serverFactory) +{ + [Fact] + public async Task Should_WriteNullValues() + { + // arrange + var request = new VariableBatchRequest( + null, + "abc", + "myOperation", + variables: + [ + new Dictionary + { + ["abc"] = "def", + ["hij"] = null, + }, + new Dictionary + { + ["abc"] = "xyz", + ["hij"] = null, + }, + ]); + + using var memory = new MemoryStream(); + await using var writer = new Utf8JsonWriter(memory); + + // act + request.WriteTo(writer); + await writer.FlushAsync(); + + // assert + var result = JsonDocument.Parse(Encoding.UTF8.GetString(memory.ToArray())).RootElement; + result.MatchInlineSnapshot( + """ + { + "id": "abc", + "operationName": "myOperation", + "variables": [ + { + "abc": "def", + "hij": null + }, + { + "abc": "xyz", + "hij": null + } + ] + } + """); + } + + [Fact] + public async Task Post_Variable_Batch() + { + // arrange + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + using var testServer = CreateStarWarsServer(); + var httpClient = testServer.CreateClient(); + var client = new DefaultGraphQLHttpClient(httpClient); + + var query = + """ + query($episode: Episode!) { + hero(episode: $episode) { + name + } + } + """; + + var variables1 = new Dictionary + { + ["episode"] = "JEDI", + }; + + var variables2 = new Dictionary + { + ["episode"] = "EMPIRE", + }; + + var requestUri = new Uri(CreateUrl("/graphql")); + + // act + var request = new VariableBatchRequest( + query, + variables: new[] { variables1, variables2 }); + + var response = await client.PostAsync(request, requestUri, cts.Token); + + // assert + var snapshot = new Snapshot(); + + await foreach(var result in response.ReadAsResultStreamAsync(cts.Token)) + { + snapshot.Add(result); + } + + snapshot.MatchInline( + """ + --------------- + VariableIndex: 0 + Data: {"hero":{"name":"R2-D2"}} + --------------- + + --------------- + VariableIndex: 1 + Data: {"hero":{"name":"Luke Skywalker"}} + --------------- + + """); + } + + [Fact] + public async Task Post_Request_With_Nested_Variable_Batch() + { + // arrange + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1000)); + using var testServer = CreateStarWarsServer(); + var httpClient = testServer.CreateClient(); + var client = new DefaultGraphQLHttpClient(httpClient); + + var query = + """ + query($episode: Episode!) { + hero(episode: $episode) { + name + } + } + """; + + var variables1 = new Dictionary + { + ["episode"] = "JEDI", + }; + + var variables2 = new Dictionary + { + ["episode"] = "EMPIRE", + }; + + var requestUri = new Uri(CreateUrl("/graphql")); + + // act + var nestedVariableBatchRequest = new VariableBatchRequest( + query, + variables: new[] { variables1, variables2 }); + + var nestedSingleRequest = new OperationRequest( + """ + { + __typename + } + """); + + var batch = new OperationBatchRequest([nestedVariableBatchRequest, nestedSingleRequest]); + + var response = await client.PostAsync(batch, requestUri, cts.Token); + + // assert + response.EnsureSuccessStatusCode(); + + var sortedResults = new SortedList<(int?, int?), OperationResult>(); + + await foreach(var result in response.ReadAsResultStreamAsync(cts.Token)) + { + sortedResults.Add((result.RequestIndex, result.VariableIndex), result); + } + + var snapshot = new Snapshot(); + + foreach (var item in sortedResults.Values) + { + snapshot.Add(item); + } + + snapshot.MatchInline( + """ + --------------- + RequestIndex: 0 + VariableIndex: 0 + Data: {"hero":{"name":"R2-D2"}} + --------------- + + --------------- + RequestIndex: 0 + VariableIndex: 1 + Data: {"hero":{"name":"Luke Skywalker"}} + --------------- + + --------------- + RequestIndex: 1 + Data: {"__typename":"Query"} + --------------- + + """); + } + + [Fact] + public async Task Post_Request_Batch() + { + // arrange + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1000)); + using var testServer = CreateStarWarsServer(); + var httpClient = testServer.CreateClient(); + var client = new DefaultGraphQLHttpClient(httpClient); + + var query = + """ + query($episode: Episode!) { + hero(episode: $episode) { + name + } + } + """; + + var variables1 = new Dictionary + { + ["episode"] = "JEDI", + }; + + var variables2 = new Dictionary + { + ["episode"] = "EMPIRE", + }; + + var requestUri = new Uri(CreateUrl("/graphql")); + + // act + var request1 = new OperationRequest( + query, + variables: variables1); + + var request2 = new OperationRequest( + query, + variables: variables2); + + var request3 = new OperationRequest( + """ + { + __typename + } + """); + + var batch = new OperationBatchRequest([request1, request2, request3]); + + var response = await client.PostAsync(batch, requestUri, cts.Token); + + // assert + response.EnsureSuccessStatusCode(); + + var sortedResults = new SortedList<(int?, int?), OperationResult>(); + + await foreach(var result in response.ReadAsResultStreamAsync(cts.Token)) + { + sortedResults.Add((result.RequestIndex, result.VariableIndex), result); + } + + var snapshot = new Snapshot(); + + snapshot.Add(response.ContentHeaders.ContentType?.ToString(), "ContentType"); + + foreach (var item in sortedResults.Values) + { + snapshot.Add(item); + } + + snapshot.MatchInline( + """ + ContentType + --------------- + text/event-stream; charset=utf-8 + --------------- + + --------------- + RequestIndex: 0 + Data: {"hero":{"name":"R2-D2"}} + --------------- + + --------------- + RequestIndex: 1 + Data: {"hero":{"name":"Luke Skywalker"}} + --------------- + + --------------- + RequestIndex: 2 + Data: {"__typename":"Query"} + --------------- + + """); + } +} diff --git a/src/HotChocolate/Caching/src/Caching/CacheControlTypeInterceptor.cs b/src/HotChocolate/Caching/src/Caching/CacheControlTypeInterceptor.cs index d5f87b689bc..e69dfc0ce26 100644 --- a/src/HotChocolate/Caching/src/Caching/CacheControlTypeInterceptor.cs +++ b/src/HotChocolate/Caching/src/Caching/CacheControlTypeInterceptor.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; using System.Linq; +using System.Reflection; +using System.Threading.Tasks; using HotChocolate.Configuration; using HotChocolate.Language; using HotChocolate.Types; @@ -89,8 +91,7 @@ private void TryApplyDefaults(RegisteredType type, ObjectTypeDefinition objectDe continue; } - if (type.IsQueryType == true || - CostTypeInterceptor.IsDataResolver(field)) + if (type.IsQueryType == true || IsDataResolver(field)) { // Each field on the query type or data resolver fields // are treated as fields that need to be explicitly cached. @@ -148,4 +149,40 @@ private static bool IsCacheControlDirective(DirectiveDefinition directive) return false; } + + /// + /// Defines if a resolver is possible fetching data and causing higher impact on the system. + /// + internal static bool IsDataResolver(ObjectFieldDefinition field) + { + if (field.PureResolver is not null && field.MiddlewareDefinitions.Count == 0) + { + return false; + } + + if (field.Resolver is not null) + { + return true; + } + + var resolver = field.ResolverMember ?? field.Member; + + if (resolver is MethodInfo method) + { + if (typeof(Task).IsAssignableFrom(method.ReturnType) || + typeof(IQueryable).IsAssignableFrom(method.ReturnType) || + typeof(IExecutable).IsAssignableFrom(method.ReturnType)) + { + return true; + } + + if (method.ReturnType.IsGenericType && + method.ReturnType.GetGenericTypeDefinition() == typeof(ValueTask<>)) + { + return true; + } + } + + return false; + } } diff --git a/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheQueryRequestBuilderExtensions.cs b/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheQueryRequestBuilderExtensions.cs index 53eb6de5c37..126996b75de 100644 --- a/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheQueryRequestBuilderExtensions.cs +++ b/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheQueryRequestBuilderExtensions.cs @@ -1,14 +1,14 @@ namespace HotChocolate.Execution; -public static class QueryCacheQueryRequestBuilderExtensions +public static class QueryCacheOperationRequestBuilderExtensions { /// /// Skip the query result caching for the current request. /// /// - /// The . + /// The . /// - public static IQueryRequestBuilder SkipQueryCaching( - this IQueryRequestBuilder builder) => + public static OperationRequestBuilder SkipQueryCaching( + this OperationRequestBuilder builder) => builder.SetGlobalState(WellKnownContextData.SkipQueryCaching, null); } diff --git a/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheRequestExecutorBuilderExtensions.cs b/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheRequestExecutorBuilderExtensions.cs index 66d165a0b2f..19b33fd1c87 100644 --- a/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/Caching/src/Caching/Extensions/QueryCacheRequestExecutorBuilderExtensions.cs @@ -42,7 +42,6 @@ public static IRequestExecutorBuilder UseQueryCachePipeline( .UseDocumentParser() .UseDocumentValidation() .UseOperationCache() - .UseOperationComplexityAnalyzer() .UseOperationResolver() .UseOperationVariableCoercion() .UseOperationExecution(); diff --git a/src/HotChocolate/Caching/src/Caching/ICacheControlConstraints.cs b/src/HotChocolate/Caching/src/Caching/ICacheControlConstraints.cs index 693a62cf081..3de506a68a6 100644 --- a/src/HotChocolate/Caching/src/Caching/ICacheControlConstraints.cs +++ b/src/HotChocolate/Caching/src/Caching/ICacheControlConstraints.cs @@ -15,7 +15,7 @@ public interface ICacheConstraints int MaxAge { get; } /// - /// The scope of the that shall be cached. + /// The scope of the that shall be cached. /// CacheControlScope Scope { get; } } diff --git a/src/HotChocolate/Caching/src/Caching/QueryCacheMiddleware.cs b/src/HotChocolate/Caching/src/Caching/QueryCacheMiddleware.cs index caad6ddc2b6..2b5d1697b7a 100644 --- a/src/HotChocolate/Caching/src/Caching/QueryCacheMiddleware.cs +++ b/src/HotChocolate/Caching/src/Caching/QueryCacheMiddleware.cs @@ -47,7 +47,7 @@ queryResult.ContextData is not null contextData.Add(CacheControlHeaderValue, cacheControlHeaderValue); - context.Result = new QueryResult( + context.Result = new OperationResult( queryResult.Data, queryResult.Errors, queryResult.Extensions, diff --git a/src/HotChocolate/Core/src/Abstractions/ArgumentAttribute.cs b/src/HotChocolate/Core/src/Abstractions/ArgumentAttribute.cs index 792f2f00b85..d078ed5d792 100644 --- a/src/HotChocolate/Core/src/Abstractions/ArgumentAttribute.cs +++ b/src/HotChocolate/Core/src/Abstractions/ArgumentAttribute.cs @@ -1,7 +1,5 @@ using System; -#nullable enable - namespace HotChocolate; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/ExecutionResultExtensions.cs b/src/HotChocolate/Core/src/Abstractions/Execution/ExecutionResultExtensions.cs index 826284838c6..0667cf4b834 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/ExecutionResultExtensions.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/ExecutionResultExtensions.cs @@ -100,9 +100,9 @@ public static bool IsStreamResult(this IExecutionResult result) /// /// Expect a query result. /// - public static IQueryResult ExpectQueryResult(this IExecutionResult result) + public static IOperationResult ExpectQueryResult(this IExecutionResult result) { - if (result is IQueryResult qr) + if (result is IOperationResult qr) { return qr; } diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionRequest.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionRequest.cs new file mode 100644 index 00000000000..eead15368b9 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionRequest.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace HotChocolate.Execution; + +public interface IExecutionRequest +{ + /// + /// Gets the initial request state. + /// + IReadOnlyDictionary? ContextData { get; } + + /// + /// Gets the services that shall be used while executing the GraphQL request. + /// + IServiceProvider? Services { get; } +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs index 852085e24b2..d84f499caeb 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; -#nullable enable - namespace HotChocolate.Execution; /// @@ -34,4 +32,4 @@ public interface IExecutionResult : IAsyncDisposable /// A cleanup task that will be executed when this result is disposed. /// void RegisterForCleanup(Func clean); -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocument.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocument.cs new file mode 100644 index 00000000000..47dbc8f8efd --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocument.cs @@ -0,0 +1,32 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace HotChocolate.Execution; + +/// +/// Represents a GraphQL operation document. +/// +public interface IOperationDocument +{ + /// + /// Writes the current document to the output stream. + /// + Task WriteToAsync(Stream output, CancellationToken cancellationToken = default); + + /// + /// Returns the binary document representation. + /// + ReadOnlySpan AsSpan(); + + /// + /// Returns the binary document representation. + /// + byte[] ToArray(); + + /// + /// Returns the document string representation. + /// + string ToString(); +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocumentStorage.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocumentStorage.cs new file mode 100644 index 00000000000..c5665970219 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationDocumentStorage.cs @@ -0,0 +1,44 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace HotChocolate.Execution; + +/// +/// Represents a storage for operation documents. +/// +public interface IOperationDocumentStorage +{ + /// + /// Tries to read an operation document from the storage. + /// If the document does not exist null is returned. + /// + /// + /// The id of the document to read. + /// + /// + /// The cancellation token. + /// + /// + /// Returns the operation document or null if the document does not exist. + /// + ValueTask TryReadAsync( + OperationDocumentId documentId, + CancellationToken cancellationToken = default); + + /// + /// Saves an operation document to the storage. + /// + /// + /// The id of the document to save. + /// + /// + /// The document to save. + /// + /// + /// The cancellation token. + /// + ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, + CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequest.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationRequest.cs similarity index 58% rename from src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequest.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/IOperationRequest.cs index 864709cc510..9ac69105e50 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequest.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationRequest.cs @@ -1,29 +1,27 @@ using System; using System.Collections.Generic; -#nullable enable - namespace HotChocolate.Execution; /// -/// Representation of a GraphQL request. +/// Defines the basic properties fro a GraphQL operation request. /// -public interface IQueryRequest +public interface IOperationRequest : IExecutionRequest { /// /// Gets the GraphQL request document. /// - IQuery? Query { get; } + IOperationDocument? Document { get; } /// /// Gets the GraphQL request document ID. /// - string? QueryId { get; } + OperationDocumentId? DocumentId { get; } /// /// Gets GraphQL request document hash. /// - string? QueryHash { get; } + string? DocumentHash { get; } /// /// A name of an operation in the GraphQL request document that shall be executed; @@ -31,28 +29,13 @@ public interface IQueryRequest /// string? OperationName { get; } - /// - /// Gets the variable values for the GraphQL request. - /// - IReadOnlyDictionary? VariableValues { get; } - /// /// Gets the GraphQL request extension data. /// IReadOnlyDictionary? Extensions { get; } - /// - /// Gets the initial request state. - /// - IReadOnlyDictionary? ContextData { get; } - - /// - /// Gets the services that shall be used while executing the GraphQL request. - /// - IServiceProvider? Services { get; } - /// /// GraphQL request flags allow to limit the GraphQL executor capabilities. /// GraphQLRequestFlags Flags { get; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResult.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationResult.cs similarity index 85% rename from src/HotChocolate/Core/src/Abstractions/Execution/IQueryResult.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/IOperationResult.cs index d55b600df14..b18029b3e7e 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResult.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationResult.cs @@ -1,14 +1,22 @@ using System.Collections.Generic; -#nullable enable - namespace HotChocolate.Execution; /// /// Represents a query result object. /// -public interface IQueryResult : IExecutionResult +public interface IOperationResult : IExecutionResult { + /// + /// Gets the index of the request that corresponds to this result. + /// + int? RequestIndex { get; } + + /// + /// Gets the index of of the variable set that corresponds to this result. + /// + int? VariableIndex { get; } + /// /// A string that was passed to the label argument of the @defer or @stream /// directive that corresponds to this results. @@ -52,7 +60,7 @@ public interface IQueryResult : IExecutionResult /// /// Gets the incremental patches provided with this result. /// - IReadOnlyList? Incremental { get; } + IReadOnlyList? Incremental { get; } /// /// A boolean that is present and true when there are more payloads diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultFormatter.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationResultFormatter.cs similarity index 89% rename from src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultFormatter.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/IOperationResultFormatter.cs index e278edc97d1..5fe75c13903 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultFormatter.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IOperationResultFormatter.cs @@ -4,14 +4,12 @@ using System.Threading; using System.Threading.Tasks; -#nullable enable - namespace HotChocolate.Execution; /// -/// Represents a formatter for s. +/// Represents a formatter for s. /// -public interface IQueryResultFormatter +public interface IOperationResultFormatter { /// /// Formats a query result and writes the formatted result to @@ -31,7 +29,7 @@ public interface IQueryResultFormatter /// is null. /// ValueTask FormatAsync( - IQueryResult result, + IOperationResult result, Stream outputStream, CancellationToken cancellationToken = default); @@ -50,6 +48,6 @@ ValueTask FormatAsync( /// is null. /// void Format( - IQueryResult result, + IOperationResult result, IBufferWriter writer); } diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IQuery.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IQuery.cs deleted file mode 100644 index 7a8318f0988..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IQuery.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -#nullable enable - -namespace HotChocolate.Execution; - -/// -/// Represents an executable query. -/// -public interface IQuery -{ - /// - /// Writes the current query to the output stream. - /// - [Obsolete("Use WriteToAsync")] - void WriteTo(Stream output); - - /// - /// Writes the current query to the output stream. - /// - Task WriteToAsync(Stream output); - - /// - /// Writes the current query to the output stream. - /// - Task WriteToAsync(Stream output, CancellationToken cancellationToken); - - /// - /// Returns the binary query representation. - /// - ReadOnlySpan AsSpan(); - - /// - /// Returns the query string representation. - /// - string ToString(); -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequestBuilder.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequestBuilder.cs deleted file mode 100644 index f66ec0f938d..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryRequestBuilder.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using HotChocolate.Language; - -#nullable enable - -namespace HotChocolate.Execution; - -public interface IQueryRequestBuilder -{ - IQueryRequestBuilder SetQuery( - string sourceText); - - IQueryRequestBuilder SetQuery( - DocumentNode document); - - IQueryRequestBuilder SetQueryId( - string? queryName); - - IQueryRequestBuilder SetQueryHash( - string? queryHash); - - IQueryRequestBuilder SetOperation( - string? operationName); - - IQueryRequestBuilder SetVariableValues( - Dictionary? variableValues); - - IQueryRequestBuilder SetVariableValues( - IDictionary? variableValues); - - IQueryRequestBuilder SetVariableValues( - IReadOnlyDictionary? variableValues); - - IQueryRequestBuilder AddVariableValue( - string name, object? value); - - IQueryRequestBuilder TryAddVariableValue( - string name, object? value); - - IQueryRequestBuilder SetVariableValue( - string name, object? value); - - /// - /// Initializes the global state of the request to the given - /// . - /// - /// The initial state. - /// The query request builder. - IQueryRequestBuilder InitializeGlobalState( - Dictionary? initialState); - - /// - /// Initializes the global state of the request to the given - /// . - /// - /// The initial state. - /// The query request builder. - IQueryRequestBuilder InitializeGlobalState( - IDictionary? initialState); - - /// - /// Initializes the global state of the request to the given - /// . - /// - /// The initial state. - /// The query request builder. - IQueryRequestBuilder InitializeGlobalState( - IReadOnlyDictionary? initialState); - - /// - /// Sets the global state for - /// to the specified , - /// or throws an exception if it already exists. - /// - /// The name of the state. - /// The state value. - /// The query request builder. - /// - /// Thrown if a state value for already exists. - /// - IQueryRequestBuilder AddGlobalState( - string name, object? value); - - /// - /// Sets the global state for - /// to the specified , - /// if it does not yet exist. - /// - /// The name of the state. - /// The state value. - /// The query request builder. - IQueryRequestBuilder TryAddGlobalState( - string name, object? value); - - /// - /// Sets the global state for - /// to the specified . - /// State set previously using the same - /// will be overwritten. - /// - /// The name of the state. - /// The new state value. - /// The query request builder. - IQueryRequestBuilder SetGlobalState( - string name, object? value); - - /// - /// Removes the global state value for the specified - /// . - /// - /// The name of the state. - /// The query request builder. - IQueryRequestBuilder RemoveGlobalState( - string name); - - IQueryRequestBuilder SetExtensions( - Dictionary? extensions); - - IQueryRequestBuilder SetExtensions( - IDictionary? extensions); - - IQueryRequestBuilder SetExtensions( - IReadOnlyDictionary? extensions); - - IQueryRequestBuilder AddExtension( - string name, object? value); - - IQueryRequestBuilder TryAddExtension( - string name, object? value); - - IQueryRequestBuilder SetExtension( - string name, object? value); - - IQueryRequestBuilder SetServices( - IServiceProvider? services); - - IQueryRequestBuilder TrySetServices( - IServiceProvider? services); - - IQueryRequestBuilder SetFlags( - GraphQLRequestFlags flags); - - IQueryRequest Create(); -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultBuilder.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultBuilder.cs deleted file mode 100644 index 77edef027fb..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IQueryResultBuilder.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -#nullable enable - -namespace HotChocolate.Execution; - -public interface IQueryResultBuilder -{ - IQueryResultBuilder SetData(IReadOnlyDictionary? data); - - IQueryResultBuilder SetItems(IReadOnlyList? items); - - IQueryResultBuilder AddError(IError error); - - IQueryResultBuilder AddErrors(IEnumerable errors); - - IQueryResultBuilder AddExtension(string key, object? data); - - IQueryResultBuilder SetExtension(string key, object? data); - - IQueryResultBuilder SetExtensions(IReadOnlyDictionary? extensions); - - IQueryResultBuilder AddContextData(string key, object? data); - - IQueryResultBuilder SetContextData(string key, object? data); - - IQueryResultBuilder SetContextData(IReadOnlyDictionary? contextData); - - IQueryResultBuilder SetLabel(string? label); - - IQueryResultBuilder SetPath(Path? path); - - IQueryResultBuilder SetHasNext(bool? hasNext); - - IQueryResultBuilder RegisterForCleanup(Func clean); - - IQueryResult Create(); -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IReadStoredQueries.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IReadStoredQueries.cs deleted file mode 100644 index 891fcd6efcf..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IReadStoredQueries.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -#nullable enable - -namespace HotChocolate.Execution; - -/// -/// A tool for reading queries from some persistence medium. -/// -public interface IReadStoredQueries -{ - /// - /// Retrieves the query associated with the given identifier. - /// If the query is not found null is returned. - /// - /// The query identifier. - /// The cancellation token. - /// - /// The desired query or null if no query - /// is found with the specified identifier. - /// - Task TryReadQueryAsync( - string queryId, - CancellationToken cancellationToken = default); -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStream.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStream.cs index 5b1a5b99281..a24c587e2c5 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStream.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStream.cs @@ -3,7 +3,7 @@ namespace HotChocolate.Execution; /// -/// The response stream represents a stream of that are produced +/// The response stream represents a stream of that are produced /// by the execution engine. /// public interface IResponseStream : IExecutionResult @@ -11,5 +11,5 @@ public interface IResponseStream : IExecutionResult /// /// Reads the subscription results from the execution engine. /// - IAsyncEnumerable ReadResultsAsync(); + IAsyncEnumerable ReadResultsAsync(); } diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStreamFormatter.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStreamFormatter.cs index 64d94ab76b1..f758494e478 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStreamFormatter.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IResponseStreamFormatter.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable enable - namespace HotChocolate.Execution; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/ISourceStream~1.cs b/src/HotChocolate/Core/src/Abstractions/Execution/ISourceStream~1.cs index 5228024953f..025c88778fc 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/ISourceStream~1.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/ISourceStream~1.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable enable - namespace HotChocolate.Execution; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IVariableValueCollection.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IVariableValueCollection.cs index 7064fa65aec..1ef1c296753 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IVariableValueCollection.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IVariableValueCollection.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -#nullable enable - namespace HotChocolate.Execution; /// @@ -15,7 +13,7 @@ public interface IVariableValueCollection : IEnumerable /// /// The variable name. /// - /// + /// /// A GraphQL execution error is thrown when the /// requested variable cannot be found or cannot /// be converted to the request type. diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IWriteStoredQueries.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IWriteStoredQueries.cs deleted file mode 100644 index 0b33bf2259e..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IWriteStoredQueries.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -#nullable enable - -namespace HotChocolate.Execution; - -/// -/// A tool for storing queries to some persistence medium. -/// -public interface IWriteStoredQueries -{ - /// - /// Stores a given query using the given identifier. - /// - /// The query identifier. - /// The query to store. - /// The cancellation token. - /// An asynchronous operation. - Task WriteQueryAsync( - string queryId, - IQuery query, - CancellationToken cancellationToken = default); -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocument.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocument.cs new file mode 100644 index 00000000000..5f10318c88a --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocument.cs @@ -0,0 +1,72 @@ +using System; +using System.IO; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using HotChocolate.Language; +using HotChocolate.Language.Utilities; + +namespace HotChocolate.Execution; + +/// +/// Represents an already parsed GraphQL operation document. +/// +/// +/// The parsed GraphQL operation document. +/// +public sealed class OperationDocument(DocumentNode document) : IOperationDocument +{ + /// + /// Gets the parsed GraphQL operation document. + /// + public DocumentNode Document { get; } = document ?? throw new ArgumentNullException(nameof(document)); + + /// + /// Writes the current document to the output stream. + /// + /// + /// The output stream to which the document is written. + /// + /// + /// The cancellation token. + /// + /// + /// is null. + /// + public async Task WriteToAsync(Stream output, CancellationToken cancellationToken = default) + { + if (output == null) + { + throw new ArgumentNullException(nameof(output)); + } + + await Document.PrintToAsync(output, false, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the binary document representation. + /// + /// + /// Returns the binary document representation. + /// + public ReadOnlySpan AsSpan() + => Encoding.UTF8.GetBytes(Document.Print(false)); + + /// + /// Returns the binary document representation. + /// + /// + /// Returns the binary document representation. + /// + public byte[] ToArray() + => Encoding.UTF8.GetBytes(Document.Print(false)); + + /// + /// Returns the document string representation. + /// + /// + /// Returns the document string representation. + /// + public override string ToString() + => Document.Print(); +} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentId.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentId.cs new file mode 100644 index 00000000000..0d5ad583471 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentId.cs @@ -0,0 +1,237 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using static HotChocolate.Properties.AbstractionResources; + +namespace HotChocolate.Execution; + +/// +/// Represents a valid identifier for a GraphQL operation document. +/// +public readonly struct OperationDocumentId : IEquatable +{ + /// + /// Initializes a new instance of . + /// + /// + /// The GraphQL operation document id. + /// + public OperationDocumentId(string value) + { + EnsureValidId(value); + Value = value; + } + + private OperationDocumentId(string value, bool skipValidation) + { + if (!skipValidation) + { + EnsureValidId(value); + } + Value = value; + } + + /// + /// Gets a value indicating whether the GraphQL operation document id is empty. + /// + public bool IsEmpty => string.IsNullOrEmpty(Value); + + /// + /// Gets the GraphQL operation document id. + /// + public string Value { get; } + + /// + /// Determines whether the specified + /// is equal to the current . + /// + /// + /// The to compare with the current . + /// + /// + /// true if the specified is equal to the current ; + /// otherwise, false. + /// + public bool Equals(OperationDocumentId other) + => string.Equals(Value, other.Value, StringComparison.Ordinal); + + /// + /// Determines whether the specified + /// is equal to the current . + /// + /// + /// The to compare with the current . + /// + /// + /// true if the specified is equal to the current ; + /// otherwise, false. + /// + public override bool Equals(object? obj) + => obj is OperationDocumentId other && Equals(other); + + /// + /// Serves as the default hash function. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + => Value.GetHashCode(); + + /// + /// Returns a string that represents the current . + /// + public override string? ToString() => Value; + + /// + /// Determines whether the specified is equal to the specified . + /// + /// + /// The first to compare. + /// + /// + /// The second to compare. + /// + /// + /// true if the specified is equal to the specified ; + /// otherwise, false. + /// + public static bool operator ==(OperationDocumentId left, OperationDocumentId right) + => left.Equals(right); + + /// + /// Determines whether the specified is not equal to the specified . + /// + /// + /// The first to compare. + /// + /// + /// The second to compare. + /// + /// + /// true if the specified is not equal to the specified ; + /// otherwise, false. + /// + public static bool operator !=(OperationDocumentId left, OperationDocumentId right) + => !left.Equals(right); + + /// + /// Implicitly converts the specified to a . + /// + /// + /// The GraphQL operation document id string representation. + /// + /// + /// A new instance of representing the specified . + /// + public static implicit operator OperationDocumentId?(string? value) + => value is null ? null : new OperationDocumentId(value); + + /// + /// Ensures that the specified GraphQL operation document id is valid. + /// + /// + /// The GraphQL operation document id. + /// + /// + /// The specified GraphQL operation document id is invalid. + /// + public static void EnsureValidId(string operationId) + { + if(!IsValidId(operationId)) + { + throw new ArgumentException( + OperationDocumentId_InvalidOperationIdFormat, + nameof(operationId)); + } + } + + /// + /// Determines whether the specified + /// string is valid input for an . + /// + /// + /// The GraphQL operation document id. + /// + /// + /// true if the specified is valid; + /// otherwise, false. + /// + public static bool IsValidId(string operationId) + { + if(operationId.Length == 0) + { + return false; + } + + var span = operationId.AsSpan(); + ref var start = ref MemoryMarshal.GetReference(span); + ref var end = ref Unsafe.Add(ref start, span.Length); + + while (Unsafe.IsAddressLessThan(ref start, ref end)) + { + if (!IsAllowedCharacter((byte)start)) + { + return false; + } + + start = ref Unsafe.Add(ref start, 1)!; + } + + return true; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool IsAllowedCharacter(byte c) + { + switch (c) + { + case > 96 and < 123 or > 64 and < 91: + case > 47 and < 58: + case 45 or 95: + return true; + + default: + return false; + } + } + + /// + /// Determines whether the specified is null or empty. + /// + /// + /// The to check. + /// + /// + /// true if the specified is null or empty; + /// otherwise, false. + /// + public static bool IsNullOrEmpty([NotNullWhen(false)] OperationDocumentId? id) + => string.IsNullOrEmpty(id?.Value); + + /// + /// Tries to parse the specified to a . + /// + /// + /// The GraphQL operation document id string representation. + /// + /// + /// The parsed . + /// + /// + /// true if the specified could be parsed to a ; + /// otherwise, false. + /// + public static bool TryParse(string? value, out OperationDocumentId id) + { + if (string.IsNullOrEmpty(value) || !IsValidId(value)) + { + id = default; + return false; + } + + id = new OperationDocumentId(value, skipValidation: true); + return true; + } +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentSourceText.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentSourceText.cs new file mode 100644 index 00000000000..76d830506fd --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationDocumentSourceText.cs @@ -0,0 +1,62 @@ +using System; +using System.IO; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace HotChocolate.Execution; + +/// +/// Represents a GraphQL operation document source texts that needs parsing before it can be executed. +/// +/// +public sealed class OperationDocumentSourceText(string sourceText) : IOperationDocument +{ + /// + /// Gets the GraphQL operation document source text. + /// + public string SourceText { get; } = sourceText ?? throw new ArgumentNullException(nameof(sourceText)); + + /// + /// Writes the current document to the output stream. + /// + /// + /// The output stream to which the document is written. + /// + /// + /// The cancellation token. + /// + /// + /// is null. + /// + public async Task WriteToAsync(Stream output, CancellationToken cancellationToken = default) + { + if (output == null) + { + throw new ArgumentNullException(nameof(output)); + } + + var buffer = Encoding.UTF8.GetBytes(SourceText); + await output.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the binary document representation. + /// + /// + /// Returns the binary document representation. + /// + public ReadOnlySpan AsSpan() + => Encoding.UTF8.GetBytes(SourceText); + + public byte[] ToArray() + => Encoding.UTF8.GetBytes(SourceText); + + /// + /// Returns the document string representation. + /// + /// + /// Returns the document string representation. + /// + public override string ToString() => SourceText; +} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequest.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequest.cs new file mode 100644 index 00000000000..7c11eb6eb62 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequest.cs @@ -0,0 +1,468 @@ +using System; +using System.Collections.Generic; +using static HotChocolate.Properties.AbstractionResources; + +namespace HotChocolate.Execution; + +/// +/// Defines the standard GraphQL request. +/// +public sealed class OperationRequest : IOperationRequest +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// A GraphQL request document. + /// + /// + /// A GraphQL request document ID. + /// + /// + /// A GraphQL request document hash. + /// + /// + /// A name of an operation in the GraphQL request document that shall be executed; + /// + /// + /// The variable values for the GraphQL request. + /// + /// + /// The GraphQL request extension data. + /// + /// + /// The initial global request state. + /// + /// + /// The services that shall be used while executing the GraphQL request. + /// + /// + /// The GraphQL request flags can be used to limit the execution engine capabilities. + /// + /// + /// and are both null. + /// + public OperationRequest( + IOperationDocument? document, + OperationDocumentId? documentId, + string? documentHash, + string? operationName, + IReadOnlyDictionary? variableValues, + IReadOnlyDictionary? extensions, + IReadOnlyDictionary? contextData, + IServiceProvider? services, + GraphQLRequestFlags flags) + { + if (document is null && OperationDocumentId.IsNullOrEmpty(documentId)) + { + throw new InvalidOperationException(OperationRequest_DocumentOrIdMustBeSet); + } + + Document = document; + DocumentId = documentId; + DocumentHash = documentHash; + OperationName = operationName; + VariableValues = variableValues; + Extensions = extensions; + ContextData = contextData; + Services = services; + Flags = flags; + } + + /// + /// Gets the GraphQL request document. + /// + public IOperationDocument? Document { get; } + + /// + /// Gets the GraphQL request document ID. + /// + public OperationDocumentId? DocumentId { get; } + + /// + /// Gets GraphQL request document hash. + /// + public string? DocumentHash { get; } + + /// + /// A name of an operation in the GraphQL request document that shall be executed; + /// or, null if the document only contains a single operation. + /// + public string? OperationName { get; } + + /// + /// Gets the variable values for the GraphQL request. + /// + public IReadOnlyDictionary? VariableValues { get; } + + /// + /// Gets the GraphQL request extension data. + /// + public IReadOnlyDictionary? Extensions { get; } + + /// + /// Gets the initial request state. + /// + public IReadOnlyDictionary? ContextData { get; } + + /// + /// Gets the services that shall be used while executing the GraphQL request. + /// + public IServiceProvider? Services { get; } + + /// + /// GraphQL request flags allow to limit the GraphQL executor capabilities. + /// + public GraphQLRequestFlags Flags { get; } + + /// + /// Creates a new request with the specified document. + /// + /// + /// The GraphQL request document. + /// + /// + /// Returns a new request with the specified document. + /// + public OperationRequest WithDocument(IOperationDocument document) + => new OperationRequest( + document, + DocumentId, + DocumentHash, + OperationName, + VariableValues, + Extensions, + ContextData, + Services, + Flags); + + /// + /// Creates a new request with the specified document ID. + /// + /// + /// The ID of the persisted operation document. + /// + /// + /// Returns a new request with the specified document ID. + /// + public OperationRequest WithDocumentId(OperationDocumentId documentId) + => new OperationRequest( + Document, + documentId, + DocumentHash, + OperationName, + VariableValues, + Extensions, + ContextData, + Services, + Flags); + + /// + /// Creates a new request with the specified document hash. + /// + /// + /// The hash of the persisted operation document. + /// + /// + /// Returns a new request with the specified document hash. + /// + public OperationRequest WithDocumentHash(string documentHash) + => new OperationRequest( + Document, + DocumentId, + documentHash, + OperationName, + VariableValues, + Extensions, + ContextData, + Services, + Flags); + + /// + /// Creates a new request with the specified operation name. + /// + /// + /// The name of the operation that shall be executed. + /// + /// + /// Returns a new request with the specified operation name. + /// + public OperationRequest WithOperationName(string operationName) + => new OperationRequest( + Document, + DocumentId, + DocumentHash, + operationName, + VariableValues, + Extensions, + ContextData, + Services, + Flags); + + /// + /// Creates a new request with the specified variable values. + /// + /// + /// The variable values that shall be used while executing the operation. + /// + /// + /// Returns a new request with the specified variable values. + /// + public OperationRequest WithVariableValues(IReadOnlyDictionary variableValues) + => new OperationRequest( + Document, + DocumentId, + DocumentHash, + OperationName, + variableValues, + Extensions, + ContextData, + Services, + Flags); + + /// + /// Creates a new request with the specified extensions. + /// + /// + /// The extensions that shall be used while executing the operation. + /// + /// + /// Returns a new request with the specified extensions. + /// + public OperationRequest WithExtensions(IReadOnlyDictionary extensions) + => new OperationRequest( + Document, + DocumentId, + DocumentHash, + OperationName, + VariableValues, + extensions, + ContextData, + Services, + Flags); + + /// + /// Creates a new request with the specified context data. + /// + /// + /// The context data that shall be used while executing the operation. + /// + /// + /// Returns a new request with the specified context data. + /// + public OperationRequest WithContextData(IReadOnlyDictionary contextData) + => new OperationRequest( + Document, + DocumentId, + DocumentHash, + OperationName, + VariableValues, + Extensions, + contextData, + Services, + Flags); + + /// + /// Creates a new request with the specified services. + /// + /// + /// The services that shall be used while executing the operation. + /// + /// + /// Returns a new request with the specified services. + /// + public OperationRequest WithServices(IServiceProvider services) + => new OperationRequest( + Document, + DocumentId, + DocumentHash, + OperationName, + VariableValues, + Extensions, + ContextData, + services, + Flags); + + /// + /// Creates a new request with the specified flags. + /// + /// + /// The request flags. + /// + /// + /// Returns a new request with the specified flags. + /// + public OperationRequest WithFlags(GraphQLRequestFlags flags) + => new OperationRequest( + Document, + DocumentId, + DocumentHash, + OperationName, + VariableValues, + Extensions, + ContextData, + Services, + flags); + + /// + /// Creates a persisted operation request. + /// + /// + /// The ID of the persisted operation document. + /// + /// + /// The hash of the persisted operation document. + /// + /// + /// The name of the operation that shall be executed. + /// + /// + /// The variable values for the operation. + /// + /// + /// The extensions for the operation. + /// + /// + /// The context data for the operation. + /// + /// + /// The services that shall be used while executing the operation. + /// + /// + /// The request flags. + /// + /// + /// Returns a new persisted operation request. + /// + /// + /// is null. + /// + public static OperationRequest FromId( + OperationDocumentId documentId, + string? documentHash = null, + string? operationName = null, + IReadOnlyDictionary? variableValues = null, + IReadOnlyDictionary? extensions = null, + IReadOnlyDictionary? contextData = null, + IServiceProvider? services = null, + GraphQLRequestFlags flags = GraphQLRequestFlags.AllowAll) + { + if (OperationDocumentId.IsNullOrEmpty(documentId)) + { + throw new ArgumentNullException(nameof(documentId)); + } + + return new OperationRequest( + null, + documentId, + documentHash, + operationName, + variableValues, + extensions, + contextData, + services, + flags); + } + + /// + /// Creates a persisted operation request. + /// + /// + /// The ID of the persisted operation document. + /// + /// + /// The hash of the persisted operation document. + /// + /// + /// The name of the operation that shall be executed. + /// + /// + /// The variable values for the operation. + /// + /// + /// The extensions for the operation. + /// + /// + /// The context data for the operation. + /// + /// + /// The services that shall be used while executing the operation. + /// + /// + /// The request flags. + /// + /// + /// Returns a new persisted operation request. + /// + /// + /// is null. + /// + public static OperationRequest FromId( + string documentId, + string? documentHash = null, + string? operationName = null, + IReadOnlyDictionary? variableValues = null, + IReadOnlyDictionary? extensions = null, + IReadOnlyDictionary? contextData = null, + IServiceProvider? services = null, + GraphQLRequestFlags flags = GraphQLRequestFlags.AllowAll) + => FromId( + new OperationDocumentId(documentId), + documentHash, + operationName, + variableValues, + extensions, + contextData, + services, + flags); + + /// + /// Creates a GraphQL request from a operation document source text. + /// + /// + /// The GraphQL operation document source text. + /// + /// + /// The hash of the persisted operation document. + /// + /// + /// The name of the operation that shall be executed. + /// + /// + /// The variable values for the operation. + /// + /// + /// The extensions for the operation. + /// + /// + /// The context data for the operation. + /// + /// + /// The services that shall be used while executing the operation. + /// + /// + /// The request flags. + /// + /// + /// Returns a new persisted operation request. + /// + public static OperationRequest FromSourceText( + string sourceText, + string? documentHash = null, + string? operationName = null, + IReadOnlyDictionary? variableValues = null, + IReadOnlyDictionary? extensions = null, + IReadOnlyDictionary? contextData = null, + IServiceProvider? services = null, + GraphQLRequestFlags flags = GraphQLRequestFlags.AllowAll) + => new OperationRequest( + new OperationDocumentSourceText(sourceText), + null, + documentHash, + operationName, + variableValues, + extensions, + contextData, + services, + flags); +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBatch.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBatch.cs new file mode 100644 index 00000000000..7992f881490 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBatch.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +namespace HotChocolate.Execution; + +/// +/// Represents a batch of GraphQL requests that shall be executed together. +/// +/// +/// The requests within this batch. +/// +/// +/// The initial request state. +/// +/// +/// The services that shall be used while executing the GraphQL request. +/// +public sealed class OperationRequestBatch( + IReadOnlyList requests, + IReadOnlyDictionary? contextData = null, + IServiceProvider? services = null) + : IExecutionRequest +{ + /// + /// The requests within this batch. + /// + public IReadOnlyList Requests { get; } = requests; + + /// + /// Gets the initial request state. + /// + public IReadOnlyDictionary? ContextData { get; } = contextData; + + /// + /// Gets the services that shall be used while executing the GraphQL request. + /// + public IServiceProvider? Services { get; } = services; +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilder.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilder.cs new file mode 100644 index 00000000000..55d4b1bc0f7 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilder.cs @@ -0,0 +1,522 @@ +using System; +using System.Collections.Generic; +#if NET7_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif +using System.Linq; +using HotChocolate.Language; +using static HotChocolate.Properties.AbstractionResources; + +namespace HotChocolate.Execution; + +public sealed class OperationRequestBuilder +{ + private IOperationDocument? _document; + private OperationDocumentId? _documentId; + private string? _documentHash; + private string? _operationName; + private IReadOnlyList>? _readOnlyVariableValues; + private List>? _variableValues; + private IReadOnlyDictionary? _readOnlyExtensions; + private Dictionary? _contextData; + private IReadOnlyDictionary? _readOnlyContextData; + private IServiceProvider? _services; + private GraphQLRequestFlags _flags = GraphQLRequestFlags.AllowAll; + + /// + /// Sets the GraphQL operation document that shall be executed. + /// + /// + /// The GraphQL operation document source text. + /// + /// + /// Returns this instance of for configuration chaining. + /// + /// + /// is null or empty. + /// + public OperationRequestBuilder SetDocument( +#if NET7_0_OR_GREATER + [StringSyntax("graphql")] string sourceText) +#else + string sourceText) +#endif + { + if (string.IsNullOrEmpty(sourceText)) + { + throw new ArgumentException( + OperationRequestBuilder_OperationIsNullOrEmpty, + nameof(sourceText)); + } + + _document = new OperationDocumentSourceText(sourceText); + return this; + } + + /// + /// Sets the GraphQL operation document that shall be executed. + /// + /// + /// The parsed GraphQL operation document. + /// + /// + /// Returns this instance of for configuration chaining. + /// + /// + /// is null. + /// + public OperationRequestBuilder SetDocument(DocumentNode document) + { + if (document is null) + { + throw new ArgumentNullException(nameof(document)); + } + + _document = new OperationDocument(document); + return this; + } + + /// + /// Sets the GraphQL operation document id. + /// + /// + /// The GraphQL operation document id. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetDocumentId(OperationDocumentId? documentId) + { + _documentId = documentId; + return this; + } + + /// + /// Sets the hash of the GraphQL operation document. + /// + /// + /// + public OperationRequestBuilder SetDocumentHash(string? documentHash) + { + _documentHash = documentHash; + return this; + } + + /// + /// Sets the name of the operation in the GraphQL request document that shall be executed. + /// + /// + /// The name of the GraphQL operation within the GraphQL operation document. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetOperationName(string? operationName) + { + _operationName = operationName; + return this; + } + + /// + /// Sets the variable values for the GraphQL request. + /// + /// + /// The variable values for the GraphQL request. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder AddVariableValues( + IReadOnlyDictionary variableValues) + { + if (_readOnlyVariableValues is not null) + { + _variableValues = _readOnlyVariableValues.ToList(); + _readOnlyVariableValues = null; + } + + _variableValues ??= []; + _variableValues!.Add(variableValues); + return this; + } + + /// + /// Sets the variable values for the GraphQL request. + /// + /// + /// The variable values for the GraphQL request. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetVariableValues( + IReadOnlyDictionary? variableValues) + { + if (variableValues is null) + { + _variableValues = null; + _readOnlyVariableValues = null; + } + else + { + _variableValues = new List>(1) { variableValues, }; + _readOnlyVariableValues = null; + } + return this; + } + + /// + /// Sets the variable values for the GraphQL request. + /// + /// + /// The variable values for the GraphQL request. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetVariableValuesSet( + IReadOnlyList>? variableValues) + { + if (variableValues is null) + { + _variableValues = null; + _readOnlyVariableValues = null; + } + else + { + _variableValues = null; + _readOnlyVariableValues = variableValues; + } + return this; + } + + /// + /// Sets the GraphQL request extension data. + /// + /// + /// The GraphQL request extension data. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetExtensions( + IReadOnlyDictionary? extensions) + { + _readOnlyExtensions = extensions; + return this; + } + + /// + /// Sets the initial global request state. + /// + /// + /// The initial global request state. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetGlobalState(IReadOnlyDictionary? contextData) + { + _readOnlyContextData = _contextData; + _contextData = null; + return this; + } + + /// + /// Sets the initial global request state. + /// + /// + /// The name of the global state. + /// + /// + /// The value of the global state. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetGlobalState(string name, object? value) + { + if (_readOnlyContextData is not null) + { + _contextData = _readOnlyContextData.ToDictionary(t => t.Key, t => t.Value); + _readOnlyContextData = null; + } + + _contextData ??= new Dictionary(); + _contextData[name] = value; + return this; + } + + /// + /// Adds a global state to the initial global request state. + /// + /// + /// The name of the global state. + /// + /// + /// The value of the global state. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder AddGlobalState(string name, object? value) + { + if (_readOnlyContextData is not null) + { + _contextData = _readOnlyContextData.ToDictionary(t => t.Key, t => t.Value); + _readOnlyContextData = null; + } + + _contextData ??= new Dictionary(); + _contextData.Add(name, value); + return this; + } + + /// + /// Tries to add a global state to the initial global request state. + /// + /// + /// The name of the global state. + /// + /// + /// The value of the global state. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder TryAddGlobalState(string name, object? value) + { + if (_readOnlyContextData is not null) + { + _contextData = _readOnlyContextData.ToDictionary(t => t.Key, t => t.Value); + _readOnlyContextData = null; + } + + _contextData ??= new Dictionary(); + + if (!_contextData.ContainsKey(name)) + { + _contextData.Add(name, value); + } + return this; + } + + /// + /// Removes a global state from the initial global request state. + /// + /// + /// The name of the global state. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder RemoveGlobalState(string name) + { + if (_readOnlyContextData is not null) + { + _contextData = _readOnlyContextData.ToDictionary(t => t.Key, t => t.Value); + _readOnlyContextData = null; + } + + if (_contextData is null) + { + return this; + } + + _contextData.Remove(name); + return this; + } + + /// + /// Sets the initial global request state. + /// + /// + /// The services that shall be used while executing the GraphQL request. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetServices(IServiceProvider? services) + { + _services = services; + return this; + } + + /// + /// Tries to set the initial global request state. + /// + /// + /// The services that shall be used while executing the GraphQL request. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder TrySetServices(IServiceProvider? services) + { + _services ??= services; + return this; + } + + /// + /// Sets the GraphQL request flags can be used to limit the execution engine capabilities. + /// + /// + /// The GraphQL request flags can be used to limit the execution engine capabilities. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder SetFlags(GraphQLRequestFlags flags) + { + _flags = flags; + return this; + } + + /// + /// Resets the builder to its initial state. + /// + /// + /// Returns this instance of for configuration chaining. + /// + public OperationRequestBuilder Reset() + { + _document = null; + _documentId = null; + _documentHash = null; + _operationName = null; + _readOnlyVariableValues = null; + _variableValues = null; + _readOnlyExtensions = null; + _contextData = null; + _readOnlyContextData = null; + _services = null; + _flags = GraphQLRequestFlags.AllowAll; + return this; + } + + /// + /// Builds the operation request. + /// + /// + /// Returns the operation request. + /// + public IOperationRequest Build() + { + IOperationRequest? request; + + var variableSet = GetVariableValues(); + + if (variableSet is { Count: > 1, }) + { + request = new VariableBatchRequest( + document: _document, + documentId: _documentId, + documentHash: _documentHash, + operationName: _operationName, + variableValues: variableSet, + contextData: _readOnlyContextData ?? _contextData, + extensions: _readOnlyExtensions, + services: _services, + flags: _flags); + Reset(); + return request; + } + + request = new OperationRequest( + document: _document, + documentId: _documentId, + documentHash: _documentHash, + operationName: _operationName, + variableValues: variableSet is { Count: 1, } + ? variableSet[0] + : null, + contextData: _readOnlyContextData ?? _contextData, + extensions: _readOnlyExtensions, + services: _services, + flags: _flags + ); + Reset(); + return request; + } + + private IReadOnlyList>? GetVariableValues() + => _variableValues ?? _readOnlyVariableValues; + + /// + /// Creates a new instance of . + /// + /// + public static OperationRequestBuilder Create() => new(); + + /// + /// Creates a new instance of from an existing request. + /// + /// + /// The existing request from which the new builder is created. + /// + /// + /// + /// The request type is not supported. + /// + public static OperationRequestBuilder From(IOperationRequest request) + => request switch + { + VariableBatchRequest batch + => new OperationRequestBuilder + { + _document = batch.Document, + _documentId = batch.DocumentId, + _documentHash = batch.DocumentHash, + _operationName = batch.OperationName, + _readOnlyVariableValues = batch.VariableValues, + _readOnlyContextData = batch.ContextData, + _readOnlyExtensions = batch.Extensions, + _services = batch.Services, + _flags = batch.Flags, + }, + OperationRequest operation + => new OperationRequestBuilder + { + _document = operation.Document, + _documentId = operation.DocumentId, + _documentHash = operation.DocumentHash, + _operationName = operation.OperationName, + _readOnlyVariableValues = operation.VariableValues is not null + ? new List>(1) { operation.VariableValues, } + : null, + _readOnlyContextData = operation.ContextData, + _readOnlyExtensions = operation.Extensions, + _services = operation.Services, + _flags = operation.Flags, + }, + _ => throw new NotSupportedException("The request type is not supported.") + }; + + /// + /// Creates a new instance of from an existing request. + /// + /// + /// The existing request from which the new builder is created. + /// + /// + /// Returns a new instance of . + /// + public static OperationRequestBuilder From(GraphQLRequest request) + { + var builder = Create(); + + builder + .SetDocumentId(request.QueryId) + .SetDocumentHash(request.QueryHash) + .SetOperationName(request.OperationName) + .SetVariableValuesSet(request.Variables) + .SetExtensions(request.Extensions); + + if (request.Query is not null) + { + builder.SetDocument(request.Query); + } + + return builder; + } +} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilderExtensions.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilderExtensions.cs new file mode 100644 index 00000000000..af02bfba792 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationRequestBuilderExtensions.cs @@ -0,0 +1,93 @@ +using System; +using System.Security.Claims; + +namespace HotChocolate.Execution; + +/// +/// Extensions methods for . +/// +public static class OperationRequestBuilderExtensions +{ + /// + /// Allows introspection usage in the current request. + /// + public static OperationRequestBuilder AllowIntrospection( + this OperationRequestBuilder builder) + => builder.SetGlobalState(WellKnownContextData.IntrospectionAllowed, null); + + /// + /// Sets the error message for when the introspection is not allowed. + /// + public static OperationRequestBuilder SetIntrospectionNotAllowedMessage( + this OperationRequestBuilder builder, + string message) + { + if (message is null) + { + throw new ArgumentNullException(nameof(message)); + } + + return builder.SetGlobalState(WellKnownContextData.IntrospectionMessage, message); + } + + /// + /// Sets the error message for when the introspection is not allowed. + /// + public static OperationRequestBuilder SetIntrospectionNotAllowedMessage( + this OperationRequestBuilder builder, + Func messageFactory) + { + if (messageFactory is null) + { + throw new ArgumentNullException(nameof(messageFactory)); + } + + return builder.SetGlobalState(WellKnownContextData.IntrospectionMessage, messageFactory); + } + + /// + /// Skips the operation complexity analysis of this request. + /// + public static OperationRequestBuilder SkipComplexityAnalysis( + this OperationRequestBuilder builder) + => builder.SetGlobalState(WellKnownContextData.SkipComplexityAnalysis, null); + + /// + /// Set allowed complexity for this request and override the global allowed complexity. + /// + public static OperationRequestBuilder SetMaximumAllowedComplexity( + this OperationRequestBuilder builder, + int maximumAllowedComplexity) + => builder.SetGlobalState(WellKnownContextData.MaximumAllowedComplexity, maximumAllowedComplexity); + + /// + /// Marks the current request to allow non-persisted queries. + /// + public static OperationRequestBuilder AllowNonPersistedQuery( + this OperationRequestBuilder builder) + => builder.SetGlobalState(WellKnownContextData.NonPersistedQueryAllowed, true); + + /// + /// Skips the request execution depth analysis. + /// + public static OperationRequestBuilder SkipExecutionDepthAnalysis( + this OperationRequestBuilder builder) + => builder.SetGlobalState(WellKnownContextData.SkipDepthAnalysis, null); + + /// + /// Set allowed execution depth for this request and override the + /// global allowed execution depth. + /// + public static OperationRequestBuilder SetMaximumAllowedExecutionDepth( + this OperationRequestBuilder builder, + int maximumAllowedDepth) + => builder.SetGlobalState(WellKnownContextData.MaxAllowedExecutionDepth, maximumAllowedDepth); + + /// + /// Sets the user for this request. + /// + public static OperationRequestBuilder SetUser( + this OperationRequestBuilder builder, + ClaimsPrincipal claimsPrincipal) + => builder.SetGlobalState(nameof(ClaimsPrincipal), claimsPrincipal); +} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryResult.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResult.cs similarity index 77% rename from src/HotChocolate/Core/src/Abstractions/Execution/QueryResult.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/OperationResult.cs index c370c8dbf42..4ee9330ebdb 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryResult.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResult.cs @@ -3,27 +3,27 @@ using System.Threading.Tasks; using HotChocolate.Properties; -#nullable enable - namespace HotChocolate.Execution; /// /// Represents a query result object. /// -public sealed class QueryResult : ExecutionResult, IQueryResult +public sealed class OperationResult : ExecutionResult, IOperationResult { - internal QueryResult( + internal OperationResult( IReadOnlyDictionary? data, IReadOnlyList? errors, IReadOnlyDictionary? extension, IReadOnlyDictionary? contextData, IReadOnlyList? items, - IReadOnlyList? incremental, + IReadOnlyList? incremental, string? label, Path? path, bool? hasNext, Func[] cleanupTasks, - bool isDataSet) + bool isDataSet, + int? requestIndex, + int? variableIndex) : base(cleanupTasks) { if (data is null && @@ -47,21 +47,25 @@ incremental is null && Path = path; HasNext = hasNext; IsDataSet = isDataSet; + RequestIndex = requestIndex; + VariableIndex = variableIndex; } /// - /// Initializes a new . + /// Initializes a new . /// - public QueryResult( + public OperationResult( IReadOnlyDictionary? data, IReadOnlyList? errors = null, IReadOnlyDictionary? extension = null, IReadOnlyDictionary? contextData = null, IReadOnlyList? items = null, - IReadOnlyList? incremental = null, + IReadOnlyList? incremental = null, string? label = null, Path? path = null, - bool? hasNext = null) + bool? hasNext = null, + int? requestIndex = null, + int? variableIndex = null) { if (data is null && items is null && @@ -83,11 +87,19 @@ incremental is null && Label = label; Path = path; HasNext = hasNext; + RequestIndex = requestIndex; + VariableIndex = variableIndex; } /// public override ExecutionResultKind Kind => ExecutionResultKind.SingleResult; + /// + public int? RequestIndex { get; } + + /// + public int? VariableIndex { get; } + /// public string? Label { get; } @@ -107,7 +119,7 @@ incremental is null && public IReadOnlyDictionary? Extensions { get; } /// - public IReadOnlyList? Incremental { get; } + public IReadOnlyList? Incremental { get; } /// public override IReadOnlyDictionary? ContextData { get; } @@ -120,5 +132,5 @@ incremental is null && /// public IReadOnlyDictionary ToDictionary() - => QueryResultHelper.ToDictionary(this); + => OperationResultHelper.ToDictionary(this); } diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBatch.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBatch.cs new file mode 100644 index 00000000000..3518f1e0301 --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBatch.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using HotChocolate.Properties; + +namespace HotChocolate.Execution; + +/// +/// Represents a batch of operation results. +/// +public sealed class OperationResultBatch : ExecutionResult +{ + /// + /// Initializes a new instance of . + /// + /// + /// The results of this batch. + /// + /// + /// The result context data which represent additional properties that are NOT written to the transport. + /// + /// + /// The result must be either an operation result or a response stream. + /// + /// + /// is null. + /// + public OperationResultBatch( + IReadOnlyList results, + IReadOnlyDictionary? contextData = null) + : base(cleanupTasks: [() => RunCleanUp(results),]) + { + foreach (var result in results) + { + if (result is not IResponseStream and not OperationResult) + { + throw new ArgumentException( + AbstractionResources.OperationResultBatch_ResponseStreamOrOperationResult, + nameof(results)); + } + } + + Results = results ?? throw new ArgumentNullException(nameof(results)); + ContextData = contextData; + } + + /// + /// Gets the result kind. + /// + public override ExecutionResultKind Kind => ExecutionResultKind.BatchResult; + + /// + /// Gets the results of this batch. + /// + public IReadOnlyList Results { get; } + + /// + /// Gets the result context data which represent additional + /// properties that are NOT written to the transport. + /// + public override IReadOnlyDictionary? ContextData { get; } + + private static async ValueTask RunCleanUp(IReadOnlyList results) + { + foreach (var result in results) + { + await result.DisposeAsync().ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryResultBuilder.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilder.cs similarity index 69% rename from src/HotChocolate/Core/src/Abstractions/Execution/QueryResultBuilder.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilder.cs index a5cc7ff3b8b..76691d4e4a4 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryResultBuilder.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilder.cs @@ -4,21 +4,23 @@ namespace HotChocolate.Execution; -public sealed class QueryResultBuilder : IQueryResultBuilder +public sealed class OperationResultBuilder { private IReadOnlyDictionary? _data; private IReadOnlyList? _items; private List? _errors; private ExtensionData? _extensionData; private ExtensionData? _contextData; - private List? _incremental; + private List? _incremental; private string? _label; private Path? _path; private bool? _hasNext; private bool? _isDataSet; + private int? _requestIndex; + private int? _variableIndex; private Func[] _cleanupTasks = Array.Empty>(); - public IQueryResultBuilder SetData(IReadOnlyDictionary? data) + public OperationResultBuilder SetData(IReadOnlyDictionary? data) { _data = data; _items = null; @@ -26,7 +28,7 @@ public IQueryResultBuilder SetData(IReadOnlyDictionary? data) return this; } - public IQueryResultBuilder SetItems(IReadOnlyList? items) + public OperationResultBuilder SetItems(IReadOnlyList? items) { _items = items; @@ -38,7 +40,7 @@ public IQueryResultBuilder SetItems(IReadOnlyList? items) return this; } - public IQueryResultBuilder AddError(IError error) + public OperationResultBuilder AddError(IError error) { if (error is null) { @@ -50,7 +52,7 @@ public IQueryResultBuilder AddError(IError error) return this; } - public IQueryResultBuilder AddErrors(IEnumerable errors) + public OperationResultBuilder AddErrors(IEnumerable errors) { if (errors is null) { @@ -62,21 +64,21 @@ public IQueryResultBuilder AddErrors(IEnumerable errors) return this; } - public IQueryResultBuilder AddExtension(string key, object? data) + public OperationResultBuilder AddExtension(string key, object? data) { _extensionData ??= new ExtensionData(); _extensionData.Add(key, data); return this; } - public IQueryResultBuilder SetExtension(string key, object? data) + public OperationResultBuilder SetExtension(string key, object? data) { _extensionData ??= new ExtensionData(); _extensionData[key] = data; return this; } - public IQueryResultBuilder SetExtensions(IReadOnlyDictionary? extensions) + public OperationResultBuilder SetExtensions(IReadOnlyDictionary? extensions) { if (extensions is ExtensionData extensionData) { @@ -93,21 +95,21 @@ public IQueryResultBuilder SetExtensions(IReadOnlyDictionary? e return this; } - public IQueryResultBuilder AddContextData(string key, object? data) + public OperationResultBuilder AddContextData(string key, object? data) { _contextData ??= new ExtensionData(); _contextData.Add(key, data); return this; } - public IQueryResultBuilder SetContextData(string key, object? data) + public OperationResultBuilder SetContextData(string key, object? data) { _contextData ??= new ExtensionData(); _contextData[key] = data; return this; } - public IQueryResultBuilder SetContextData(IReadOnlyDictionary? contextData) + public OperationResultBuilder SetContextData(IReadOnlyDictionary? contextData) { if (contextData is ExtensionData extensionData) { @@ -124,7 +126,7 @@ public IQueryResultBuilder SetContextData(IReadOnlyDictionary? return this; } - public IQueryResultBuilder AddPatch(IQueryResult patch) + public OperationResultBuilder AddPatch(IOperationResult patch) { if (patch is null) { @@ -136,25 +138,25 @@ public IQueryResultBuilder AddPatch(IQueryResult patch) return this; } - public IQueryResultBuilder SetLabel(string? label) + public OperationResultBuilder SetLabel(string? label) { _label = label; return this; } - public IQueryResultBuilder SetPath(Path? path) + public OperationResultBuilder SetPath(Path? path) { _path = path; return this; } - public IQueryResultBuilder SetHasNext(bool? hasNext) + public OperationResultBuilder SetHasNext(bool? hasNext) { _hasNext = hasNext; return this; } - public IQueryResultBuilder RegisterForCleanup(Func clean) + public OperationResultBuilder RegisterForCleanup(Func clean) { if (clean is null) { @@ -167,8 +169,8 @@ public IQueryResultBuilder RegisterForCleanup(Func clean) return this; } - public IQueryResult Create() - => new QueryResult( + public IOperationResult Build() + => new OperationResult( _data, _errors?.Count > 0 ? _errors : null, _extensionData?.Count > 0 ? _extensionData : null, @@ -179,13 +181,15 @@ public IQueryResult Create() _path, _hasNext, _cleanupTasks, - _isDataSet ?? false); + _isDataSet ?? false, + _requestIndex, + _variableIndex); - public static QueryResultBuilder New() => new(); + public static OperationResultBuilder New() => new(); - public static QueryResultBuilder FromResult(IQueryResult result) + public static OperationResultBuilder FromResult(IOperationResult result) { - var builder = new QueryResultBuilder { _data = result.Data, }; + var builder = new OperationResultBuilder { _data = result.Data, }; if (result.Errors is not null) { @@ -214,19 +218,21 @@ public static QueryResultBuilder FromResult(IQueryResult result) builder._path = result.Path; builder._hasNext = result.HasNext; builder._isDataSet = result.IsDataSet; + builder._requestIndex = result.RequestIndex; + builder._variableIndex = result.VariableIndex; return builder; } - public static IQueryResult CreateError( + public static IOperationResult CreateError( IError error, IReadOnlyDictionary? contextData = null) => error is AggregateError aggregateError ? CreateError(aggregateError.Errors, contextData) - : new QueryResult(null, new List { error, }, contextData: contextData); + : new OperationResult(null, new List { error, }, contextData: contextData); - public static IQueryResult CreateError( + public static IOperationResult CreateError( IReadOnlyList errors, IReadOnlyDictionary? contextData = null) - => new QueryResult(null, errors, contextData: contextData); + => new OperationResult(null, errors, contextData: contextData); } diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilderExtensions.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilderExtensions.cs new file mode 100644 index 00000000000..5d264b6296e --- /dev/null +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultBuilderExtensions.cs @@ -0,0 +1,88 @@ +using System; +using System.Security.Claims; + +namespace HotChocolate.Execution; + +/// +/// Extensions methods for . +/// +public static class OperationResultBuilderExtensions +{ + /// + /// Registers a cleanup task for execution resources with the . + /// + /// + /// The . + /// + /// + /// A cleanup task that will be executed when this result is disposed. + /// + public static void RegisterForCleanup(this OperationResultBuilder builder, Action clean) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (clean is null) + { + throw new ArgumentNullException(nameof(clean)); + } + + builder.RegisterForCleanup(() => + { + clean(); + return default; + }); + } + + /// + /// Registers a cleanup task for execution resources with the . + /// + /// + /// The . + /// + /// + /// The resource that needs to be disposed. + /// + public static void RegisterForCleanup(this OperationResultBuilder builder, IDisposable disposable) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (disposable is null) + { + throw new ArgumentNullException(nameof(disposable)); + } + + builder.RegisterForCleanup(disposable.Dispose); + } + + /// + /// Registers a cleanup task for execution resources with the . + /// + /// + /// The . + /// + /// + /// The resource that needs to be disposed. + /// + public static void RegisterForCleanup( + this OperationResultBuilder builder, + IAsyncDisposable disposable) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (disposable is null) + { + throw new ArgumentNullException(nameof(disposable)); + } + + builder.RegisterForCleanup(disposable.DisposeAsync); + } +} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryResultHelper.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultHelper.cs similarity index 97% rename from src/HotChocolate/Core/src/Abstractions/Execution/QueryResultHelper.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/OperationResultHelper.cs index 15ab50f550d..ed26616fc7f 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryResultHelper.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OperationResultHelper.cs @@ -2,7 +2,7 @@ namespace HotChocolate.Execution; -internal static class QueryResultHelper +internal static class OperationResultHelper { private const string _data = "data"; private const string _errors = "errors"; @@ -13,7 +13,7 @@ internal static class QueryResultHelper private const string _line = "line"; private const string _column = "column"; - public static IReadOnlyDictionary ToDictionary(IQueryResult result) + public static IReadOnlyDictionary ToDictionary(IOperationResult result) { var formatted = new OrderedDictionary(); diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/OrderedDictionary.cs b/src/HotChocolate/Core/src/Abstractions/Execution/OrderedDictionary.cs index a3f38d4e105..5d7a8137e45 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/OrderedDictionary.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/OrderedDictionary.cs @@ -4,9 +4,7 @@ namespace HotChocolate.Execution; -public class OrderedDictionary : OrderedDictionary -{ -} +public class OrderedDictionary : OrderedDictionary; public class OrderedDictionary : IDictionary diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryDocument.cs b/src/HotChocolate/Core/src/Abstractions/Execution/QueryDocument.cs deleted file mode 100644 index d4c527cabe0..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryDocument.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using HotChocolate.Language; -using HotChocolate.Language.Utilities; - -namespace HotChocolate.Execution; - -public class QueryDocument : IQuery -{ - public QueryDocument(DocumentNode document) - { - Document = document ?? throw new ArgumentNullException(nameof(document)); - } - - public DocumentNode Document { get; } - - public void WriteTo(Stream output) - { - using var sw = new StreamWriter(output); - sw.Write(Document.Print(false)); - sw.Flush(); - } - - public Task WriteToAsync(Stream output) => - WriteToAsync(output, CancellationToken.None); - - public async Task WriteToAsync( - Stream output, - CancellationToken cancellationToken) - { - await Document - .PrintToAsync(output, false, cancellationToken) - .ConfigureAwait(false); - } - - public ReadOnlySpan AsSpan() - { - using var stream = new MemoryStream(); - using var sw = new StreamWriter(stream); - - sw.Write(Document.Print(false)); - sw.Flush(); - - return stream.ToArray(); - } - - public override string ToString() => - Document.Print(true); -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryException.cs b/src/HotChocolate/Core/src/Abstractions/Execution/QueryException.cs deleted file mode 100644 index 976118c87ec..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryException.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; - -namespace HotChocolate.Execution; - -public class QueryException - : GraphQLException -{ - public QueryException(string message) - : base(message) - { - } - - public QueryException(IError error) - : base(error) - { - } - - public QueryException(params IError[] errors) - : base(errors) - { - - } - - public QueryException(IEnumerable errors) - : base(errors) - { - } -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilder.cs b/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilder.cs deleted file mode 100644 index d324ee04e29..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilder.cs +++ /dev/null @@ -1,375 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using HotChocolate.Language; -using HotChocolate.Properties; - -#nullable enable - -namespace HotChocolate.Execution; - -public class QueryRequestBuilder : IQueryRequestBuilder -{ - private IQuery? _query; - private string? _queryName; - private string? _queryHash; - private string? _operationName; - private IReadOnlyDictionary? _readOnlyVariableValues; - private Dictionary? _variableValues; - private IReadOnlyDictionary? _readOnlyContextData; - private Dictionary? _contextData; - private IReadOnlyDictionary? _readOnlyExtensions; - private Dictionary? _extensions; - private IServiceProvider? _services; - private GraphQLRequestFlags _flags = GraphQLRequestFlags.AllowAll; - - public IQueryRequestBuilder SetQuery(string sourceText) - { - if (string.IsNullOrEmpty(sourceText)) - { - throw new ArgumentException( - AbstractionResources.QueryRequestBuilder_QueryIsNullOrEmpty, - nameof(sourceText)); - } - - _query = new QuerySourceText(sourceText); - return this; - } - - public IQueryRequestBuilder SetQuery(DocumentNode document) - { - if (document is null) - { - throw new ArgumentNullException(nameof(document)); - } - - _query = new QueryDocument(document); - return this; - } - - public IQueryRequestBuilder SetQueryId(string? queryName) - { - _queryName = queryName; - return this; - } - - public IQueryRequestBuilder SetQueryHash(string? queryHash) - { - _queryHash = queryHash; - return this; - } - - public IQueryRequestBuilder SetOperation(string? operationName) - { - _operationName = operationName; - return this; - } - - public IQueryRequestBuilder SetServices( - IServiceProvider? services) - { - _services = services; - return this; - } - - public IQueryRequestBuilder TrySetServices( - IServiceProvider? services) - { - _services ??= services; - return this; - } - - public IQueryRequestBuilder SetFlags( - GraphQLRequestFlags flags) - { - _flags = flags; - return this; - } - - public IQueryRequestBuilder SetVariableValues( - Dictionary? variableValues) => - SetVariableValues((IDictionary?)variableValues); - - public IQueryRequestBuilder SetVariableValues( - IDictionary? variableValues) - { - _variableValues = variableValues is null - ? null - : new Dictionary(variableValues); - _readOnlyVariableValues = null; - return this; - } - - public IQueryRequestBuilder SetVariableValues( - IReadOnlyDictionary? variableValues) - { - _variableValues = null; - _readOnlyVariableValues = variableValues; - return this; - } - - public IQueryRequestBuilder SetVariableValue(string name, object? value) - { - InitializeVariables(); - - _variableValues![name] = value; - return this; - } - - public IQueryRequestBuilder AddVariableValue( - string name, object? value) - { - InitializeVariables(); - - _variableValues!.Add(name, value); - return this; - } - - public IQueryRequestBuilder TryAddVariableValue( - string name, object? value) - { - InitializeVariables(); - - if (!_variableValues!.ContainsKey(name)) - { - _variableValues.Add(name, value); - } - return this; - } - - /// - public IQueryRequestBuilder InitializeGlobalState( - Dictionary? initialState) - => InitializeGlobalState((IDictionary?)initialState); - - /// - public IQueryRequestBuilder InitializeGlobalState( - IDictionary? initialState) - { - _contextData = initialState is null - ? null - : new Dictionary(initialState); - _readOnlyContextData = null; - return this; - } - - /// - public IQueryRequestBuilder InitializeGlobalState( - IReadOnlyDictionary? initialState) - { - _contextData = null; - _readOnlyContextData = initialState; - return this; - } - - /// - public IQueryRequestBuilder SetGlobalState( - string name, object? value) - { - InitializeContextData(); - - _contextData![name] = value; - return this; - } - - /// - public IQueryRequestBuilder AddGlobalState( - string name, object? value) - { - InitializeContextData(); - - _contextData!.Add(name, value); - return this; - } - - /// - public IQueryRequestBuilder TryAddGlobalState( - string name, object? value) - { - InitializeContextData(); - - if (!_contextData!.ContainsKey(name)) - { - _contextData!.Add(name, value); - } - return this; - } - - /// - public IQueryRequestBuilder RemoveGlobalState(string name) - { - if (_readOnlyContextData is null && _contextData is null) - { - return this; - } - - InitializeContextData(); - - _contextData!.Remove(name); - return this; - } - - public IQueryRequestBuilder SetExtensions( - Dictionary? extensions) => - SetExtensions((IDictionary?)extensions); - - public IQueryRequestBuilder SetExtensions( - IDictionary? extensions) - { - _extensions = extensions is null - ? null - : new Dictionary(extensions); - _readOnlyExtensions = null; - return this; - } - - public IQueryRequestBuilder SetExtensions( - IReadOnlyDictionary? extensions) - { - _extensions = null; - _readOnlyExtensions = extensions; - return this; - } - - public IQueryRequestBuilder SetExtension(string name, object? value) - { - InitializeExtensions(); - - _extensions![name] = value; - return this; - } - - public IQueryRequestBuilder AddExtension( - string name, object? value) - { - InitializeExtensions(); - - _extensions!.Add(name, value); - return this; - } - - public IQueryRequestBuilder TryAddExtension( - string name, object? value) - { - InitializeExtensions(); - - if (!_extensions!.ContainsKey(name)) - { - _extensions.Add(name, value); - } - return this; - } - - public IQueryRequest Create() - => new QueryRequest - ( - query: _query, - queryId: _queryName, - queryHash: _queryHash, - operationName: _operationName, - variableValues: GetVariableValues(), - contextData: GetContextData(), - extensions: GetExtensions(), - services: _services, - flags: _flags - ); - - private IReadOnlyDictionary GetVariableValues() - { - return _variableValues ?? _readOnlyVariableValues!; - } - - private void InitializeVariables() - { - if (_variableValues is null) - { - _variableValues = _readOnlyVariableValues is null - ? new Dictionary() - : _readOnlyVariableValues.ToDictionary( - t => t.Key, t => t.Value); - _readOnlyVariableValues = null; - } - } - - private IReadOnlyDictionary? GetContextData() - { - return _contextData ?? _readOnlyContextData; - } - - private void InitializeContextData() - { - if (_contextData is null) - { - _contextData = _readOnlyContextData is null - ? new Dictionary() - : _readOnlyContextData.ToDictionary( - t => t.Key, t => t.Value); - _readOnlyContextData = null; - } - } - - private IReadOnlyDictionary? GetExtensions() - { - return _extensions ?? _readOnlyExtensions; - } - - private void InitializeExtensions() - { - if (_extensions is null) - { - _extensions = _readOnlyExtensions is null - ? new Dictionary() - : _readOnlyExtensions.ToDictionary( - t => t.Key, t => t.Value); - _readOnlyExtensions = null; - } - } - - public static IQueryRequest Create(string query) => - New().SetQuery(query).Create(); - - public static QueryRequestBuilder New() => new(); - - public static QueryRequestBuilder From(IQueryRequest request) - { - var builder = new QueryRequestBuilder - { - _query = request.Query, - _queryName = request.QueryId, - _queryHash = request.QueryHash, - _operationName = request.OperationName, - _readOnlyVariableValues = request.VariableValues, - _readOnlyContextData = request.ContextData, - _readOnlyExtensions = request.Extensions, - _services = request.Services, - _flags = request.Flags, - }; - - if (builder._query is null && builder._queryName is null) - { - throw new QueryRequestBuilderException( - AbstractionResources.QueryRequestBuilder_QueryIsNull); - } - - return builder; - } - - public static QueryRequestBuilder From(GraphQLRequest request) - { - var builder = New(); - - builder - .SetQueryId(request.QueryId) - .SetQueryHash(request.QueryHash) - .SetOperation(request.OperationName) - .SetVariableValues(request.Variables) - .SetExtensions(request.Extensions); - - if (request.Query is not null) - { - builder.SetQuery(request.Query); - } - - return builder; - } -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderException.cs b/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderException.cs deleted file mode 100644 index 63b65e63591..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderException.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace HotChocolate.Execution; - -public class QueryRequestBuilderException : Exception -{ - public QueryRequestBuilderException() { } - - public QueryRequestBuilderException(string message) - : base(message) { } - - public QueryRequestBuilderException(string message, Exception inner) - : base(message, inner) { } -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderExtensions.cs b/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderExtensions.cs deleted file mode 100644 index 789e50eeb38..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequestBuilderExtensions.cs +++ /dev/null @@ -1,173 +0,0 @@ -using System; -using System.Security.Claims; - -namespace HotChocolate.Execution; - -/// -/// Extensions methods for . -/// -public static class QueryRequestBuilderExtensions -{ - /// - /// Allows introspection usage in the current request. - /// - public static IQueryRequestBuilder AllowIntrospection( - this IQueryRequestBuilder builder) => - builder.SetGlobalState(WellKnownContextData.IntrospectionAllowed, null); - - /// - /// Sets the error message for when the introspection is not allowed. - /// - public static IQueryRequestBuilder SetIntrospectionNotAllowedMessage( - this IQueryRequestBuilder builder, - string message) - { - if (message is null) - { - throw new ArgumentNullException(nameof(message)); - } - - return builder.SetGlobalState(WellKnownContextData.IntrospectionMessage, message); - } - - /// - /// Sets the error message for when the introspection is not allowed. - /// - public static IQueryRequestBuilder SetIntrospectionNotAllowedMessage( - this IQueryRequestBuilder builder, - Func messageFactory) - { - if (messageFactory is null) - { - throw new ArgumentNullException(nameof(messageFactory)); - } - - return builder.SetGlobalState(WellKnownContextData.IntrospectionMessage, messageFactory); - } - - /// - /// Skips the operation complexity analysis of this request. - /// - public static IQueryRequestBuilder SkipComplexityAnalysis( - this IQueryRequestBuilder builder) => - builder.SetGlobalState(WellKnownContextData.SkipComplexityAnalysis, null); - - /// - /// Set allowed complexity for this request and override the global allowed complexity. - /// - public static IQueryRequestBuilder SetMaximumAllowedComplexity( - this IQueryRequestBuilder builder, - int maximumAllowedComplexity) => - builder.SetGlobalState( - WellKnownContextData.MaximumAllowedComplexity, - maximumAllowedComplexity); - - /// - /// Marks the current request to allow non-persisted queries. - /// - public static IQueryRequestBuilder AllowNonPersistedQuery( - this IQueryRequestBuilder builder) => - builder.SetGlobalState(WellKnownContextData.NonPersistedQueryAllowed, true); - - /// - /// Skips the request execution depth analysis. - /// - public static IQueryRequestBuilder SkipExecutionDepthAnalysis( - this IQueryRequestBuilder builder) => - builder.SetGlobalState(WellKnownContextData.SkipDepthAnalysis, null); - - /// - /// Set allowed execution depth for this request and override the - /// global allowed execution depth. - /// - public static IQueryRequestBuilder SetMaximumAllowedExecutionDepth( - this IQueryRequestBuilder builder, - int maximumAllowedDepth) => - builder.SetGlobalState(WellKnownContextData.MaxAllowedExecutionDepth, maximumAllowedDepth); - - /// - /// Sets the user for this request. - /// - public static IQueryRequestBuilder SetUser( - this IQueryRequestBuilder builder, - ClaimsPrincipal claimsPrincipal) => - builder.SetGlobalState(nameof(ClaimsPrincipal), claimsPrincipal); - - /// - /// Registers a cleanup task for execution resources with the . - /// - /// - /// The . - /// - /// - /// A cleanup task that will be executed when this result is disposed. - /// - public static void RegisterForCleanup(this IQueryResultBuilder builder, Action clean) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (clean is null) - { - throw new ArgumentNullException(nameof(clean)); - } - - builder.RegisterForCleanup(() => - { - clean(); - return default; - }); - } - - /// - /// Registers a cleanup task for execution resources with the . - /// - /// - /// The . - /// - /// - /// The resource that needs to be disposed. - /// - public static void RegisterForCleanup(this IQueryResultBuilder builder, IDisposable disposable) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (disposable is null) - { - throw new ArgumentNullException(nameof(disposable)); - } - - builder.RegisterForCleanup(disposable.Dispose); - } - - /// - /// Registers a cleanup task for execution resources with the . - /// - /// - /// The . - /// - /// - /// The resource that needs to be disposed. - /// - public static void RegisterForCleanup( - this IQueryResultBuilder builder, - IAsyncDisposable disposable) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (disposable is null) - { - throw new ArgumentNullException(nameof(disposable)); - } - - builder.RegisterForCleanup(disposable.DisposeAsync); - } -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QuerySourceText.cs b/src/HotChocolate/Core/src/Abstractions/Execution/QuerySourceText.cs deleted file mode 100644 index e2158f97a32..00000000000 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QuerySourceText.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace HotChocolate.Execution; - -public class QuerySourceText : IQuery -{ - private byte[]? _source; - - public QuerySourceText(string sourceText) - { - Text = sourceText ?? throw new ArgumentNullException(nameof(sourceText)); - } - - public string Text { get; } - - public void WriteTo(Stream output) - { - var writer = new StreamWriter(output, Encoding.UTF8); - writer.Write(Text); - writer.Flush(); - } - - public Task WriteToAsync(Stream output) => - WriteToAsync(output, CancellationToken.None); - - public async Task WriteToAsync( - Stream output, - CancellationToken cancellationToken) - { - var buffer = Encoding.UTF8.GetBytes(Text); - await output - .WriteAsync(buffer, 0, buffer.Length, cancellationToken) - .ConfigureAwait(false); - } - - public ReadOnlySpan AsSpan() - { - if (_source is null) - { - _source = Encoding.UTF8.GetBytes(Text); - } - return _source; - } - - public override string ToString() => Text; -} diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/ResponseStream.cs b/src/HotChocolate/Core/src/Abstractions/Execution/ResponseStream.cs index 46746723abe..33089d77778 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/ResponseStream.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/ResponseStream.cs @@ -3,17 +3,15 @@ using HotChocolate.Properties; using static HotChocolate.Execution.ExecutionResultKind; -#nullable enable - namespace HotChocolate.Execution; public sealed class ResponseStream : ExecutionResult, IResponseStream { - private readonly Func>? _resultStreamFactory; + private readonly Func>? _resultStreamFactory; private bool _isRead; public ResponseStream( - Func>? resultStreamFactory, + Func>? resultStreamFactory, ExecutionResultKind kind = SubscriptionResult, IReadOnlyDictionary? contextData = null) { @@ -34,7 +32,7 @@ public ResponseStream( public override IReadOnlyDictionary? ContextData { get; } - public IAsyncEnumerable ReadResultsAsync() + public IAsyncEnumerable ReadResultsAsync() { if (_resultStreamFactory is null) { diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/ExecutionTask.cs b/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/ExecutionTask.cs index b0d0d72f288..520f7bb48ba 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/ExecutionTask.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/ExecutionTask.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable enable - namespace HotChocolate.Execution; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTask.cs b/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTask.cs index 82a42ce8a1c..50658d65473 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTask.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTask.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable enable - namespace HotChocolate.Execution; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTaskContext.cs b/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTaskContext.cs index 0143de4416c..09422f414af 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTaskContext.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/Tasks/IExecutionTaskContext.cs @@ -1,7 +1,5 @@ using System; -#nullable enable - namespace HotChocolate.Execution; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequest.cs b/src/HotChocolate/Core/src/Abstractions/Execution/VariableBatchRequest.cs similarity index 54% rename from src/HotChocolate/Core/src/Abstractions/Execution/QueryRequest.cs rename to src/HotChocolate/Core/src/Abstractions/Execution/VariableBatchRequest.cs index 7ebf80d854e..79cffa2c5bc 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/QueryRequest.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/VariableBatchRequest.cs @@ -1,34 +1,31 @@ using System; using System.Collections.Generic; -using HotChocolate.Properties; - -#nullable enable +using static HotChocolate.Properties.AbstractionResources; namespace HotChocolate.Execution; /// -/// Representation of a GraphQL request. +/// Defines a GraphQL operation request that shall be executed as many times as there are variable sets. /// -public class QueryRequest : IQueryRequest +public sealed class VariableBatchRequest : IOperationRequest { /// - /// Initializes a new instance of . + /// Initializes a new instance of the class. /// - /// + /// /// A GraphQL request document. /// - /// + /// /// A GraphQL request document ID. /// - /// + /// /// A GraphQL request document hash. /// /// - /// A name of an operation in the GraphQL request document that shall be executed; - /// or, null if the document only contains a single operation. + /// A name of an operation in the GraphQL request document that shall be executed. /// /// - /// The variable values for the GraphQL request. + /// The list variable values for the GraphQL request. /// /// /// The GraphQL request extension data. @@ -42,68 +39,67 @@ public class QueryRequest : IQueryRequest /// /// The GraphQL request flags can be used to limit the execution engine capabilities. /// - /// - /// and are both null. + /// + /// and are both null. /// - public QueryRequest( - IQuery? query = null, - string? queryId = null, - string? queryHash = null, - string? operationName = null, - IReadOnlyDictionary? variableValues = null, - IReadOnlyDictionary? extensions = null, - IReadOnlyDictionary? contextData = null, - IServiceProvider? services = null, - GraphQLRequestFlags flags = GraphQLRequestFlags.AllowAll) + public VariableBatchRequest( + IOperationDocument? document, + OperationDocumentId? documentId, + string? documentHash, + string? operationName, + IReadOnlyList>? variableValues, + IReadOnlyDictionary? extensions, + IReadOnlyDictionary? contextData, + IServiceProvider? services, + GraphQLRequestFlags flags) { - if (query is null && queryId is null) + if (document is null && OperationDocumentId.IsNullOrEmpty(documentId)) { - throw new QueryRequestBuilderException( - AbstractionResources.QueryRequestBuilder_QueryIsNull); + throw new InvalidOperationException(OperationRequest_DocumentOrIdMustBeSet); } - - Query = query; - QueryId = queryId; - QueryHash = queryHash; + + Document = document; + DocumentId = documentId; + DocumentHash = documentHash; OperationName = operationName; VariableValues = variableValues; - ContextData = contextData; Extensions = extensions; + ContextData = contextData; Services = services; Flags = flags; } - + /// /// Gets the GraphQL request document. /// - public IQuery? Query { get; } + public IOperationDocument? Document { get; } /// /// Gets the GraphQL request document ID. /// - public string? QueryId { get; } + public OperationDocumentId? DocumentId { get; } /// - /// Gets the GraphQL request document hash. + /// Gets GraphQL request document hash. /// - public string? QueryHash { get; } + public string? DocumentHash { get; } /// - /// Gets the name of an operation in the GraphQL request document that shall be executed; + /// A name of an operation in the GraphQL request document that shall be executed; /// or, null if the document only contains a single operation. /// public string? OperationName { get; } - + /// - /// Gets the variable values for the GraphQL request. + /// Gets a list of variable values for the GraphQL request. /// - public IReadOnlyDictionary? VariableValues { get; } + public IReadOnlyList>? VariableValues { get; } /// /// Gets the GraphQL request extension data. /// public IReadOnlyDictionary? Extensions { get; } - + /// /// Gets the initial request state. /// @@ -115,7 +111,7 @@ public QueryRequest( public IServiceProvider? Services { get; } /// - /// Gets the GraphQL request flags can be used to limit the execution engine capabilities. + /// GraphQL request flags allow to limit the GraphQL executor capabilities. /// public GraphQLRequestFlags Flags { get; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/VariableValue.cs b/src/HotChocolate/Core/src/Abstractions/Execution/VariableValue.cs index 4214b9d1249..331b8df36cc 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/VariableValue.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/VariableValue.cs @@ -8,27 +8,20 @@ namespace HotChocolate.Execution; /// /// Represents a variable value. /// -public readonly struct VariableValue +public readonly struct VariableValue(string name, IInputType type, IValueNode value) { - public VariableValue(string name, IInputType type, IValueNode value) - { - Name = name.EnsureGraphQLName(); - Type = type ?? throw new ArgumentNullException(nameof(type)); - Value = value ?? throw new ArgumentNullException(nameof(value)); - } - /// /// Gets the variable name. /// - public string Name { get; } + public string Name { get; } = name.EnsureGraphQLName(); /// /// Gets the variable type. /// - public IInputType Type { get; } + public IInputType Type { get; } = type ?? throw new ArgumentNullException(nameof(type)); /// /// Gets the variable value. /// - public IValueNode Value { get; } + public IValueNode Value { get; } = value ?? throw new ArgumentNullException(nameof(value)); } diff --git a/src/HotChocolate/Core/src/Abstractions/ExtensionData.cs b/src/HotChocolate/Core/src/Abstractions/ExtensionData.cs index e6d1bc1a27e..371c1c8c025 100644 --- a/src/HotChocolate/Core/src/Abstractions/ExtensionData.cs +++ b/src/HotChocolate/Core/src/Abstractions/ExtensionData.cs @@ -4,8 +4,6 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -#nullable enable - namespace HotChocolate; public sealed class ExtensionData diff --git a/src/HotChocolate/Core/src/Abstractions/FieldCoordinate.cs b/src/HotChocolate/Core/src/Abstractions/FieldCoordinate.cs index 2879d989402..53d5c089fd7 100644 --- a/src/HotChocolate/Core/src/Abstractions/FieldCoordinate.cs +++ b/src/HotChocolate/Core/src/Abstractions/FieldCoordinate.cs @@ -3,8 +3,6 @@ using HotChocolate.Utilities; using static System.StringComparison; -#nullable enable - namespace HotChocolate; /// diff --git a/src/HotChocolate/Core/src/Abstractions/GraphQLNonNullTypeAttribute.cs b/src/HotChocolate/Core/src/Abstractions/GraphQLNonNullTypeAttribute.cs index f21369c4240..42ed7efd098 100644 --- a/src/HotChocolate/Core/src/Abstractions/GraphQLNonNullTypeAttribute.cs +++ b/src/HotChocolate/Core/src/Abstractions/GraphQLNonNullTypeAttribute.cs @@ -1,7 +1,5 @@ using System; -#nullable enable - namespace HotChocolate; [AttributeUsage( diff --git a/src/HotChocolate/Core/src/Abstractions/HotChocolate.Abstractions.csproj b/src/HotChocolate/Core/src/Abstractions/HotChocolate.Abstractions.csproj index 3694230e761..2c5bc7f60db 100644 --- a/src/HotChocolate/Core/src/Abstractions/HotChocolate.Abstractions.csproj +++ b/src/HotChocolate/Core/src/Abstractions/HotChocolate.Abstractions.csproj @@ -31,9 +31,6 @@ True AbstractionResources.resx - - IQueryResult.cs - Path.cs diff --git a/src/HotChocolate/Core/src/Abstractions/IErrorBuilder.cs b/src/HotChocolate/Core/src/Abstractions/IErrorBuilder.cs index 4bd35025e62..23807ba9f4b 100644 --- a/src/HotChocolate/Core/src/Abstractions/IErrorBuilder.cs +++ b/src/HotChocolate/Core/src/Abstractions/IErrorBuilder.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using HotChocolate.Language; -#nullable enable - namespace HotChocolate; public interface IErrorBuilder diff --git a/src/HotChocolate/Core/src/Abstractions/IExecutable.cs b/src/HotChocolate/Core/src/Abstractions/IExecutable.cs index 45d696aa70d..cc803b56ab0 100644 --- a/src/HotChocolate/Core/src/Abstractions/IExecutable.cs +++ b/src/HotChocolate/Core/src/Abstractions/IExecutable.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable enable - namespace HotChocolate; /// diff --git a/src/HotChocolate/Core/src/Abstractions/IHasContextData.cs b/src/HotChocolate/Core/src/Abstractions/IHasContextData.cs index 83b850f93ad..09f1cd84c55 100644 --- a/src/HotChocolate/Core/src/Abstractions/IHasContextData.cs +++ b/src/HotChocolate/Core/src/Abstractions/IHasContextData.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable enable - namespace HotChocolate; /// diff --git a/src/HotChocolate/Core/src/Abstractions/IHasReadOnlyContextData.cs b/src/HotChocolate/Core/src/Abstractions/IHasReadOnlyContextData.cs index 65eca5a0878..2848729de37 100644 --- a/src/HotChocolate/Core/src/Abstractions/IHasReadOnlyContextData.cs +++ b/src/HotChocolate/Core/src/Abstractions/IHasReadOnlyContextData.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable enable - namespace HotChocolate; public interface IHasReadOnlyContextData diff --git a/src/HotChocolate/Core/src/Abstractions/IOptional.cs b/src/HotChocolate/Core/src/Abstractions/IOptional.cs index 8a2f8108894..509a3e65a04 100644 --- a/src/HotChocolate/Core/src/Abstractions/IOptional.cs +++ b/src/HotChocolate/Core/src/Abstractions/IOptional.cs @@ -1,5 +1,3 @@ -#nullable enable - namespace HotChocolate; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Optional.cs b/src/HotChocolate/Core/src/Abstractions/Optional.cs index de60314bc82..67abe4467b0 100644 --- a/src/HotChocolate/Core/src/Abstractions/Optional.cs +++ b/src/HotChocolate/Core/src/Abstractions/Optional.cs @@ -1,8 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; -#nullable enable - namespace HotChocolate; /// diff --git a/src/HotChocolate/Core/src/Abstractions/Path.cs b/src/HotChocolate/Core/src/Abstractions/Path.cs index 7b91338363e..dd9e0f92ce9 100644 --- a/src/HotChocolate/Core/src/Abstractions/Path.cs +++ b/src/HotChocolate/Core/src/Abstractions/Path.cs @@ -1,5 +1,3 @@ -#nullable enable - using System; using System.Collections.Generic; using System.Text; diff --git a/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.Designer.cs b/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.Designer.cs index 7a7e5d57ffe..19d53179ee1 100644 --- a/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.Designer.cs +++ b/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.Designer.cs @@ -57,15 +57,15 @@ internal static string Name_MustNotBeEmpty { } } - internal static string QueryRequestBuilder_QueryIsNull { + internal static string OperationRequestBuilder_QueryIsNull { get { - return ResourceManager.GetString("QueryRequestBuilder_QueryIsNull", resourceCulture); + return ResourceManager.GetString("OperationRequestBuilder_QueryIsNull", resourceCulture); } } - internal static string QueryRequestBuilder_QueryIsNullOrEmpty { + internal static string OperationRequestBuilder_OperationIsNullOrEmpty { get { - return ResourceManager.GetString("QueryRequestBuilder_QueryIsNullOrEmpty", resourceCulture); + return ResourceManager.GetString("OperationRequestBuilder_OperationIsNullOrEmpty", resourceCulture); } } @@ -266,5 +266,23 @@ internal static string MutationError_ErrorsEmpty { return ResourceManager.GetString("MutationError_ErrorsEmpty", resourceCulture); } } + + internal static string OperationDocumentId_InvalidOperationIdFormat { + get { + return ResourceManager.GetString("OperationDocumentId_InvalidOperationIdFormat", resourceCulture); + } + } + + internal static string OperationRequest_DocumentOrIdMustBeSet { + get { + return ResourceManager.GetString("OperationRequest_DocumentOrIdMustBeSet", resourceCulture); + } + } + + internal static string OperationResultBatch_ResponseStreamOrOperationResult { + get { + return ResourceManager.GetString("OperationResultBatch_ResponseStreamOrOperationResult", resourceCulture); + } + } } } diff --git a/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.resx b/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.resx index 3f792626901..34ef7ae83c2 100644 --- a/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.resx +++ b/src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.resx @@ -123,11 +123,11 @@ The specified name mustn't be empty. - + You must specify a query before creating a query request. - - The query mustn't be null or empty. + + The operation source text mustn't be null or empty. The state key mustn't null or empty. @@ -228,4 +228,13 @@ There must be at least one error in the errors list. + + Invalid operation id format. + + + A GraphQL operation document or a document id is required to create a query request. + + + The result must be either an operation result or a response stream. + diff --git a/src/HotChocolate/Core/src/Abstractions/ScopedStateAttribute.cs b/src/HotChocolate/Core/src/Abstractions/ScopedStateAttribute.cs index 3aed0738f8c..3e77f3bdc64 100644 --- a/src/HotChocolate/Core/src/Abstractions/ScopedStateAttribute.cs +++ b/src/HotChocolate/Core/src/Abstractions/ScopedStateAttribute.cs @@ -1,7 +1,5 @@ using System; -#nullable enable - namespace HotChocolate; [AttributeUsage(AttributeTargets.Parameter)] diff --git a/src/HotChocolate/Core/src/Abstractions/SingleValueExtensionData.cs b/src/HotChocolate/Core/src/Abstractions/SingleValueExtensionData.cs index 3fe2f965e7b..c6d991edb60 100644 --- a/src/HotChocolate/Core/src/Abstractions/SingleValueExtensionData.cs +++ b/src/HotChocolate/Core/src/Abstractions/SingleValueExtensionData.cs @@ -1,5 +1,3 @@ -#nullable enable - using System; using System.Collections; using System.Collections.Generic; @@ -9,7 +7,7 @@ namespace HotChocolate; /// -/// An optimized extension data dictionary for or +/// An optimized extension data dictionary for or /// when only one value is needed. /// public sealed class SingleValueExtensionData : IReadOnlyDictionary diff --git a/src/HotChocolate/Core/src/Abstractions/WellKnownDirectives.cs b/src/HotChocolate/Core/src/Abstractions/WellKnownDirectives.cs index 7939a6d8da4..e7980b8cb62 100644 --- a/src/HotChocolate/Core/src/Abstractions/WellKnownDirectives.cs +++ b/src/HotChocolate/Core/src/Abstractions/WellKnownDirectives.cs @@ -69,8 +69,4 @@ public static class WellKnownDirectives /// The name of the @tag argument name. /// public const string Name = "name"; - - public const string NullBubbling = "nullBubbling"; - - public const string Enable = "enable"; } diff --git a/src/HotChocolate/Core/src/Authorization/AuthorizeValidationResultAggregator.cs b/src/HotChocolate/Core/src/Authorization/AuthorizeValidationResultAggregator.cs index ea554378749..fd3791d689a 100644 --- a/src/HotChocolate/Core/src/Authorization/AuthorizeValidationResultAggregator.cs +++ b/src/HotChocolate/Core/src/Authorization/AuthorizeValidationResultAggregator.cs @@ -40,7 +40,7 @@ public async ValueTask AggregateAsync( _services, context.ContextData, document, - context.DocumentId); + context.DocumentId.Value); var result = await handler.AuthorizeAsync(ctx, directives, ct).ConfigureAwait(false); diff --git a/src/HotChocolate/Core/src/Authorization/AuthorizeValidationRule.cs b/src/HotChocolate/Core/src/Authorization/AuthorizeValidationRule.cs index cfe8bb0f4a5..25536f0875c 100644 --- a/src/HotChocolate/Core/src/Authorization/AuthorizeValidationRule.cs +++ b/src/HotChocolate/Core/src/Authorization/AuthorizeValidationRule.cs @@ -6,15 +6,10 @@ namespace HotChocolate.Authorization; -internal sealed class AuthorizeValidationRule : IDocumentValidatorRule +internal sealed class AuthorizeValidationRule(AuthorizationCache cache) : IDocumentValidatorRule { private readonly AuthorizeValidationVisitor _visitor = new(); - private readonly AuthorizationCache _cache; - - public AuthorizeValidationRule(AuthorizationCache cache) - { - _cache = cache ?? throw new ArgumentNullException(nameof(cache)); - } + private readonly AuthorizationCache _cache = cache ?? throw new ArgumentNullException(nameof(cache)); public bool IsCacheable => false; @@ -22,12 +17,12 @@ public void Validate(IDocumentValidatorContext context, DocumentNode document) { if (context.Schema.ContextData.ContainsKey(WellKnownContextData.AuthorizationRequestPolicy)) { - if (!_cache.TryGetDirectives(context.DocumentId, out var directives)) + if (!_cache.TryGetDirectives(context.DocumentId.Value, out var directives)) { _visitor.Visit(document, context); directives = ((HashSet) context.ContextData[AuthContextData.Directives]!).ToArray(); - _cache.TryAddDirectives(context.DocumentId, directives); + _cache.TryAddDirectives(context.DocumentId.Value, directives); } // update context data with the array result. diff --git a/src/HotChocolate/Core/src/Execution/AutoUpdateRequestExecutorProxy.cs b/src/HotChocolate/Core/src/Execution/AutoUpdateRequestExecutorProxy.cs index e7fec64a91f..f6cde0fcb3e 100644 --- a/src/HotChocolate/Core/src/Execution/AutoUpdateRequestExecutorProxy.cs +++ b/src/HotChocolate/Core/src/Execution/AutoUpdateRequestExecutorProxy.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -16,7 +15,7 @@ public class AutoUpdateRequestExecutorProxy : IRequestExecutor, IDisposable private readonly RequestExecutorProxy _executorProxy; private IRequestExecutor _executor; private bool _disposed; - + private AutoUpdateRequestExecutorProxy( RequestExecutorProxy requestExecutorProxy, IRequestExecutor initialExecutor) @@ -114,21 +113,21 @@ public static AutoUpdateRequestExecutorProxy Create( /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result - /// that the yields is a . + /// that the yields is a . /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// public Task ExecuteAsync( - IQueryRequest request, - CancellationToken cancellationToken = default) => - _executor.ExecuteAsync(request, cancellationToken); + IOperationRequest request, + CancellationToken cancellationToken = default) + => _executor.ExecuteAsync(request, cancellationToken); /// /// Executes the given GraphQL . @@ -143,12 +142,12 @@ public Task ExecuteAsync( /// Returns a stream of query results. /// public Task ExecuteBatchAsync( - IReadOnlyList requestBatch, - CancellationToken cancellationToken = default) => - _executor.ExecuteBatchAsync(requestBatch, cancellationToken); + OperationRequestBatch requestBatch, + CancellationToken cancellationToken = default) + => _executor.ExecuteBatchAsync(requestBatch, cancellationToken); - private void BeginUpdateExecutor() => - Task.Run(UpdateExecutorAsync); + private void BeginUpdateExecutor() + => Task.Run(UpdateExecutorAsync); private async ValueTask UpdateExecutorAsync() { diff --git a/src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.Enumerable.cs b/src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.Enumerable.cs deleted file mode 100644 index dd4cce77e2e..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.Enumerable.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using HotChocolate.Execution.Processing; -using HotChocolate.Language; -using HotChocolate.Types; -using HotChocolate.Utilities; -using static HotChocolate.Execution.ThrowHelper; - -namespace HotChocolate.Execution.Batching; - -internal partial class BatchExecutor -{ - private sealed class BatchExecutorEnumerable : IAsyncEnumerable - { - private readonly IReadOnlyList _requestBatch; - private readonly RequestExecutor _requestExecutor; - private readonly IErrorHandler _errorHandler; - private readonly ITypeConverter _typeConverter; - private readonly InputFormatter _inputFormatter; - private readonly ConcurrentBag _exportedVariables = []; - private readonly CollectVariablesVisitor _visitor; - private readonly CollectVariablesVisitationMap _visitationMap = new(); - private DocumentNode? _previous; - private Dictionary? _fragments; - - public BatchExecutorEnumerable( - IReadOnlyList requestBatch, - RequestExecutor requestExecutor, - IErrorHandler errorHandler, - ITypeConverter typeConverter, - InputFormatter inputFormatter) - { - _requestBatch = requestBatch ?? - throw new ArgumentNullException(nameof(requestBatch)); - _requestExecutor = requestExecutor ?? - throw new ArgumentNullException(nameof(requestExecutor)); - _errorHandler = errorHandler ?? - throw new ArgumentNullException(nameof(errorHandler)); - _typeConverter = typeConverter ?? - throw new ArgumentNullException(nameof(typeConverter)); - _inputFormatter = inputFormatter ?? - throw new ArgumentNullException(nameof(inputFormatter)); - _visitor = new CollectVariablesVisitor(requestExecutor.Schema); - } - - public async IAsyncEnumerator GetAsyncEnumerator( - CancellationToken cancellationToken = default) - { - for (var i = 0; i < _requestBatch.Count; i++) - { - var result = await ExecuteNextAsync( - _requestBatch[i], - cancellationToken) - .ConfigureAwait(false); - - yield return result; - - if (result.Data is null) - { - break; - } - } - } - - private async Task ExecuteNextAsync( - IQueryRequest request, - CancellationToken cancellationToken) - { - try - { - var document = request.Query is QueryDocument d - ? d.Document - : Utf8GraphQLParser.Parse(request.Query!.AsSpan()); - - var operation = - document.GetOperation(request.OperationName); - - if (document != _previous) - { - _fragments = document.GetFragments(); - _visitationMap.Initialize(_fragments); - } - - operation.Accept(_visitor, _visitationMap, _ => VisitorAction.Continue); - - _previous = document; - document = RewriteDocument(operation); - operation = (OperationDefinitionNode)document.Definitions[0]; - var variableValues = MergeVariables(request.VariableValues, operation); - - request = QueryRequestBuilder.From(request) - .SetQuery(document) - .SetVariableValues(variableValues) - .AddExportedVariables(_exportedVariables) - .SetQueryId(null) - .SetQueryHash(null) - .Create(); - - var result = await _requestExecutor - .ExecuteAsync(request, false, cancellationToken) - .ConfigureAwait(false); - return result.ExpectQueryResult(); - } - catch (GraphQLException ex) - { - return QueryResultBuilder.CreateError(ex.Errors); - } - catch (Exception ex) - { - return QueryResultBuilder.CreateError( - _errorHandler.Handle( - _errorHandler.CreateUnexpectedError(ex).Build())); - } - } - - private DocumentNode RewriteDocument( - OperationDefinitionNode operation) - { - var definitions = new List(); - - var variables = operation.VariableDefinitions.ToList(); - variables.AddRange(_visitor.VariableDeclarations); - operation = operation.WithVariableDefinitions(variables); - definitions.Add(operation); - - foreach (var fragmentName in _visitor.TouchedFragments) - { - definitions.Add(_fragments![fragmentName]); - } - - return new DocumentNode(definitions); - } - - private IReadOnlyDictionary? MergeVariables( - IReadOnlyDictionary? variables, - OperationDefinitionNode operation) - { - if (_exportedVariables.Count == 0) - { - return variables; - } - - var exported = _exportedVariables.ToLookup(t => t.Name); - var merged = new Dictionary(); - - foreach (var variableDefinition in operation.VariableDefinitions) - { - var variableName = variableDefinition.Variable.Name.Value; - - if (!exported[variableName].Any()) - { - if (variables != null && variables.TryGetValue(variableName, out var value)) - { - merged[variableName] = value; - } - } - else if (variableDefinition.Type.IsListType()) - { - var list = new List(); - - if (variables != null && variables.TryGetValue(variableName, out var value)) - { - if (value is IReadOnlyCollection l) - { - list.AddRange(l); - } - else - { - list.Add(value); - } - } - - foreach (var variable in exported[variableName]) - { - SerializeListValue(variable, variableDefinition.Type, list); - } - - merged[variableName] = list; - } - else - { - if (variables != null && variables.TryGetValue(variableName, out var value)) - { - merged[variableName] = value; - } - else - { - merged[variableName] = Serialize( - exported[variableName].First(), - variableDefinition.Type); - } - } - - } - - return merged; - } - - private object Serialize(ExportedVariable exported, ITypeNode type) - { - if (_requestExecutor.Schema.TryGetType( - type.NamedType().Name.Value, - out var inputType) - && _typeConverter.TryConvert( - inputType!.RuntimeType, - exported.Value, - out var converted)) - { - return _inputFormatter.FormatResult(converted, inputType, Path.Root); - } - - throw BatchExecutor_CannotSerializeVariable(exported.Name); - } - - private void SerializeListValue( - ExportedVariable exported, - ITypeNode type, - ICollection list) - { - if (_requestExecutor.Schema.TryGetType( - type.NamedType().Name.Value, - out var inputType)) - { - SerializeListValue(exported, inputType, list); - } - else - { - throw BatchExecutor_CannotSerializeVariable(exported.Name); - } - } - - private void SerializeListValue( - ExportedVariable exported, - INamedInputType inputType, - ICollection list) - { - var runtimeType = inputType.RuntimeType; - - if (exported.Type.IsListType() - && exported.Value is IEnumerable l) - { - foreach (var o in l) - { - if (_typeConverter.TryConvert(runtimeType, o, out var converted)) - { - list.Add(_inputFormatter.FormatResult(converted, inputType, Path.Root)); - } - else - { - throw BatchExecutor_CannotSerializeVariable(exported.Name); - } - } - } - else - { - if (_typeConverter.TryConvert(runtimeType, exported.Value, out var converted)) - { - list.Add(_inputFormatter.FormatResult(converted, inputType, Path.Root)); - } - else - { - throw BatchExecutor_CannotSerializeVariable(exported.Name); - } - } - } - } -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.cs b/src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.cs deleted file mode 100644 index 8a6f60c739c..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/BatchExecutor.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using HotChocolate.Types; -using HotChocolate.Utilities; - -namespace HotChocolate.Execution.Batching; - -internal partial class BatchExecutor -{ - private readonly IErrorHandler _errorHandler; - private readonly ITypeConverter _typeConverter; - private readonly InputFormatter _inputFormatter; - - public BatchExecutor( - IErrorHandler errorHandler, - ITypeConverter typeConverter, - InputFormatter inputFormatter) - { - _errorHandler = errorHandler ?? - throw new ArgumentNullException(nameof(errorHandler)); - _typeConverter = typeConverter ?? - throw new ArgumentNullException(nameof(typeConverter)); - _inputFormatter = inputFormatter ?? - throw new ArgumentNullException(nameof(inputFormatter)); - } - - public IAsyncEnumerable ExecuteAsync( - RequestExecutor requestExecutor, - IReadOnlyList requestBatch) - => new BatchExecutorEnumerable( - requestBatch, - requestExecutor, - _errorHandler, - _typeConverter, - _inputFormatter); -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitationMap.cs b/src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitationMap.cs deleted file mode 100644 index aa13cea59c4..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitationMap.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using HotChocolate.Language; - -namespace HotChocolate.Execution.Batching; - -public sealed class CollectVariablesVisitationMap - : VisitationMap -{ - private IReadOnlyDictionary? _fragments = null; - - public void Initialize(IReadOnlyDictionary fragments) - { - _fragments = fragments ?? - throw new ArgumentNullException(nameof(fragments)); - } - - protected override void ResolveChildren( - OperationDefinitionNode node, - IList children) - { - ResolveChildren( - nameof(node.SelectionSet), - node.SelectionSet, - children); - } - - protected override void ResolveChildren( - VariableNode node, - IList children) - { - // we do not want to visit any nodes. - } - - protected override void ResolveChildren( - FieldNode node, - IList children) - { - if (node.Arguments.Count != 0) - { - ResolveChildren( - nameof(node.Arguments), - node.Arguments, - children); - } - - if (node.SelectionSet != null) - { - ResolveChildren( - nameof(node.SelectionSet), - node.SelectionSet, - children); - } - } - - protected override void ResolveChildren( - ArgumentNode node, - IList children) - { - ResolveChildren( - nameof(node.Value), - node.Value, - children); - } - - protected override void ResolveChildren( - FragmentSpreadNode node, - IList children) - { - if (_fragments is not null && - _fragments.TryGetValue(node.Name.Value, out var d)) - { - ResolveChildren( - d.Name.Value, - d, - children); - } - } - - protected override void ResolveChildren( - InlineFragmentNode node, - IList children) - { - ResolveChildren( - nameof(node.SelectionSet), - node.SelectionSet, - children); - } - - protected override void ResolveChildren( - FragmentDefinitionNode node, - IList children) - { - ResolveChildren( - nameof(node.SelectionSet), - node.SelectionSet, - children); - } -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitor.cs b/src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitor.cs deleted file mode 100644 index 01956b4fae7..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/CollectVariablesVisitor.cs +++ /dev/null @@ -1,327 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using HotChocolate.Language; -using HotChocolate.Types; -using static HotChocolate.Execution.ThrowHelper; - -namespace HotChocolate.Execution.Batching; - -internal class CollectVariablesVisitor - : ISyntaxNodeVisitor - , ISyntaxNodeVisitor - , ISyntaxNodeVisitor - , ISyntaxNodeVisitor - , ISyntaxNodeVisitor - , ISyntaxNodeVisitor - , ISyntaxNodeVisitor - , ISyntaxNodeVisitor -{ - private readonly Dictionary _variables = - new Dictionary(); - private readonly HashSet _declared = []; - private readonly Stack _type = new Stack(); - private readonly Stack _field = - new Stack(); - private readonly Stack _action = - new Stack(); - private readonly HashSet _touchedFragments = - []; - private readonly ISchema _schema; - - public CollectVariablesVisitor(ISchema schema) - { - _schema = schema ?? throw new ArgumentNullException(nameof(schema)); - } - - public IReadOnlyCollection - VariableDeclarations => - _variables.Values; - public IReadOnlyCollection TouchedFragments => - _touchedFragments; - - public VisitorAction Enter( - OperationDefinitionNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - _variables.Clear(); - _field.Clear(); - _type.Clear(); - _action.Clear(); - _touchedFragments.Clear(); - - var type = _schema.GetOperationType(node.Operation)!; - _type.Push(type); - - for (var i = 0; i < node.VariableDefinitions.Count; i++) - { - _declared.Add( - node.VariableDefinitions[i].Variable.Name.Value); - } - - return VisitorAction.Continue; - } - - public VisitorAction Leave( - OperationDefinitionNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - _type.Pop(); - return VisitorAction.Continue; - } - - public VisitorAction Enter( - FieldNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_type.Peek().NamedType() is IComplexOutputType complexType - && complexType.Fields.TryGetField( - node.Name.Value, out var field)) - { - _field.Push(field); - _type.Push(field.Type); - _action.Push(VisitorAction.Continue); - return VisitorAction.Continue; - } - - _action.Push(VisitorAction.Skip); - return VisitorAction.Skip; - } - - public VisitorAction Leave( - FieldNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_action.Pop() == VisitorAction.Continue) - { - _type.Pop(); - _field.Pop(); - } - return VisitorAction.Continue; - } - - public VisitorAction Enter( - ArgumentNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_field.Peek().Arguments.TryGetField( - node.Name.Value, - out var field)) - { - _type.Push(field.Type); - _action.Push(VisitorAction.Continue); - return VisitorAction.Continue; - } - - _action.Push(VisitorAction.Skip); - return VisitorAction.Skip; - } - - public VisitorAction Leave( - ArgumentNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_action.Pop() == VisitorAction.Continue) - { - _type.Pop(); - } - return VisitorAction.Continue; - } - - public VisitorAction Enter( - ObjectFieldNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_type.Peek().NamedType() is InputObjectType inputObject - && inputObject.Fields.TryGetField( - node.Name.Value, - out IInputField? field)) - { - _type.Push(field.Type); - _action.Push(VisitorAction.Continue); - return VisitorAction.Continue; - } - - _action.Push(VisitorAction.Skip); - return VisitorAction.Skip; - } - - public VisitorAction Leave( - ObjectFieldNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_action.Pop() == VisitorAction.Continue) - { - _type.Pop(); - } - return VisitorAction.Continue; - } - - public VisitorAction Enter( - VariableNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (!_declared.Contains(node.Name.Value)) - { - var type = _type.Peek(); - - if (_variables.TryGetValue( - node.Name.Value, - out var d)) - { - if (type.IsNonNullType() - && d.Type is INullableTypeNode nullable) - { - _variables[node.Name.Value] = - d.WithType(new NonNullTypeNode(nullable)); - } - } - else - { - if (type.NamedType() is IComplexOutputType complexType) - { - var clrType = complexType.ToRuntimeType(); - var inputType = - _schema.Types.OfType() - .First(t => t.RuntimeType == clrType); - - if (inputType is null) - { - throw CollectVariablesVisitor_NoCompatibleType(node, path); - } - - d = new VariableDefinitionNode - ( - null, - node, - type.ToTypeNode(inputType), - null, - Array.Empty() - ); - } - else - { - d = new VariableDefinitionNode - ( - null, - node, - type.ToTypeNode(), - null, - Array.Empty() - ); - } - - _variables[node.Name.Value] = d; - } - } - - return VisitorAction.Continue; - } - - public VisitorAction Leave( - VariableNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - return VisitorAction.Skip; - } - - public VisitorAction Enter( - InlineFragmentNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (node.TypeCondition is not null && - _schema.TryGetType(node.TypeCondition.Name.Value, out var type)) - { - _type.Push(type); - _action.Push(VisitorAction.Continue); - return VisitorAction.Continue; - } - - _action.Push(VisitorAction.Skip); - return VisitorAction.Skip; - } - - public VisitorAction Leave( - InlineFragmentNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_action.Pop() == VisitorAction.Continue) - { - _type.Pop(); - } - return VisitorAction.Continue; - } - - public VisitorAction Enter( - FragmentDefinitionNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_schema.TryGetType(node.TypeCondition.Name.Value, out var type)) - { - _touchedFragments.Add(node.Name.Value); - _type.Push(type); - _action.Push(VisitorAction.Continue); - return VisitorAction.Continue; - } - - _action.Push(VisitorAction.Skip); - return VisitorAction.Skip; - } - - public VisitorAction Leave( - FragmentDefinitionNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - if (_action.Pop() == VisitorAction.Continue) - { - _type.Pop(); - } - return VisitorAction.Continue; - } - - public VisitorAction Enter( - FragmentSpreadNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - return VisitorAction.Continue; - } - - public VisitorAction Leave( - FragmentSpreadNode node, - ISyntaxNode parent, - IReadOnlyList path, - IReadOnlyList ancestors) - { - return VisitorAction.Continue; - } -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/ExportDirective.cs b/src/HotChocolate/Core/src/Execution/Batching/ExportDirective.cs deleted file mode 100644 index ebb0a47d555..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/ExportDirective.cs +++ /dev/null @@ -1,7 +0,0 @@ - -namespace HotChocolate.Execution.Batching; - -public sealed class ExportDirective -{ - public string? As { get; set; } -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveHelper.cs b/src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveHelper.cs deleted file mode 100644 index da458fabf61..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveHelper.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Concurrent; -using HotChocolate.Resolvers; - -namespace HotChocolate.Execution.Batching; - -internal static class ExportDirectiveHelper -{ - public const string Name = "export"; - public const string ExportedVariables = "HC.ExportedVariables"; - - public static T AddExportedVariables( - this T builder, - ConcurrentBag exportedVariables) - where T : IQueryRequestBuilder - { - builder.SetGlobalState(ExportedVariables, exportedVariables); - return builder; - } - - public static void ExportValueAsVariable( - this IMiddlewareContext context, - ExportDirective directive) - { - if (context.ContextData.TryGetValue(ExportedVariables, out var o) - && o is ConcurrentBag exp) - { - exp.Add(new ExportedVariable( - directive.As ?? context.Selection.Field.Name, - context.Selection.Type, - context.Result)); - } - } -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveType.cs b/src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveType.cs deleted file mode 100644 index 527b7de16b1..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/ExportDirectiveType.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HotChocolate.Types; - -namespace HotChocolate.Execution.Batching; - -public sealed class ExportDirectiveType : DirectiveType -{ - protected override void Configure(IDirectiveTypeDescriptor descriptor) - { - descriptor.Name(ExportDirectiveHelper.Name); - descriptor.Location(DirectiveLocation.Field); - - descriptor.Argument(t => t.As).Type(); - - descriptor.Use((next, directive) => async context => - { - await next(context).ConfigureAwait(false); - context.ExportValueAsVariable(directive.AsValue()); - }); - } -} diff --git a/src/HotChocolate/Core/src/Execution/Batching/ExportedVariable.cs b/src/HotChocolate/Core/src/Execution/Batching/ExportedVariable.cs deleted file mode 100644 index c950b8dfde5..00000000000 --- a/src/HotChocolate/Core/src/Execution/Batching/ExportedVariable.cs +++ /dev/null @@ -1,22 +0,0 @@ - -using System; -using HotChocolate.Types; - -namespace HotChocolate.Execution.Batching; - -public sealed class ExportedVariable -{ - public ExportedVariable(string name, IType type, object? value) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - Type = type ?? throw new ArgumentNullException(nameof(type)); - Value = value; - - } - - public string Name { get; } - - public IType Type { get; } - - public object? Value { get; } -} diff --git a/src/HotChocolate/Core/src/Execution/Caching/DefaultComplexityAnalyzerCache.cs b/src/HotChocolate/Core/src/Execution/Caching/DefaultComplexityAnalyzerCache.cs deleted file mode 100644 index da6d481a4fa..00000000000 --- a/src/HotChocolate/Core/src/Execution/Caching/DefaultComplexityAnalyzerCache.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using HotChocolate.Execution.Pipeline.Complexity; -using HotChocolate.Utilities; - -namespace HotChocolate.Execution.Caching; - -internal sealed class DefaultComplexityAnalyzerCache : IComplexityAnalyzerCache -{ - private readonly Cache _cache; - - public DefaultComplexityAnalyzerCache(int capacity = 100) - { - _cache = new Cache(capacity); - } - - public int Capacity => _cache.Capacity; - - public int Count => _cache.Usage; - - public bool TryGetAnalyzer( - string operationId, - [NotNullWhen(true)] out ComplexityAnalyzerDelegate? analyzer) - => _cache.TryGet(operationId, out analyzer); - - - public void TryAddAnalyzer( - string operationId, - ComplexityAnalyzerDelegate analyzer) - => _cache.GetOrCreate(operationId, () => analyzer); - - public void Clear() => _cache.Clear(); -} diff --git a/src/HotChocolate/Core/src/Execution/Caching/IComplexityAnalyzerCache.cs b/src/HotChocolate/Core/src/Execution/Caching/IComplexityAnalyzerCache.cs deleted file mode 100644 index d86fc3bf697..00000000000 --- a/src/HotChocolate/Core/src/Execution/Caching/IComplexityAnalyzerCache.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using HotChocolate.Execution.Pipeline.Complexity; - -namespace HotChocolate.Execution.Caching; - -internal interface IComplexityAnalyzerCache -{ - /// - /// Gets maximum amount of operation complexity analyzers that can be cached. The default - /// value is 100. The minimum allowed value is 10. - /// - int Capacity { get; } - - /// - /// Gets the amount of operation analyzers residing in the cache. - /// - int Count { get; } - - /// - /// Try get a compiled operation complexity analyzer by it . - /// - /// - /// The internal operation id. - /// - /// - /// The operation complexity analyzer that is associated with the id or null - /// if no operation complexity analyzer was found that matches the specified id. - /// - /// - /// true if an operation complexity analyzer was found that matches the specified - /// , otherwise false. - /// - bool TryGetAnalyzer( - string operationId, - [NotNullWhen(true)] out ComplexityAnalyzerDelegate? analyzer); - - /// - /// Tries to add a new operation complexity analyzer to the cache. - /// - /// - /// The internal operation id. - /// - /// - /// The operation complexity analyzer that shall be cached. - /// - void TryAddAnalyzer( - string operationId, - ComplexityAnalyzerDelegate analyzer); - - /// - /// Clears all items from the cache. - /// - void Clear(); -} diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs index ea76abc73cf..e6b55a48d2b 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs @@ -39,14 +39,7 @@ internal static IServiceCollection TryAddDiagnosticEvents( }); return services; } - - internal static IServiceCollection TryAddTimespanProvider( - this IServiceCollection services) - { - services.TryAddSingleton(); - return services; - } - + public static T GetApplicationService(this IServiceProvider services) where T : notnull => services.GetApplicationServices().GetRequiredService(); diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalServiceCollectionExtensions.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalServiceCollectionExtensions.cs index 451f1accf80..eb18dda24c5 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalServiceCollectionExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/InternalServiceCollectionExtensions.cs @@ -146,8 +146,6 @@ internal static IServiceCollection TryAddDefaultCaches( _ => new DefaultDocumentCache()); services.TryAddSingleton( _ => new DefaultPreparedOperationCache()); - services.TryAddSingleton( - _ => new DefaultComplexityAnalyzerCache()); return services; } diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs index 17565416d3b..60fd1725be8 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs @@ -11,27 +11,6 @@ namespace Microsoft.Extensions.DependencyInjection; public static partial class RequestExecutorBuilderExtensions { - public static IRequestExecutorBuilder AddApolloTracing( - this IRequestExecutorBuilder builder, - TracingPreference tracingPreference = TracingPreference.OnDemand, - ITimestampProvider? timestampProvider = null) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (tracingPreference == TracingPreference.Never) - { - return builder; - } - - return builder.AddDiagnosticEventListener( - sp => new ApolloTracingDiagnosticEventListener( - tracingPreference, - timestampProvider ?? sp.GetService())); - } - public static IRequestExecutorBuilder AddDiagnosticEventListener( this IRequestExecutorBuilder builder) where T : class diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs index efa200df49f..647e78dabe3 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs @@ -110,10 +110,6 @@ public static IRequestExecutorBuilder UseOperationCache( this IRequestExecutorBuilder builder) => builder.UseRequest(OperationCacheMiddleware.Create()); - public static IRequestExecutorBuilder UseOperationComplexityAnalyzer( - this IRequestExecutorBuilder builder) => - builder.UseRequest(OperationComplexityMiddleware.Create()); - public static IRequestExecutorBuilder UseOperationExecution( this IRequestExecutorBuilder builder) => builder.UseRequest(OperationExecutionMiddleware.Create()); @@ -134,13 +130,13 @@ public static IRequestExecutorBuilder UseAutomaticPersistedQueryNotFound( this IRequestExecutorBuilder builder) => builder.UseRequest(next => context => { - if (context.Document is not null || context.Request.Query is not null) + if (context.Document is not null || context.Request.Document is not null) { return next(context); } var error = ReadPersistedQueryMiddleware_PersistedQueryNotFound(); - var result = QueryResultBuilder.CreateError( + var result = OperationResultBuilder.CreateError( error, new Dictionary { @@ -197,7 +193,6 @@ public static IRequestExecutorBuilder UsePersistedQueryPipeline( .UseDocumentParser() .UseDocumentValidation() .UseOperationCache() - .UseOperationComplexityAnalyzer() .UseOperationResolver() .UseOperationVariableCoercion() .UseOperationExecution(); @@ -222,7 +217,6 @@ public static IRequestExecutorBuilder UseAutomaticPersistedQueryPipeline( .UseDocumentParser() .UseDocumentValidation() .UseOperationCache() - .UseOperationComplexityAnalyzer() .UseOperationResolver() .UseOperationVariableCoercion() .UseOperationExecution(); @@ -237,7 +231,6 @@ internal static void AddDefaultPipeline(this IList pipeli pipeline.Add(DocumentParserMiddleware.Create()); pipeline.Add(DocumentValidationMiddleware.Create()); pipeline.Add(OperationCacheMiddleware.Create()); - pipeline.Add(OperationComplexityMiddleware.Create()); pipeline.Add(OperationResolverMiddleware.Create()); pipeline.Add(OperationVariableCoercionMiddleware.Create()); pipeline.Add(OperationExecutionMiddleware.Create()); diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceCollectionExtensions.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceCollectionExtensions.cs index 108058ac4af..6e64ef194cf 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceCollectionExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceCollectionExtensions.cs @@ -195,12 +195,9 @@ public static IServiceCollection AddOperationCache( int capacity = 100) { services.RemoveAll(); - services.RemoveAll(); services.AddSingleton( _ => new DefaultPreparedOperationCache(capacity)); - services.AddSingleton( - _ => new DefaultComplexityAnalyzerCache(capacity)); return services; } diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceProviderExtensions.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceProviderExtensions.cs index bfbba52b167..c579218276e 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceProviderExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorServiceProviderExtensions.cs @@ -137,20 +137,20 @@ public static ValueTask BuildRequestExecutorAsync( /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result - /// that the yields is a . + /// that the yields is a . /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// public static async Task ExecuteRequestAsync( this IServiceProvider services, - IQueryRequest request, + IOperationRequest request, string? schemaName = default, CancellationToken cancellationToken = default) { @@ -182,20 +182,20 @@ await GetRequestExecutorAsync(services, schemaName, cancellationToken) /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result - /// that the yields is a . + /// that the yields is a . /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// public static async Task ExecuteRequestAsync( this IRequestExecutorBuilder builder, - IQueryRequest request, + IOperationRequest request, string? schemaName = default, CancellationToken cancellationToken = default) { @@ -227,17 +227,17 @@ await BuildRequestExecutorAsync(builder, schemaName, cancellationToken) /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result /// that the yields is a - /// . + /// . /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// public static async Task ExecuteRequestAsync( this IServiceProvider services, @@ -273,19 +273,19 @@ await GetRequestExecutorAsync(services, schemaName, cancellationToken) /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result /// that the yields is a - /// . + /// . /// /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// /// public static async Task ExecuteRequestAsync( @@ -323,7 +323,7 @@ await BuildRequestExecutorAsync(builder, schemaName, cancellationToken) /// public static async Task ExecuteBatchRequestAsync( this IServiceProvider services, - IReadOnlyList requestBatch, + OperationRequestBatch requestBatch, string? schemaName = default, CancellationToken cancellationToken = default) { diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Types.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Types.cs index eb6a84bdc24..dd835e13eb7 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Types.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Types.cs @@ -1,6 +1,5 @@ using System; using HotChocolate; -using HotChocolate.Execution.Batching; using HotChocolate.Execution.Configuration; using HotChocolate.Language; using HotChocolate.Types; @@ -1611,8 +1610,4 @@ public static IRequestExecutorBuilder BindRuntimeType( return builder.ConfigureSchema(b => b.BindRuntimeType(runtimeType, typeName)); } - - public static IRequestExecutorBuilder AddExportDirectiveType( - this IRequestExecutorBuilder builder) => - builder.AddDirectiveType(); } diff --git a/src/HotChocolate/Core/src/Execution/ErrorHelper.cs b/src/HotChocolate/Core/src/Execution/ErrorHelper.cs index 1355c63e480..c7f738c1a49 100644 --- a/src/HotChocolate/Core/src/Execution/ErrorHelper.cs +++ b/src/HotChocolate/Core/src/Execution/ErrorHelper.cs @@ -123,8 +123,8 @@ public static IError UnexpectedValueCompletionError( .Build(); } - public static IQueryResult RootTypeNotFound(OperationType operationType) => - QueryResultBuilder.CreateError( + public static IOperationResult RootTypeNotFound(OperationType operationType) => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage(ErrorHelper_RootTypeNotFound_Message, operationType) .Build(), @@ -133,20 +133,20 @@ public static IQueryResult RootTypeNotFound(OperationType operationType) => { WellKnownContextData.HttpStatusCode, HttpStatusCode.BadRequest }, }); - public static IQueryResult StateInvalidForOperationResolver() => - QueryResultBuilder.CreateError( + public static IOperationResult StateInvalidForOperationResolver() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage(ErrorHelper_StateInvalidForOperationResolver_Message) .Build()); - public static IQueryResult StateInvalidForOperationVariableCoercion() => - QueryResultBuilder.CreateError( + public static IOperationResult StateInvalidForOperationVariableCoercion() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage(ErrorHelper_StateInvalidForOperationVariableCoercion_Message) .Build()); - public static IQueryResult StateInvalidForOperationExecution() => - QueryResultBuilder.CreateError( + public static IOperationResult StateInvalidForOperationExecution() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage(ErrorHelper_StateInvalidForOperationExecution_Message) .Build()); @@ -164,15 +164,15 @@ public static IError ValueCompletion_CouldNotResolveAbstractType( .AddLocation([field]) .Build(); - public static IQueryResult StateInvalidForDocumentValidation() => - QueryResultBuilder.CreateError( + public static IOperationResult StateInvalidForDocumentValidation() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage(ErrorHelper_StateInvalidForDocumentValidation_Message) .SetCode(ErrorCodes.Execution.QueryNotFound) .Build()); - public static IQueryResult OperationKindNotAllowed() => - QueryResultBuilder.CreateError( + public static IOperationResult OperationKindNotAllowed() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage("The specified operation kind is not allowed.") .Build(), @@ -181,22 +181,32 @@ public static IQueryResult OperationKindNotAllowed() => { WellKnownContextData.OperationNotAllowed, null }, }); - public static IQueryResult RequestTimeout(TimeSpan timeout) => - QueryResultBuilder.CreateError( + public static IOperationResult RequestTypeNotAllowed() => + OperationResultBuilder.CreateError( + ErrorBuilder.New() + .SetMessage("Variable batch requests are only allowed for mutations and subscriptions.") + .Build(), + new Dictionary + { + { WellKnownContextData.ValidationErrors, null }, + }); + + public static IOperationResult RequestTimeout(TimeSpan timeout) => + OperationResultBuilder.CreateError( new Error( string.Format(ErrorHelper_RequestTimeout, timeout), ErrorCodes.Execution.Timeout)); - public static IQueryResult OperationCanceled() => - QueryResultBuilder.CreateError( + public static IOperationResult OperationCanceled() => + OperationResultBuilder.CreateError( new Error( ErrorHelper_OperationCanceled_Message, ErrorCodes.Execution.Canceled)); - public static IQueryResult MaxComplexityReached( + public static IOperationResult MaxComplexityReached( int complexity, int allowedComplexity) => - QueryResultBuilder.CreateError( + OperationResultBuilder.CreateError( new Error( ErrorHelper_MaxComplexityReached, ErrorCodes.Execution.ComplexityExceeded, @@ -215,8 +225,8 @@ public static IError MaxComplexityReached() => ErrorHelper_MaxComplexityReached, ErrorCodes.Execution.ComplexityExceeded); - public static IQueryResult StateInvalidForComplexityAnalyzer() => - QueryResultBuilder.CreateError( + public static IOperationResult StateInvalidForComplexityAnalyzer() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage(ErrorHelper_StateInvalidForComplexityAnalyzer_Message) .SetCode(ErrorCodes.Execution.ComplexityStateInvalid) @@ -230,7 +240,7 @@ public static IError NonNullOutputFieldViolation(Path? path, FieldNode selection .AddLocation([selection]) .Build(); - public static IError PersistedQueryNotFound(string requestedKey) + public static IError PersistedQueryNotFound(OperationDocumentId requestedKey) => ErrorBuilder.New() .SetMessage(ErrorHelper_PersistedQueryNotFound) .SetCode(ErrorCodes.Execution.PersistedQueryNotFound) diff --git a/src/HotChocolate/Core/src/Execution/Extensions/ExecutionRequestExecutorExtensions.cs b/src/HotChocolate/Core/src/Execution/Extensions/ExecutionRequestExecutorExtensions.cs index e87eae8f188..b83882b9b72 100644 --- a/src/HotChocolate/Core/src/Execution/Extensions/ExecutionRequestExecutorExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/Extensions/ExecutionRequestExecutorExtensions.cs @@ -14,7 +14,7 @@ public static class ExecutionRequestExecutorExtensions { public static Task ExecuteAsync( this IRequestExecutor executor, - IQueryRequest request) + IOperationRequest request) { if (executor is null) { @@ -52,7 +52,7 @@ public static Task ExecuteAsync( } return executor.ExecuteAsync( - QueryRequestBuilder.New().SetQuery(query).Create(), + OperationRequestBuilder.Create().SetDocument(query).Build(), CancellationToken.None); } @@ -78,7 +78,7 @@ public static Task ExecuteAsync( } return executor.ExecuteAsync( - QueryRequestBuilder.New().SetQuery(query).Create(), + OperationRequestBuilder.Create().SetDocument(query).Build(), cancellationToken); } @@ -109,10 +109,10 @@ public static Task ExecuteAsync( } return executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) + OperationRequestBuilder.Create() + .SetDocument(query) .SetVariableValues(variableValues) - .Create(), + .Build(), CancellationToken.None); } @@ -144,16 +144,16 @@ public static Task ExecuteAsync( } return executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) + OperationRequestBuilder.Create() + .SetDocument(query) .SetVariableValues(variableValues) - .Create(), + .Build(), cancellationToken); } public static IExecutionResult Execute( this IRequestExecutor executor, - IQueryRequest request) + IOperationRequest request) { if (executor is null) { @@ -193,9 +193,9 @@ public static IExecutionResult Execute( } return executor.Execute( - QueryRequestBuilder.New() - .SetQuery(query) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .Build()); } public static IExecutionResult Execute( @@ -225,15 +225,15 @@ public static IExecutionResult Execute( } return executor.Execute( - QueryRequestBuilder.New() - .SetQuery(query) + OperationRequestBuilder.Create() + .SetDocument(query) .SetVariableValues(variableValues) - .Create()); + .Build()); } public static Task ExecuteAsync( this IRequestExecutor executor, - Action buildRequest, + Action buildRequest, CancellationToken cancellationToken) { if (executor is null) @@ -246,17 +246,17 @@ public static Task ExecuteAsync( throw new ArgumentNullException(nameof(buildRequest)); } - var builder = new QueryRequestBuilder(); + var builder = new OperationRequestBuilder(); buildRequest(builder); return executor.ExecuteAsync( - builder.Create(), + builder.Build(), cancellationToken); } public static Task ExecuteAsync( this IRequestExecutor executor, - Action buildRequest) + Action buildRequest) { if (executor is null) { diff --git a/src/HotChocolate/Core/src/Execution/Extensions/ExecutionResultExtensions.cs b/src/HotChocolate/Core/src/Execution/Extensions/ExecutionResultExtensions.cs index 60311de300a..59486cfb318 100644 --- a/src/HotChocolate/Core/src/Execution/Extensions/ExecutionResultExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/Extensions/ExecutionResultExtensions.cs @@ -13,7 +13,7 @@ public static class ExecutionResultExtensions private static readonly JsonResultFormatter _formatterIndented = new(new() { Indented = true, }); public static void WriteTo( - this IQueryResult result, + this IOperationResult result, IBufferWriter writer, bool withIndentations = true) { @@ -62,7 +62,7 @@ public static string ToJson( throw new ArgumentNullException(nameof(result)); } - if (result is IQueryResult queryResult) + if (result is IOperationResult queryResult) { return withIndentations ? _formatterIndented.Format(queryResult) diff --git a/src/HotChocolate/Core/src/Execution/Extensions/OperationContextExtensions.cs b/src/HotChocolate/Core/src/Execution/Extensions/OperationContextExtensions.cs index e979ec85099..db7aba72c3b 100644 --- a/src/HotChocolate/Core/src/Execution/Extensions/OperationContextExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/Extensions/OperationContextExtensions.cs @@ -137,7 +137,7 @@ public static OperationContext ClearResult( return context; } - public static IQueryResult BuildResult( + public static IOperationResult BuildResult( this OperationContext context) => context.Result.BuildResult(); } diff --git a/src/HotChocolate/Core/src/Execution/HotChocolate.Execution.csproj b/src/HotChocolate/Core/src/Execution/HotChocolate.Execution.csproj index 3744e68660b..086a0c66e6e 100644 --- a/src/HotChocolate/Core/src/Execution/HotChocolate.Execution.csproj +++ b/src/HotChocolate/Core/src/Execution/HotChocolate.Execution.csproj @@ -225,4 +225,8 @@ + + + + diff --git a/src/HotChocolate/Core/src/Execution/IRequestContext.cs b/src/HotChocolate/Core/src/Execution/IRequestContext.cs index 119b356a707..fe76ff60d86 100644 --- a/src/HotChocolate/Core/src/Execution/IRequestContext.cs +++ b/src/HotChocolate/Core/src/Execution/IRequestContext.cs @@ -1,12 +1,11 @@ using System; +using System.Collections.Generic; using System.Threading; using HotChocolate.Execution.Instrumentation; using HotChocolate.Execution.Processing; using HotChocolate.Language; using HotChocolate.Validation; -#nullable enable - namespace HotChocolate.Execution; /// @@ -23,6 +22,11 @@ public interface IRequestContext : IHasContextData /// Gets the request executor version. /// ulong ExecutorVersion { get; } + + /// + /// Gets the index of the request that corresponds to this context. + /// + int? RequestIndex { get; } /// /// Gets or sets the scoped request services. @@ -43,7 +47,7 @@ public interface IRequestContext : IHasContextData /// /// Gets or sets the initial query request. /// - IQueryRequest Request { get; } + IOperationRequest Request { get; } /// /// Notifies when the connection underlying this request is aborted @@ -54,7 +58,7 @@ public interface IRequestContext : IHasContextData /// /// Gets or sets a unique identifier for a query document. /// - string? DocumentId { get; set; } + OperationDocumentId? DocumentId { get; set; } /// /// Gets or sets the document hash. @@ -101,7 +105,7 @@ public interface IRequestContext : IHasContextData /// /// Gets or sets the coerced variable values. /// - IVariableValueCollection? Variables { get; set; } + IReadOnlyList? Variables { get; set; } /// /// Gets or sets the execution result. diff --git a/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs b/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs index 5a497b01a8e..5171b9879e5 100644 --- a/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs +++ b/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs @@ -39,19 +39,19 @@ public interface IRequestExecutor /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result - /// that the yields is a . + /// that the yields is a . /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// Task ExecuteAsync( - IQueryRequest request, + IOperationRequest request, CancellationToken cancellationToken = default); /// @@ -67,6 +67,6 @@ Task ExecuteAsync( /// Returns a stream of query results. /// Task ExecuteBatchAsync( - IReadOnlyList requestBatch, + OperationRequestBatch requestBatch, CancellationToken cancellationToken = default); } diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs index 62316a8eb8c..e7af37051bf 100644 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs @@ -267,7 +267,7 @@ public IDisposable OnSubscriptionEvent(SubscriptionEventContext context) return new AggregateActivityScope(scopes); } - public void SubscriptionEventResult(SubscriptionEventContext context, IQueryResult result) + public void SubscriptionEventResult(SubscriptionEventContext context, IOperationResult result) { for (var i = 0; i < _listeners.Length; i++) { diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingDiagnosticEventListener.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingDiagnosticEventListener.cs deleted file mode 100644 index 2f2a5f69dd9..00000000000 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingDiagnosticEventListener.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using HotChocolate.Execution.Options; -using HotChocolate.Resolvers; - -namespace HotChocolate.Execution.Instrumentation; - -internal class ApolloTracingDiagnosticEventListener : ExecutionDiagnosticEventListener -{ - private const string _extensionKey = "tracing"; - private readonly TracingPreference _tracingPreference; - private readonly ITimestampProvider _timestampProvider; - - public ApolloTracingDiagnosticEventListener( - TracingPreference tracingPreference = TracingPreference.OnDemand, - ITimestampProvider? timestampProvider = null) - { - _tracingPreference = tracingPreference; - _timestampProvider = timestampProvider ?? new DefaultTimestampProvider(); - } - - public override bool EnableResolveFieldValue => true; - - public override IDisposable ExecuteRequest(IRequestContext context) - { - if (IsEnabled(context.ContextData)) - { - var startTime = _timestampProvider.UtcNow(); - - var builder = CreateBuilder(context.ContextData); - - builder.SetRequestStartTime( - startTime, - _timestampProvider.NowInNanoseconds()); - - return new RequestScope(context, startTime, builder, _timestampProvider); - } - return EmptyScope; - } - - public override IDisposable ParseDocument(IRequestContext context) - { - return TryGetBuilder(context.ContextData, out var builder) - ? new ParseDocumentScope(builder, _timestampProvider) - : EmptyScope; - } - - public override IDisposable ValidateDocument(IRequestContext context) - { - return TryGetBuilder(context.ContextData, out var builder) - ? new ValidateDocumentScope(builder, _timestampProvider) - : EmptyScope; - } - - public override IDisposable ResolveFieldValue(IMiddlewareContext context) - { - return TryGetBuilder(context.ContextData, out var builder) - ? new ResolveFieldValueScope(context, builder, _timestampProvider) - : EmptyScope; - } - - private static ApolloTracingResultBuilder CreateBuilder( - IDictionary contextData) - { - var builder = new ApolloTracingResultBuilder(); - contextData[nameof(ApolloTracingResultBuilder)] = builder; - return builder; - } - - private static bool TryGetBuilder( - IDictionary contextData, - [NotNullWhen(true)] out ApolloTracingResultBuilder? builder) - { - if (contextData.TryGetValue(nameof(ApolloTracingResultBuilder), out var value) && - value is ApolloTracingResultBuilder b) - { - builder = b; - return true; - } - - builder = null; - return false; - } - - private bool IsEnabled(IDictionary contextData) - { - return (_tracingPreference == TracingPreference.Always || - (_tracingPreference == TracingPreference.OnDemand && - contextData.ContainsKey(WellKnownContextData.EnableTracing))); - } - - private sealed class RequestScope : IDisposable - { - private readonly IRequestContext _context; - private readonly DateTime _startTime; - private readonly ApolloTracingResultBuilder _builder; - private readonly ITimestampProvider _timestampProvider; - private bool _disposed; - - public RequestScope( - IRequestContext context, - DateTime startTime, - ApolloTracingResultBuilder builder, - ITimestampProvider timestampProvider) - { - _context = context; - _startTime = startTime; - _builder = builder; - _timestampProvider = timestampProvider; - } - - public void Dispose() - { - if (!_disposed) - { - var endTime = _timestampProvider.UtcNow(); - _builder.SetRequestDuration(endTime - _startTime); - - if (_context.Result is IQueryResult queryResult) - { - _context.Result = QueryResultBuilder.FromResult(queryResult) - .AddExtension(_extensionKey, _builder.Build()) - .Create(); - } - _disposed = true; - } - } - } - - private sealed class ParseDocumentScope : IDisposable - { - private readonly ApolloTracingResultBuilder _builder; - private readonly ITimestampProvider _timestampProvider; - private readonly long _startTimestamp; - private bool _disposed; - - public ParseDocumentScope( - ApolloTracingResultBuilder builder, - ITimestampProvider timestampProvider) - { - _builder = builder; - _timestampProvider = timestampProvider; - _startTimestamp = timestampProvider.NowInNanoseconds(); - } - - public void Dispose() - { - if (!_disposed) - { - _builder.SetParsingResult( - _startTimestamp, - _timestampProvider.NowInNanoseconds()); - _disposed = true; - } - } - } - - private sealed class ValidateDocumentScope : IDisposable - { - private readonly ApolloTracingResultBuilder _builder; - private readonly ITimestampProvider _timestampProvider; - private readonly long _startTimestamp; - private bool _disposed; - - public ValidateDocumentScope( - ApolloTracingResultBuilder builder, - ITimestampProvider timestampProvider) - { - _builder = builder; - _timestampProvider = timestampProvider; - _startTimestamp = timestampProvider.NowInNanoseconds(); - } - - public void Dispose() - { - if (!_disposed) - { - _builder.SetValidationResult( - _startTimestamp, - _timestampProvider.NowInNanoseconds()); - _disposed = true; - } - } - } - - private sealed class ResolveFieldValueScope : IDisposable - { - private readonly IMiddlewareContext _context; - private readonly ApolloTracingResultBuilder _builder; - private readonly ITimestampProvider _timestampProvider; - private readonly long _startTimestamp; - private bool _disposed; - - public ResolveFieldValueScope( - IMiddlewareContext context, - ApolloTracingResultBuilder builder, - ITimestampProvider timestampProvider) - { - _context = context; - _builder = builder; - _timestampProvider = timestampProvider; - _startTimestamp = timestampProvider.NowInNanoseconds(); - } - - public void Dispose() - { - if (!_disposed) - { - var stopTimestamp = _timestampProvider.NowInNanoseconds(); - - _builder.AddResolverResult( - new ApolloTracingResolverRecord( - _context, - _startTimestamp, - stopTimestamp)); - _disposed = true; - } - } - } -} - -public interface ITimestampProvider -{ - DateTime UtcNow(); - - long NowInNanoseconds(); -} - -public class DefaultTimestampProvider : ITimestampProvider -{ - public DateTime UtcNow() => DateTime.UtcNow; - - public long NowInNanoseconds() => Timestamp.GetNowInNanoseconds(); -} diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResolverRecord.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResolverRecord.cs deleted file mode 100644 index 4486eaa72eb..00000000000 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResolverRecord.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; -using HotChocolate.Resolvers; -using HotChocolate.Types; - -namespace HotChocolate.Execution.Instrumentation; - -internal class ApolloTracingResolverRecord -{ - public ApolloTracingResolverRecord( - IResolverContext context, - long startTimestamp, - long endTimestamp) - { - Path = context.Path.ToList(); - ParentType = context.ObjectType.Name; - FieldName = context.Selection.Field.Name; - ReturnType = context.Selection.Type.TypeName(); - StartTimestamp = startTimestamp; - EndTimestamp = endTimestamp; - } - - public IReadOnlyList Path { get; } - - public string ParentType { get; } - - public string FieldName { get; } - - public string ReturnType { get; } - - public long StartTimestamp { get; } - - public long EndTimestamp { get; } -} diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultBuilder.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultBuilder.cs deleted file mode 100644 index be2517cc996..00000000000 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultBuilder.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Concurrent; -using HotChocolate.Execution.Processing; -using static HotChocolate.Execution.Instrumentation.ApolloTracingResultKeys; - -namespace HotChocolate.Execution.Instrumentation; - -internal class ApolloTracingResultBuilder -{ - private const int _apolloTracingVersion = 1; - private const long _ticksToNanosecondsMultiplier = 100; - private readonly ConcurrentQueue _resolverRecords = - new ConcurrentQueue(); - private TimeSpan _duration; - private ObjectResult? _parsingResult; - private DateTimeOffset _startTime; - private long _startTimestamp; - private ObjectResult? _validationResult; - - public void SetRequestStartTime( - DateTimeOffset startTime, - long startTimestamp) - { - _startTime = startTime; - _startTimestamp = startTimestamp; - } - - public void SetParsingResult(long startTimestamp, long endTimestamp) - { - _parsingResult = new ObjectResult(); - _parsingResult.EnsureCapacity(2); - _parsingResult.SetValueUnsafe(0, StartOffset, startTimestamp - _startTimestamp); - _parsingResult.SetValueUnsafe(1, Duration, endTimestamp - startTimestamp); - } - - public void SetValidationResult(long startTimestamp, long endTimestamp) - { - _validationResult = new ObjectResult(); - _validationResult.EnsureCapacity(2); - _validationResult.SetValueUnsafe(0, StartOffset, startTimestamp - _startTimestamp); - _validationResult.SetValueUnsafe(1, Duration, endTimestamp - startTimestamp); - } - - public void AddResolverResult(ApolloTracingResolverRecord record) - { - _resolverRecords.Enqueue(record); - } - - public void SetRequestDuration(TimeSpan duration) - { - _duration = duration; - } - - public ObjectResult Build() - { - if (_parsingResult is null) - { - // in the case that the request pipeline cached the parsed document, - // we will set the parsing duration to 0. - SetParsingResult(_startTimestamp, _startTimestamp); - } - - if (_validationResult is null) - { - // in the case that the request pipeline cached the validation result, - // we will set the validation duration to 0. - SetValidationResult(_startTimestamp, _startTimestamp); - } - - var result = new ObjectResult(); - result.EnsureCapacity(1); - result.SetValueUnsafe(0, ApolloTracingResultKeys.Resolvers, BuildResolverResults()); - - var details = new ObjectResult(); - details.EnsureCapacity(7); - details.SetValueUnsafe(0, ApolloTracingResultKeys.Version, _apolloTracingVersion); - details.SetValueUnsafe(1, StartTime, _startTime.ToRfc3339DateTimeString()); - details.SetValueUnsafe(2, EndTime, _startTime.Add(_duration).ToRfc3339DateTimeString()); - details.SetValueUnsafe(3, Duration, _duration.Ticks * _ticksToNanosecondsMultiplier); - details.SetValueUnsafe(4, Parsing, _parsingResult); - details.SetValueUnsafe(5, ApolloTracingResultKeys.Validation, _validationResult); - details.SetValueUnsafe(6, ApolloTracingResultKeys.Execution, result); - return details; - } - - private ObjectResult[] BuildResolverResults() - { - var i = 0; - var results = new ObjectResult[_resolverRecords.Count]; - - foreach (var record in _resolverRecords) - { - var result = new ObjectResult(); - result.EnsureCapacity(6); - result.SetValueUnsafe(0, ApolloTracingResultKeys.Path, record.Path); - result.SetValueUnsafe(1, ParentType, record.ParentType); - result.SetValueUnsafe(2, FieldName, record.FieldName); - result.SetValueUnsafe(3, ReturnType, record.ReturnType); - result.SetValueUnsafe(4, StartOffset, record.StartTimestamp - _startTimestamp); - result.SetValueUnsafe(5, Duration, record.EndTimestamp - record.StartTimestamp); - results[i++] = result; - } - - return results; - } -} diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultKeys.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultKeys.cs deleted file mode 100644 index 575b009fc78..00000000000 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/ApolloTracingResultKeys.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace HotChocolate.Execution.Instrumentation; - -internal static class ApolloTracingResultKeys -{ - public const string Duration = "duration"; - public const string EndTime = "endTime"; - public const string Execution = "execution"; - public const string FieldName = "fieldName"; - public const string ParentType = "parentType"; - public const string Parsing = "parsing"; - public const string Path = "path"; - public const string Resolvers = "resolvers"; - public const string ReturnType = "returnType"; - public const string StartOffset = "startOffset"; - public const string StartTime = "startTime"; - public const string Validation = "validation"; - public const string Version = "version"; -} diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs index 7d7e35f6162..6ecc89df8df 100644 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs @@ -134,7 +134,7 @@ public virtual IDisposable OnSubscriptionEvent( /// public virtual void SubscriptionEventResult( SubscriptionEventContext context, - IQueryResult result) + IOperationResult result) { } diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs index 99490f285f8..bed27d1ecb8 100644 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs @@ -305,7 +305,7 @@ public interface IExecutionDiagnosticEvents /// /// The subscription result that is being written to the response stream. /// - void SubscriptionEventResult(SubscriptionEventContext context, IQueryResult result); + void SubscriptionEventResult(SubscriptionEventContext context, IOperationResult result); /// /// Called when an error occurred while producing the subscription event result. diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs index 498b3d445c9..1382f81d6b0 100644 --- a/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs @@ -78,7 +78,7 @@ public void StopProcessing(IRequestContext context) public IDisposable OnSubscriptionEvent(SubscriptionEventContext context) => this; - public void SubscriptionEventResult(SubscriptionEventContext context, IQueryResult result) + public void SubscriptionEventResult(SubscriptionEventContext context, IOperationResult result) { } diff --git a/src/HotChocolate/Core/src/Execution/Options/ComplexityAnalyzerSettings.cs b/src/HotChocolate/Core/src/Execution/Options/ComplexityAnalyzerSettings.cs deleted file mode 100644 index 923f0b0c34d..00000000000 --- a/src/HotChocolate/Core/src/Execution/Options/ComplexityAnalyzerSettings.cs +++ /dev/null @@ -1,84 +0,0 @@ -using HotChocolate.Execution.Pipeline.Complexity; -using HotChocolate.Types; - -namespace HotChocolate.Execution.Options; - -/// -/// The complexity settings. -/// -public class ComplexityAnalyzerSettings : ICostSettings -{ - /// - /// Defines if the complexity analysis is enabled. - /// - public bool Enable { get; set; } = false; - - /// - /// Gets or sets the maximum allowed complexity. - /// - public int MaximumAllowed { get; set; } = 1000; - - /// - /// Defines if default cost and multipliers shall be applied to the schema. - /// - public bool ApplyDefaults { get; set; } = true; - - /// - /// Gets or sets the complexity that is applied to all fields - /// that do not have a cost directive. - /// - public int DefaultComplexity { get; set; } = 1; - - /// - /// Gets or sets the complexity that is applied to async and data - /// resolvers if is true. - /// - public int DefaultResolverComplexity { get; set; } = 5; - - /// - /// Gets or sets the context data key that that will be used to store - /// the calculated complexity on the request. - /// - public string ContextDataKey { get; set; } = WellKnownContextData.OperationComplexity; - - /// - /// Gets or sets the complexity calculation delegate.. - /// - public ComplexityCalculation Calculation { get; set; } = DefaultCalculation; - - /// - /// The default complexity calculation algorithm. - /// - /// - /// The complexity context. - /// - /// - /// Returns the calculated field complexity. - /// - public static int DefaultCalculation(ComplexityContext context) - { - if (context.Multipliers.Count == 0) - { - return context.Complexity + context.ChildComplexity; - } - - var cost = context.Complexity + context.ChildComplexity; - var needsDefaultMultiplier = true; - - foreach (var multiplier in context.Multipliers) - { - if (context.TryGetArgumentValue(multiplier, out int value)) - { - cost *= value; - needsDefaultMultiplier = false; - } - } - - if (needsDefaultMultiplier && context.DefaultMultiplier.HasValue) - { - cost *= context.DefaultMultiplier.Value; - } - - return cost; - } -} diff --git a/src/HotChocolate/Core/src/Execution/Options/IComplexityAnalyzerOptionsAccessor.cs b/src/HotChocolate/Core/src/Execution/Options/IComplexityAnalyzerOptionsAccessor.cs deleted file mode 100644 index 480af73ec9b..00000000000 --- a/src/HotChocolate/Core/src/Execution/Options/IComplexityAnalyzerOptionsAccessor.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace HotChocolate.Execution.Options; - -/// -/// The complexity options accessor. -/// -public interface IComplexityAnalyzerOptionsAccessor -{ - /// - /// Gets the complexity analyzer settings. - /// - ComplexityAnalyzerSettings Complexity { get; } -} diff --git a/src/HotChocolate/Core/src/Execution/Options/IRequestExecutorOptionsAccessor.cs b/src/HotChocolate/Core/src/Execution/Options/IRequestExecutorOptionsAccessor.cs index 1207b425206..041d6c9c04e 100644 --- a/src/HotChocolate/Core/src/Execution/Options/IRequestExecutorOptionsAccessor.cs +++ b/src/HotChocolate/Core/src/Execution/Options/IRequestExecutorOptionsAccessor.cs @@ -9,5 +9,4 @@ namespace HotChocolate.Execution.Options; public interface IRequestExecutorOptionsAccessor : IErrorHandlerOptionsAccessor , IRequestTimeoutOptionsAccessor - , IComplexityAnalyzerOptionsAccessor , IPersistedQueryOptionsAccessor; diff --git a/src/HotChocolate/Core/src/Execution/Options/RequestExecutorOptions.cs b/src/HotChocolate/Core/src/Execution/Options/RequestExecutorOptions.cs index 7b64582b4bf..39ca71c9c3d 100644 --- a/src/HotChocolate/Core/src/Execution/Options/RequestExecutorOptions.cs +++ b/src/HotChocolate/Core/src/Execution/Options/RequestExecutorOptions.cs @@ -51,11 +51,6 @@ public TimeSpan ExecutionTimeout /// public bool IncludeExceptionDetails { get; set; } = Debugger.IsAttached; - /// - /// Gets the complexity analyzer settings. - /// - public ComplexityAnalyzerSettings Complexity { get; } = new(); - /// /// Specifies if only persisted queries are allowed when using /// the persisted query pipeline. diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerCompiler.cs b/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerCompiler.cs deleted file mode 100644 index 37a18b5ff6d..00000000000 --- a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerCompiler.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using HotChocolate.Execution.Options; -using HotChocolate.Language; -using HotChocolate.Language.Visitors; -using HotChocolate.Types; -using HotChocolate.Validation; -using static System.Linq.Expressions.Expression; -using static HotChocolate.Execution.Properties.Resources; - -namespace HotChocolate.Execution.Pipeline.Complexity; - -internal sealed class ComplexityAnalyzerCompiler : TypeDocumentValidatorVisitor -{ - private static readonly MethodInfo _getService = - typeof(IServiceProvider).GetMethod("GetService")!; - private readonly Expression _settings; - private readonly Expression _zero = Constant(0, typeof(int)); - private readonly ParameterExpression _variables = - Parameter(typeof(IVariableValueCollection), "variables"); - private readonly ParameterExpression _services = - Parameter(typeof(IServiceProvider), "services"); - - public ComplexityAnalyzerCompiler(ComplexityAnalyzerSettings settings) - { - _settings = Constant(settings, typeof(ComplexityAnalyzerSettings)); - } - - protected override ISyntaxVisitorAction Enter( - DocumentNode node, - IDocumentValidatorContext context) - => throw new InvalidOperationException(ComplexityAnalyzerCompiler_Enter_OnlyOperations); - - protected override ISyntaxVisitorAction Enter( - OperationDefinitionNode node, - IDocumentValidatorContext context) - { - context.List.Push(new List()); - return base.Enter(node, context); - } - - protected override ISyntaxVisitorAction Leave( - OperationDefinitionNode node, - IDocumentValidatorContext context) - { - var expressions = (List)context.List.Pop()!; - - context.List.Push( - new OperationComplexityAnalyzer( - node, - Lambda( - Combine(expressions), - _services, - _variables).Compile())); - - return base.Leave(node, context); - } - - protected override ISyntaxVisitorAction Enter( - FieldNode node, - IDocumentValidatorContext context) - { - if (context.Types.TryPeek(out var type) && - type.NamedType() is IComplexOutputType ot && - ot.Fields.TryGetField(node.Name.Value, out var of)) - { - context.List.Push(new List()); - context.OutputFields.Push(of); - context.Types.Push(of.Type); - return Continue; - } - - context.UnexpectedErrorsDetected = true; - return Skip; - } - - protected override ISyntaxVisitorAction Leave( - FieldNode node, - IDocumentValidatorContext context) - { - var field = context.OutputFields.Pop(); - var children = (List)context.List.Pop()!; - context.Types.Pop(); - - var parent = (List)context.List.Peek()!; - parent.Add(CreateFieldComplexityExpression(context, field, node, children)); - - return Continue; - } - - private Expression CreateFieldComplexityExpression( - IDocumentValidatorContext context, - IOutputField field, - FieldNode selection, - List children) - { - return children.Count switch - { - 0 => CreateCalculateExpression(context, field, selection, _zero), - 1 => CreateCalculateExpression(context, field, selection, children[0]), - _ => CreateCalculateExpression(context, field, selection, Combine(children)), - }; - } - - private Expression CreateCalculateExpression( - IDocumentValidatorContext context, - IOutputField field, - FieldNode selection, - Expression childComplexity) - { - var costDirective = - field.Directives["cost"] - .FirstOrDefault()? - .AsValue(); - - return Call( - Helper.CalculateMethod, - Constant(field, typeof(IOutputField)), - Constant(selection, typeof(FieldNode)), - Constant(costDirective, typeof(CostDirective)), - Constant(context.Fields.Count + 1, typeof(int)), - Constant(context.Path.Count + 1, typeof(int)), - childComplexity, - _variables, - GetInputParser(), - _settings); - } - - private Expression GetInputParser() - => Convert( - Call(_services, _getService, Constant(typeof(InputParser))), - typeof(InputParser)); - - private Expression Combine(IReadOnlyList expressions) - { - if (expressions.Count > 2048) - { - throw new GraphQLException(ErrorHelper.MaxComplexityReached()); - } - - var combinedComplexity = expressions[0]; - - for (var i = 1; i < expressions.Count; i++) - { - combinedComplexity = Add(combinedComplexity, expressions[i]); - } - - return combinedComplexity; - } - - private static class Helper - { - public static readonly MethodInfo CalculateMethod = - typeof(Helper).GetMethod(nameof(Calculate))!; - - public static int Calculate( - IOutputField field, - FieldNode selection, - CostDirective costDirective, - int fieldDepth, - int nodeDepth, - int childComplexity, - IVariableValueCollection variables, - InputParser inputParser, - ComplexityAnalyzerSettings analyzerSettings) - { - return analyzerSettings.Calculation.Invoke( - new ComplexityContext( - field, - selection, - costDirective, - fieldDepth, - nodeDepth, - childComplexity, - analyzerSettings.DefaultComplexity, - variables, - inputParser)); - } - } -} diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerDelegate.cs b/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerDelegate.cs deleted file mode 100644 index 36b99267f3a..00000000000 --- a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityAnalyzerDelegate.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace HotChocolate.Execution.Pipeline.Complexity; - -internal delegate int ComplexityAnalyzerDelegate( - IServiceProvider services, - IVariableValueCollection variableValues); diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityCalculation.cs b/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityCalculation.cs deleted file mode 100644 index caaa22f7044..00000000000 --- a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityCalculation.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace HotChocolate.Execution.Pipeline.Complexity; - -/// -/// The complexity calculation delegate. -/// -public delegate int ComplexityCalculation(ComplexityContext context); diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityContext.cs b/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityContext.cs deleted file mode 100644 index 30aec3b395a..00000000000 --- a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/ComplexityContext.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using HotChocolate.Language; -using HotChocolate.Types; -using HotChocolate.Utilities; - -namespace HotChocolate.Execution.Pipeline.Complexity; - -/// -/// The context to calculate a field complexity. -/// -public readonly ref struct ComplexityContext -{ - private readonly IVariableValueCollection _valueCollection; - private readonly InputParser _inputParser; - - /// - /// Creates a new instance of - /// - public ComplexityContext( - IOutputField field, - FieldNode selection, - CostDirective? cost, - int fieldDepth, - int nodeDepth, - int childComplexity, - int defaultComplexity, - IVariableValueCollection valueCollection, - InputParser inputParser) - { - Field = field; - Selection = selection; - Complexity = cost?.Complexity ?? defaultComplexity; - ChildComplexity = childComplexity; - Multipliers = cost?.Multipliers ?? Array.Empty(); - DefaultMultiplier = cost?.DefaultMultiplier; - FieldDepth = fieldDepth; - NodeDepth = nodeDepth; - _valueCollection = valueCollection; - _inputParser = inputParser; - } - - /// - /// Gets the field for which the complexity is calculated. - /// - public IOutputField Field { get; } - - /// - /// Gets the field selection that references the field in the query. - /// - public FieldNode Selection { get; } - - /// - /// Gets the coerced variables of the current request. - /// - public IVariableValueCollection Variables => _valueCollection; - - /// - /// Gets the field`s base complexity. - /// - /// - public int Complexity { get; } - - /// - /// Gets the calculated complexity of all child fields. - /// - public int ChildComplexity { get; } - - /// - /// Gets the multiplier argument names. - /// - /// - public IReadOnlyList Multipliers { get; } - - /// - /// Gets the default multiplier value that is used when no - /// multiplier argument has a value. - /// - public int? DefaultMultiplier { get; } - - /// - /// Gets the field depth in the query of the current field. - /// - public int FieldDepth { get; } - - /// - /// Gets the selection depth of the syntax tree. - /// - public int NodeDepth { get; } - - /// - /// A helper to resolver a multiplier argument value. - /// - public bool TryGetArgumentValue(string name, out T? value) - { - if (Field.Arguments.TryGetField(name, out var argument)) - { - var argumentValue = Selection.Arguments - .FirstOrDefault(t => t.Name.Value.EqualsOrdinal(name))? - .Value; - - if (argumentValue is VariableNode variable && - _valueCollection.TryGetVariable(variable.Name.Value, out T? castedVariable)) - { - value = castedVariable; - return true; - } - - if (argumentValue is not null) - { - try - { - if (_inputParser.ParseLiteral( - argumentValue, - argument, - typeof(T)) is T castedArgument) - { - value = castedArgument; - return true; - } - } - catch (SerializationException) - { - // we ignore serialization errors and fall through. - } - } - } - - value = default!; - return false; - } -} diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/OperationComplexityAnalyzer.cs b/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/OperationComplexityAnalyzer.cs deleted file mode 100644 index 449b70d8332..00000000000 --- a/src/HotChocolate/Core/src/Execution/Pipeline/Complexity/OperationComplexityAnalyzer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HotChocolate.Language; - -namespace HotChocolate.Execution.Pipeline.Complexity; - -internal sealed class OperationComplexityAnalyzer -{ - public OperationComplexityAnalyzer( - OperationDefinitionNode operationDefinitionNode, - ComplexityAnalyzerDelegate analyzer) - { - OperationDefinitionNode = operationDefinitionNode; - Analyzer = analyzer; - } - - public OperationDefinitionNode OperationDefinitionNode { get; } - - public ComplexityAnalyzerDelegate Analyzer { get; } -} diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/DocumentCacheMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/DocumentCacheMiddleware.cs index 63ab8c0cb80..9ef037c3557 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/DocumentCacheMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/DocumentCacheMiddleware.cs @@ -36,31 +36,29 @@ public async ValueTask InvokeAsync(IRequestContext context) if (context.Document is null) { - if (request.QueryId != null && - _documentCache.TryGetDocument(request.QueryId, out var document)) + if (!OperationDocumentId.IsNullOrEmpty(request.DocumentId) && + _documentCache.TryGetDocument(request.DocumentId.Value.Value, out var document)) { - context.DocumentId = request.QueryId; + context.DocumentId = request.DocumentId; context.Document = document; context.ValidationResult = DocumentValidatorResult.Ok; context.IsCachedDocument = true; addToCache = false; _diagnosticEvents.RetrievedDocumentFromCache(context); } - else if (request.QueryHash != null && - _documentCache.TryGetDocument(request.QueryHash, out document)) + else if (request.DocumentHash is not null && + _documentCache.TryGetDocument(request.DocumentHash, out document)) { - context.DocumentId = request.QueryHash; + context.DocumentId = request.DocumentHash; context.Document = document; context.ValidationResult = DocumentValidatorResult.Ok; context.IsCachedDocument = true; addToCache = false; _diagnosticEvents.RetrievedDocumentFromCache(context); } - else if (request.QueryHash is null && request.Query != null) + else if (request.DocumentHash is null && request.Document is not null) { - context.DocumentHash = - _documentHashProvider.ComputeHash(request.Query.AsSpan()); - + context.DocumentHash = _documentHashProvider.ComputeHash(request.Document.AsSpan()); if (_documentCache.TryGetDocument(context.DocumentHash, out document)) { context.DocumentId = context.DocumentHash; @@ -76,11 +74,11 @@ public async ValueTask InvokeAsync(IRequestContext context) await _next(context).ConfigureAwait(false); if (addToCache && - context.DocumentId != null && + !OperationDocumentId.IsNullOrEmpty(context.DocumentId) && context.Document != null && context.IsValidDocument) { - _documentCache.TryAddDocument(context.DocumentId, context.Document); + _documentCache.TryAddDocument(context.DocumentId.Value.Value, context.Document); _diagnosticEvents.AddedDocumentToCache(context); } } diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/DocumentParserMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/DocumentParserMiddleware.cs index 6beeb78d67c..9bbbce58559 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/DocumentParserMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/DocumentParserMiddleware.cs @@ -30,22 +30,22 @@ private DocumentParserMiddleware(RequestDelegate next, public async ValueTask InvokeAsync(IRequestContext context) { - if (context.Document is null && context.Request.Query is not null) + if (context.Document is null && context.Request.Document is not null) { var success = false; - var query = context.Request.Query; + var query = context.Request.Document; // a parsed document was passed into the request. - if (query is QueryDocument parsed) + if (query is OperationDocument parsed) { context.DocumentId = ComputeDocumentHash( context.DocumentHash, - context.Request.QueryHash, - context.Request.Query); + context.Request.DocumentHash, + context.Request.Document); context.Document = parsed.Document; success = true; } - else if (query is QuerySourceText source) + else if (query is OperationDocumentSourceText source) { using (_diagnosticEvents.ParseDocument(context)) { @@ -53,8 +53,8 @@ public async ValueTask InvokeAsync(IRequestContext context) { context.DocumentId = ComputeDocumentHash( context.DocumentHash, - context.Request.QueryHash, - context.Request.Query); + context.Request.DocumentHash, + context.Request.Document); context.Document = Utf8GraphQLParser.Parse(source.AsSpan(), _parserOptions); success = true; } @@ -70,7 +70,7 @@ public async ValueTask InvokeAsync(IRequestContext context) .Build()); context.Exception = ex; - context.Result = QueryResultBuilder.CreateError(error); + context.Result = OperationResultBuilder.CreateError(error); _diagnosticEvents.SyntaxError(context, error); } @@ -92,10 +92,8 @@ public async ValueTask InvokeAsync(IRequestContext context) } } - private string ComputeDocumentHash(string? documentHash, string? queryHash, IQuery query) - { - return documentHash ?? queryHash ?? _documentHashProvider.ComputeHash(query.AsSpan()); - } + private string ComputeDocumentHash(string? documentHash, string? queryHash, IOperationDocument query) + => documentHash ?? queryHash ?? _documentHashProvider.ComputeHash(query.AsSpan()); public static RequestCoreMiddleware Create() => (core, next) => diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/DocumentValidationMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/DocumentValidationMiddleware.cs index 376ca96d94b..90237d20206 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/DocumentValidationMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/DocumentValidationMiddleware.cs @@ -30,7 +30,7 @@ private DocumentValidationMiddleware( public async ValueTask InvokeAsync(IRequestContext context) { - if (context.Document is null || context.DocumentId is null) + if (context.Document is null || OperationDocumentId.IsNullOrEmpty(context.DocumentId)) { context.Result = StateInvalidForDocumentValidation(); } @@ -45,7 +45,7 @@ await _documentValidator .ValidateAsync( context.Schema, context.Document, - context.DocumentId, + context.DocumentId.Value, context.ContextData, context.ValidationResult is not null, context.RequestAborted) @@ -73,7 +73,7 @@ await _documentValidator resultContextData.Add(HttpStatusCode, value); } - context.Result = QueryResultBuilder.CreateError( + context.Result = OperationResultBuilder.CreateError( validationResult.Errors, resultContextData); diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/ExceptionMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/ExceptionMiddleware.cs index 7c08d665c0f..31228cb2b4f 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/ExceptionMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/ExceptionMiddleware.cs @@ -31,13 +31,13 @@ public async ValueTask InvokeAsync(IRequestContext context) catch (GraphQLException ex) { context.Exception = ex; - context.Result = QueryResultBuilder.CreateError(_errorHandler.Handle(ex.Errors)); + context.Result = OperationResultBuilder.CreateError(_errorHandler.Handle(ex.Errors)); } catch (Exception ex) { context.Exception = ex; var error = _errorHandler.CreateUnexpectedError(ex).Build(); - context.Result = QueryResultBuilder.CreateError(_errorHandler.Handle(error)); + context.Result = OperationResultBuilder.CreateError(_errorHandler.Handle(error)); } } diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/OnlyPersistedQueriesAllowedMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/OnlyPersistedQueriesAllowedMiddleware.cs index 75922bb74f1..d3a7e96ce7a 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/OnlyPersistedQueriesAllowedMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/OnlyPersistedQueriesAllowedMiddleware.cs @@ -12,7 +12,7 @@ internal sealed class OnlyPersistedQueriesAllowedMiddleware private readonly RequestDelegate _next; private readonly IExecutionDiagnosticEvents _diagnosticEvents; private readonly bool _allowAllQueries; - private readonly IQueryResult _errorResult; + private readonly IOperationResult _errorResult; private readonly GraphQLException _exception; private readonly Dictionary _statusCode = new() { { WellKnownContextData.HttpStatusCode, 400 }, }; @@ -34,14 +34,14 @@ private OnlyPersistedQueriesAllowedMiddleware( // prepare options. _allowAllQueries = !options.OnlyAllowPersistedQueries; var error = options.OnlyPersistedQueriesAreAllowedError; - _errorResult = QueryResultBuilder.CreateError(error, _statusCode); + _errorResult = OperationResultBuilder.CreateError(error, _statusCode); _exception = new GraphQLException(error); } public ValueTask InvokeAsync(IRequestContext context) { if (_allowAllQueries || - context.Request.Query is null || + context.Request.Document is null || context.ContextData.ContainsKey(WellKnownContextData.NonPersistedQueryAllowed)) { return _next(context); diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/OperationCacheMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/OperationCacheMiddleware.cs index 1fb45254cc7..9a7957fc766 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/OperationCacheMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/OperationCacheMiddleware.cs @@ -26,7 +26,7 @@ private OperationCacheMiddleware(RequestDelegate next, public async ValueTask InvokeAsync(IRequestContext context) { - if (context.DocumentId is null) + if (OperationDocumentId.IsNullOrEmpty(context.DocumentId)) { await _next(context).ConfigureAwait(false); } @@ -37,7 +37,7 @@ public async ValueTask InvokeAsync(IRequestContext context) if (operationId is null) { - operationId = context.CreateCacheId(context.DocumentId, context.Request.OperationName); + operationId = context.CreateCacheId(context.DocumentId.Value.Value, context.Request.OperationName); context.OperationId = operationId; } @@ -52,7 +52,7 @@ public async ValueTask InvokeAsync(IRequestContext context) if (addToCache && context.Operation is not null && - context.DocumentId is not null && + !OperationDocumentId.IsNullOrEmpty(context.DocumentId) && context.Document is not null && context.IsValidDocument) { diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/OperationComplexityMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/OperationComplexityMiddleware.cs deleted file mode 100644 index d0bb699d316..00000000000 --- a/src/HotChocolate/Core/src/Execution/Pipeline/OperationComplexityMiddleware.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Threading.Tasks; -using HotChocolate.Execution.Caching; -using HotChocolate.Execution.Options; -using HotChocolate.Execution.Pipeline.Complexity; -using HotChocolate.Execution.Processing; -using HotChocolate.Language; -using HotChocolate.Validation; -using Microsoft.Extensions.DependencyInjection; -using static HotChocolate.Execution.ErrorHelper; -using static HotChocolate.Execution.Pipeline.PipelineTools; -using static HotChocolate.WellKnownContextData; - -namespace HotChocolate.Execution.Pipeline; - -internal sealed class OperationComplexityMiddleware -{ - private readonly RequestDelegate _next; - private readonly DocumentValidatorContextPool _contextPool; - private readonly ComplexityAnalyzerSettings _settings; - private readonly IComplexityAnalyzerCache _cache; - private readonly ComplexityAnalyzerCompiler _compiler; - private readonly VariableCoercionHelper _coercionHelper; - - private OperationComplexityMiddleware( - RequestDelegate next, - DocumentValidatorContextPool contextPool, - [SchemaService] IComplexityAnalyzerOptionsAccessor options, - IComplexityAnalyzerCache cache, - VariableCoercionHelper coercionHelper) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - _next = next ?? - throw new ArgumentNullException(nameof(next)); - _contextPool = contextPool ?? - throw new ArgumentNullException(nameof(contextPool)); - _settings = options.Complexity; - _cache = cache ?? - throw new ArgumentNullException(nameof(cache)); - _coercionHelper = coercionHelper ?? - throw new ArgumentNullException(nameof(coercionHelper)); - - _compiler = new ComplexityAnalyzerCompiler(_settings); - } - - public async ValueTask InvokeAsync(IRequestContext context) - { - if (!_settings.Enable || context.ContextData.ContainsKey(SkipComplexityAnalysis)) - { - await _next(context).ConfigureAwait(false); - } - else - { - if (context.DocumentId is not null && - context.OperationId is not null && - context.Document is not null) - { - var diagnostic = context.DiagnosticEvents; - - using (diagnostic.AnalyzeOperationComplexity(context)) - { - var document = context.Document; - var operationDefinition = - context.Operation?.Definition ?? - document.GetOperation(context.Request.OperationName); - - if (!_cache.TryGetAnalyzer(context.OperationId, out var analyzer)) - { - analyzer = CompileAnalyzer( - context, - document, - operationDefinition, - context.OperationId); - diagnostic.OperationComplexityAnalyzerCompiled(context); - } - - CoerceVariables( - context, - _coercionHelper, - operationDefinition.VariableDefinitions); - - var complexity = analyzer(context.Services, context.Variables!); - var allowedComplexity = GetMaximumAllowedComplexity(context); - context.ContextData[_settings.ContextDataKey] = complexity; - diagnostic.OperationComplexityResult(context, complexity, allowedComplexity); - - if (complexity <= allowedComplexity) - { - await _next(context).ConfigureAwait(false); - } - else - { - context.Result = MaxComplexityReached(complexity, _settings.MaximumAllowed); - } - } - } - else - { - context.Result = StateInvalidForComplexityAnalyzer(); - } - } - } - - private ComplexityAnalyzerDelegate CompileAnalyzer( - IRequestContext requestContext, - DocumentNode document, - OperationDefinitionNode operationDefinition, - string operationId) - { - var validatorContext = _contextPool.Get(); - - try - { - PrepareContext(requestContext, document, validatorContext); - _compiler.Visit(operationDefinition, validatorContext); - var analyzer = (OperationComplexityAnalyzer)validatorContext.List.Pop()!; - _cache.TryAddAnalyzer(operationId, analyzer.Analyzer); - return analyzer.Analyzer; - } - finally - { - validatorContext.Clear(); - _contextPool.Return(validatorContext); - } - } - - private static void PrepareContext( - IRequestContext requestContext, - DocumentNode document, - DocumentValidatorContext validatorContext) - { - validatorContext.Schema = requestContext.Schema; - - for (var i = 0; i < document.Definitions.Count; i++) - { - if (document.Definitions[i] is FragmentDefinitionNode fragmentDefinition) - { - validatorContext.Fragments[fragmentDefinition.Name.Value] = fragmentDefinition; - } - } - - validatorContext.ContextData = requestContext.ContextData; - } - - private int GetMaximumAllowedComplexity(IRequestContext requestContext) - { - if (requestContext.ContextData.TryGetValue(MaximumAllowedComplexity, out var value) && - value is int allowedComplexity) - { - return allowedComplexity; - } - - return _settings.MaximumAllowed; - } - - public static RequestCoreMiddleware Create() - => (core, next) => - { - var contextPool = core.Services.GetRequiredService(); - var options = core.SchemaServices.GetRequiredService(); - var cache = core.Services.GetRequiredService(); - var coercionHelper = core.Services.GetRequiredService(); - var middleware = new OperationComplexityMiddleware(next, contextPool, options, cache, coercionHelper); - return context => middleware.InvokeAsync(context); - }; -} diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/OperationExecutionMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/OperationExecutionMiddleware.cs index 825aad6e45a..d60f5810ee7 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/OperationExecutionMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/OperationExecutionMiddleware.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using HotChocolate.Execution.DependencyInjection; using HotChocolate.Execution.Processing; @@ -19,8 +20,9 @@ internal sealed class OperationExecutionMiddleware private readonly ITransactionScopeHandler _transactionScopeHandler; private object? _cachedQuery; private object? _cachedMutation; - - private OperationExecutionMiddleware(RequestDelegate next, + + private OperationExecutionMiddleware( + RequestDelegate next, IFactory contextFactory, [SchemaService] QueryExecutor queryExecutor, [SchemaService] SubscriptionExecutor subscriptionExecutor, @@ -49,18 +51,33 @@ public async ValueTask InvokeAsync( if (context.Operation is not null && context.Variables is not null) { - if (IsOperationAllowed(context.Operation, context.Request)) + if (!IsOperationAllowed(context.Operation, context.Request)) + { + context.Result = ErrorHelper.OperationKindNotAllowed(); + return; + } + + if (!IsRequestTypeAllowed(context.Operation, context.Variables)) { - using (context.DiagnosticEvents.ExecuteOperation(context)) + context.Result = ErrorHelper.RequestTypeNotAllowed(); + return; + } + + using (context.DiagnosticEvents.ExecuteOperation(context)) + { + if ((context.Variables?.Count ?? 0) is 0 or 1) { - await ExecuteOperationAsync(context, batchDispatcher, context.Operation) + await ExecuteOperationRequestAsync(context, batchDispatcher, context.Operation) + .ConfigureAwait(false); + } + else + { + await ExecuteVariableBatchRequestAsync(context, batchDispatcher, context.Operation) .ConfigureAwait(false); } } - else - { - context.Result = ErrorHelper.OperationKindNotAllowed(); - } + + await _next(context).ConfigureAwait(false); } else { @@ -68,12 +85,12 @@ await ExecuteOperationAsync(context, batchDispatcher, context.Operation) } } - private async Task ExecuteOperationAsync( + private async Task ExecuteOperationRequestAsync( IRequestContext context, IBatchDispatcher batchDispatcher, IOperation operation) { - if (operation.Definition.Operation == OperationType.Subscription) + if (operation.Definition.Operation is OperationType.Subscription) { // since the request context is pooled we need to clone the context for // long running executions. @@ -82,59 +99,127 @@ private async Task ExecuteOperationAsync( context.Result = await _subscriptionExecutor .ExecuteAsync(cloned, () => GetQueryRootValue(cloned)) .ConfigureAwait(false); - - await _next(cloned).ConfigureAwait(false); } else { - var operationContextOwner = _contextFactory.Create(); - var operationContext = operationContextOwner.OperationContext; - - try - { + context.Result = await ExecuteQueryOrMutationAsync( - context, - batchDispatcher, - operation, - operationContext) + context, + batchDispatcher, + operation, + context.Variables![0]) .ConfigureAwait(false); + } + } - if (operationContext.DeferredScheduler.HasResults && - context.Result is IQueryResult result) - { - var results = operationContext.DeferredScheduler.CreateResultStream(result); - var responseStream = new ResponseStream( - () => results, - ExecutionResultKind.DeferredResult); - responseStream.RegisterForCleanup(result); - responseStream.RegisterForCleanup(operationContextOwner); - context.Result = responseStream; - operationContextOwner = null; - } + private async Task ExecuteVariableBatchRequestAsync( + IRequestContext context, + IBatchDispatcher batchDispatcher, + IOperation operation) + { + var variableSet = context.Variables!; + var variableSetCount = variableSet.Count; + var tasks = new Task[variableSetCount]; - await _next(context).ConfigureAwait(false); - } - catch (OperationCanceledException) - { - // if an operation is canceled we will abandon the the rented operation context - // to ensure that that abandoned tasks to not leak execution into new operations. - operationContextOwner = null; + for (var i = 0; i < variableSetCount; i++) + { + tasks[i] = ExecuteQueryOrMutationNoStreamAsync(context, batchDispatcher, operation, variableSet[i], i); + } - // we rethrow so that another middleware can deal with the cancellation. - throw; - } - finally + var results = await Task.WhenAll(tasks).ConfigureAwait(false); + context.Result = new OperationResultBatch(results); + } + + private async Task ExecuteQueryOrMutationAsync( + IRequestContext context, + IBatchDispatcher batchDispatcher, + IOperation operation, + IVariableValueCollection variables) + { + var operationContextOwner = _contextFactory.Create(); + var operationContext = operationContextOwner.OperationContext; + + try + { + var result = + await ExecuteQueryOrMutationAsync( + context, + batchDispatcher, + operation, + operationContext, + variables) + .ConfigureAwait(false); + + if (operationContext.DeferredScheduler.HasResults) { - operationContextOwner?.Dispose(); + var results = operationContext.DeferredScheduler.CreateResultStream(result); + var responseStream = new ResponseStream(() => results, ExecutionResultKind.DeferredResult); + responseStream.RegisterForCleanup(result); + responseStream.RegisterForCleanup(operationContextOwner); + operationContextOwner = null; + return responseStream; } + + return result; + } + catch (OperationCanceledException) + { + // if an operation is canceled we will abandon the the rented operation context + // to ensure that that abandoned tasks to not leak execution into new operations. + operationContextOwner = null; + + // we rethrow so that another middleware can deal with the cancellation. + throw; + } + finally + { + operationContextOwner?.Dispose(); + } + } + + private async Task ExecuteQueryOrMutationNoStreamAsync( + IRequestContext context, + IBatchDispatcher batchDispatcher, + IOperation operation, + IVariableValueCollection variables, + int? variableIndex = null) + { + var operationContextOwner = _contextFactory.Create(); + var operationContext = operationContextOwner.OperationContext; + + try + { + return await ExecuteQueryOrMutationAsync( + context, + batchDispatcher, + operation, + operationContext, + variables, + variableIndex) + .ConfigureAwait(false); + } + catch (OperationCanceledException) + { + // if an operation is canceled we will abandon the the rented operation context + // to ensure that that abandoned tasks to not leak execution into new operations. + operationContextOwner = null; + + // we rethrow so that another middleware can deal with the cancellation. + throw; + } + finally + { + operationContextOwner?.Dispose(); } } - private async Task ExecuteQueryOrMutationAsync( + private async Task ExecuteQueryOrMutationAsync( IRequestContext context, IBatchDispatcher batchDispatcher, IOperation operation, - OperationContext operationContext) + OperationContext operationContext, + IVariableValueCollection variables, + int? variableIndex = null) { if (operation.Definition.Operation is OperationType.Query) { @@ -145,18 +230,17 @@ private async Task ExecuteQueryOrMutationAsync( context.Services, batchDispatcher, operation, - context.Variables!, + variables, query, - () => query); + () => query, + variableIndex); - context.Result = await _queryExecutor - .ExecuteAsync(operationContext) - .ConfigureAwait(false); + return await _queryExecutor.ExecuteAsync(operationContext).ConfigureAwait(false); } - else if (operation.Definition.Operation is OperationType.Mutation) + + if (operation.Definition.Operation is OperationType.Mutation) { - using var transactionScope = - _transactionScopeHandler.Create(context); + using var transactionScope = _transactionScopeHandler.Create(context); var mutation = GetMutationRootValue(context); @@ -165,16 +249,22 @@ private async Task ExecuteQueryOrMutationAsync( context.Services, batchDispatcher, operation, - context.Variables!, + variables, mutation, - () => GetQueryRootValue(context)); - - context.Result = await _queryExecutor - .ExecuteAsync(operationContext) - .ConfigureAwait(false); + () => GetQueryRootValue(context), + variableIndex); + var result = await _queryExecutor.ExecuteAsync(operationContext).ConfigureAwait(false); + + // we capture the result here so that we can capture it in the transaction scope. + context.Result = result; + + // we complete the transaction scope and are done. transactionScope.Complete(); + return result; } + + throw new InvalidOperationException(); } private object? GetQueryRootValue(IRequestContext context) @@ -191,7 +281,7 @@ private async Task ExecuteQueryOrMutationAsync( context.Schema.MutationType!, ref _cachedMutation); - private static bool IsOperationAllowed(IOperation operation, IQueryRequest request) + private static bool IsOperationAllowed(IOperation operation, IOperationRequest request) { if (request.Flags is AllowAll) { @@ -214,6 +304,19 @@ private static bool IsOperationAllowed(IOperation operation, IQueryRequest reque return allowed; } + private static bool IsRequestTypeAllowed( + IOperation operation, + IReadOnlyList? variables) + { + if (variables is { Count: > 1, }) + { + return operation.Definition.Operation is not OperationType.Subscription && + !operation.HasIncrementalParts; + } + + return true; + } + public static RequestCoreMiddleware Create() => (core, next) => { @@ -227,7 +330,7 @@ public static RequestCoreMiddleware Create() queryExecutor, subscriptionExecutor, transactionScopeHandler); - + return async context => { var batchDispatcher = context.Services.GetService(); diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/OperationResolverMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/OperationResolverMiddleware.cs index 257d98021e3..28c1cbd797d 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/OperationResolverMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/OperationResolverMiddleware.cs @@ -5,12 +5,9 @@ using HotChocolate.Execution.Processing; using HotChocolate.Language; using HotChocolate.Types; -using HotChocolate.Utilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ObjectPool; using static HotChocolate.Execution.ErrorHelper; -using static HotChocolate.WellKnownDirectives; -using static HotChocolate.Execution.Pipeline.PipelineTools; using static HotChocolate.WellKnownContextData; namespace HotChocolate.Execution.Pipeline; @@ -19,14 +16,12 @@ internal sealed class OperationResolverMiddleware { private readonly RequestDelegate _next; private readonly ObjectPool _operationCompilerPool; - private readonly VariableCoercionHelper _coercionHelper; - private readonly IReadOnlyList? _optimizers; + private readonly IOperationCompilerOptimizer[]? _optimizers; private OperationResolverMiddleware( RequestDelegate next, ObjectPool operationCompilerPool, - IEnumerable optimizers, - VariableCoercionHelper coercionHelper) + IEnumerable optimizers) { if (optimizers is null) { @@ -37,9 +32,12 @@ private OperationResolverMiddleware( throw new ArgumentNullException(nameof(next)); _operationCompilerPool = operationCompilerPool ?? throw new ArgumentNullException(nameof(operationCompilerPool)); - _coercionHelper = coercionHelper ?? - throw new ArgumentNullException(nameof(coercionHelper)); _optimizers = optimizers.ToArray(); + + if (_optimizers.Length == 0) + { + _optimizers = null; + } } public async ValueTask InvokeAsync(IRequestContext context) @@ -91,7 +89,7 @@ private IOperation CompileOperation( context.Document!, context.Schema, _optimizers, - IsNullBubblingEnabled(context, operationDefinition)); + IsNullBubblingEnabled(context)); _operationCompilerPool.Return(compiler); return operation; } @@ -107,61 +105,9 @@ private IOperation CompileOperation( _ => throw ThrowHelper.RootTypeNotSupported(operationType), }; - private bool IsNullBubblingEnabled(IRequestContext context, OperationDefinitionNode operationDefinition) - { - if (!context.Schema.ContextData.ContainsKey(EnableTrueNullability) || - operationDefinition.Directives.Count == 0) - { - return true; - } - - var enabled = true; - - for (var i = 0; i < operationDefinition.Directives.Count; i++) - { - var directive = operationDefinition.Directives[i]; - - if (!directive.Name.Value.EqualsOrdinal(NullBubbling)) - { - continue; - } - - for (var j = 0; j < directive.Arguments.Count; j++) - { - var argument = directive.Arguments[j]; - - if (argument.Name.Value.EqualsOrdinal(Enable)) - { - if (argument.Value is BooleanValueNode b) - { - enabled = b.Value; - break; - } - - if (argument.Value is VariableNode v) - { - enabled = CoerceVariable(context, operationDefinition, v); - break; - } - - throw new GraphQLException(NoNullBubbling_ArgumentValue_NotAllowed(argument)); - } - } - - break; - } - - return enabled; - } - - private bool CoerceVariable( - IRequestContext context, - OperationDefinitionNode operationDefinition, - VariableNode variable) - { - var variables = CoerceVariables(context, _coercionHelper, operationDefinition.VariableDefinitions); - return variables.GetVariable(variable.Name.Value); - } + private bool IsNullBubblingEnabled(IRequestContext context) + => !context.Schema.ContextData.ContainsKey(EnableTrueNullability) || + !context.ContextData.ContainsKey(EnableTrueNullability); public static RequestCoreMiddleware Create() => (core, next) => @@ -169,12 +115,8 @@ public static RequestCoreMiddleware Create() var operationCompilerPool = core.Services.GetRequiredService>(); var optimizers1 = core.Services.GetRequiredService>(); var optimizers2 = core.SchemaServices.GetRequiredService>(); - var coercionHelper = core.Services.GetRequiredService(); - var middleware = new OperationResolverMiddleware( - next, - operationCompilerPool, - optimizers1.Concat(optimizers2), - coercionHelper); + optimizers1 = optimizers1.Concat(optimizers2); + var middleware = new OperationResolverMiddleware(next, operationCompilerPool, optimizers1); return context => middleware.InvokeAsync(context); }; } \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/PersistedQueryNotFoundMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/PersistedQueryNotFoundMiddleware.cs index be903bf5706..39e393f1002 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/PersistedQueryNotFoundMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/PersistedQueryNotFoundMiddleware.cs @@ -25,22 +25,22 @@ private PersistedQueryNotFoundMiddleware( public ValueTask InvokeAsync(IRequestContext context) { - if (context.Document is not null || context.Request.Query is not null) + if (context.Document is not null || context.Request.Document is not null) { return _next(context); } var requestedKey = - context.Request.QueryId ?? + context.Request.DocumentId ?? context.DocumentId ?? context.DocumentHash ?? - context.Request.QueryHash; + context.Request.DocumentHash; // we know that the key is not null since otherwise the request would have // failed already since no query is specified. - var error = ErrorHelper.PersistedQueryNotFound(requestedKey!); + var error = ErrorHelper.PersistedQueryNotFound(requestedKey!.Value); _diagnosticEvents.RequestError(context, new GraphQLException(error)); - context.Result = QueryResultBuilder.CreateError(error, _statusCode); + context.Result = OperationResultBuilder.CreateError(error, _statusCode); return default; } diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/PipelineTools.cs b/src/HotChocolate/Core/src/Execution/Pipeline/PipelineTools.cs index 3e72a233cf9..fe5d3558afd 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/PipelineTools.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/PipelineTools.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using HotChocolate.Execution.Processing; @@ -8,11 +9,14 @@ namespace HotChocolate.Execution.Pipeline; internal static class PipelineTools { private static readonly Dictionary _empty = new(); - private static readonly VariableValueCollection _noVariables = VariableValueCollection.Empty; + + private static readonly IReadOnlyList _noVariables = [VariableValueCollection.Empty,]; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string CreateOperationId(string documentId, string? operationName) - => operationName is null ? documentId : $"{documentId}+{operationName}"; + => operationName is null + ? documentId + : $"{documentId}+{operationName}"; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string CreateCacheId(this IRequestContext context, string operationId) @@ -25,7 +29,7 @@ public static string CreateCacheId( string? operationName) => CreateCacheId(context, CreateOperationId(documentId, operationName)); - public static IVariableValueCollection CoerceVariables( + public static IReadOnlyList CoerceVariables( IRequestContext context, VariableCoercionHelper coercionHelper, IReadOnlyList variableDefinitions) @@ -40,7 +44,8 @@ public static IVariableValueCollection CoerceVariables( context.Variables = _noVariables; return _noVariables; } - else + + if (context.Request is OperationRequest operationRequest) { using (context.DiagnosticEvents.CoerceVariables(context)) { @@ -49,12 +54,41 @@ public static IVariableValueCollection CoerceVariables( coercionHelper.CoerceVariableValues( context.Schema, variableDefinitions, - context.Request.VariableValues ?? _empty, + operationRequest.VariableValues ?? _empty, coercedValues); - context.Variables = new VariableValueCollection(coercedValues); + context.Variables = new[] { new VariableValueCollection(coercedValues), }; + return context.Variables; + } + } + + if (context.Request is VariableBatchRequest variableBatchRequest) + { + using (context.DiagnosticEvents.CoerceVariables(context)) + { + var schema = context.Schema; + var variableSetCount = variableBatchRequest.VariableValues?.Count ?? 0; + var variableSetInput = variableBatchRequest.VariableValues!; + var variableSet = new IVariableValueCollection[variableSetCount]; + + for (var i = 0; i < variableSetCount; i++) + { + var coercedValues = new Dictionary(); + + coercionHelper.CoerceVariableValues( + schema, + variableDefinitions, + variableSetInput[i], + coercedValues); + + variableSet[i] = new VariableValueCollection(coercedValues); + } + + context.Variables = variableSet; return context.Variables; } } + + throw new NotSupportedException("Request type not supported."); } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/ReadPersistedQueryMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/ReadPersistedQueryMiddleware.cs index 9290caf4504..afd5d47416c 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/ReadPersistedQueryMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/ReadPersistedQueryMiddleware.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using HotChocolate.Execution.Instrumentation; +using HotChocolate.Language; using HotChocolate.Validation; using Microsoft.Extensions.DependencyInjection; @@ -10,24 +11,24 @@ internal sealed class ReadPersistedQueryMiddleware { private readonly RequestDelegate _next; private readonly IExecutionDiagnosticEvents _diagnosticEvents; - private readonly IReadStoredQueries _persistedQueryStore; + private readonly IOperationDocumentStorage _operationDocumentStorage; private ReadPersistedQueryMiddleware(RequestDelegate next, [SchemaService] IExecutionDiagnosticEvents diagnosticEvents, - [SchemaService] IReadStoredQueries persistedQueryStore) + [SchemaService] IOperationDocumentStorage operationDocumentStorage) { _next = next ?? throw new ArgumentNullException(nameof(next)); _diagnosticEvents = diagnosticEvents ?? throw new ArgumentNullException(nameof(diagnosticEvents)); - _persistedQueryStore = persistedQueryStore ?? - throw new ArgumentNullException(nameof(persistedQueryStore)); + _operationDocumentStorage = operationDocumentStorage ?? + throw new ArgumentNullException(nameof(operationDocumentStorage)); } public async ValueTask InvokeAsync(IRequestContext context) { if (context.Document is null && - context.Request.Query is null) + context.Request.Document is null) { await TryLoadQueryAsync(context).ConfigureAwait(false); } @@ -37,23 +38,33 @@ public async ValueTask InvokeAsync(IRequestContext context) private async ValueTask TryLoadQueryAsync(IRequestContext context) { - var queryId = - context.Request.QueryId ?? + var documentId = + context.Request.DocumentId ?? context.DocumentId ?? context.DocumentHash ?? - context.Request.QueryHash; - - if (queryId is not null) + context.Request.DocumentHash; + + if (!OperationDocumentId.IsNullOrEmpty(documentId)) { - var queryDocument = - await _persistedQueryStore.TryReadQueryAsync( - queryId, context.RequestAborted) + var operationDocument = + await _operationDocumentStorage.TryReadAsync( + documentId.Value, context.RequestAborted) .ConfigureAwait(false); - if (queryDocument is not null) + if (operationDocument is OperationDocument parsedDoc) + { + context.DocumentId = documentId; + context.Document = parsedDoc.Document; + context.ValidationResult = DocumentValidatorResult.Ok; + context.IsCachedDocument = true; + context.IsPersistedDocument = true; + _diagnosticEvents.RetrievedDocumentFromStorage(context); + } + + if (operationDocument is OperationDocumentSourceText sourceTextDoc) { - context.DocumentId = queryId; - context.Document = queryDocument.Document; + context.DocumentId = documentId; + context.Document = Utf8GraphQLParser.Parse(sourceTextDoc.AsSpan()); context.ValidationResult = DocumentValidatorResult.Ok; context.IsCachedDocument = true; context.IsPersistedDocument = true; @@ -66,7 +77,7 @@ public static RequestCoreMiddleware Create() => (core, next) => { var diagnosticEvents = core.SchemaServices.GetRequiredService(); - var persistedQueryStore = core.SchemaServices.GetRequiredService(); + var persistedQueryStore = core.SchemaServices.GetRequiredService(); var middleware = new ReadPersistedQueryMiddleware(next, diagnosticEvents, persistedQueryStore); return context => middleware.InvokeAsync(context); }; diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/RequestClassMiddlewareFactory.cs b/src/HotChocolate/Core/src/Execution/Pipeline/RequestClassMiddlewareFactory.cs index 9bd59a25471..5f6a305e7ef 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/RequestClassMiddlewareFactory.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/RequestClassMiddlewareFactory.cs @@ -100,8 +100,7 @@ private static List CreateFactoryParameterHandlers( AddService(list, schemaServices); AddService(list, schemaServices); - AddService(list, schemaServices); - AddService(list, schemaServices); + AddService(list, schemaServices); AddService(list, schemaServices); AddService>(list, schemaServices); AddService(list, schemaServices); @@ -147,9 +146,6 @@ private static void AddOptions( parameterHandlers.Add(new TypeParameterHandler( typeof(IRequestExecutorOptionsAccessor), Expression.Constant(options))); - parameterHandlers.Add(new TypeParameterHandler( - typeof(IComplexityAnalyzerOptionsAccessor), - Expression.Constant(options))); parameterHandlers.Add(new TypeParameterHandler( typeof(IPersistedQueryOptionsAccessor), Expression.Constant(options))); diff --git a/src/HotChocolate/Core/src/Execution/Pipeline/WritePersistedQueryMiddleware.cs b/src/HotChocolate/Core/src/Execution/Pipeline/WritePersistedQueryMiddleware.cs index de2d131fac8..cce10e55eda 100644 --- a/src/HotChocolate/Core/src/Execution/Pipeline/WritePersistedQueryMiddleware.cs +++ b/src/HotChocolate/Core/src/Execution/Pipeline/WritePersistedQueryMiddleware.cs @@ -16,18 +16,18 @@ internal sealed class WritePersistedQueryMiddleware private const string _expectedFormat = "expectedHashFormat"; private readonly RequestDelegate _next; private readonly IDocumentHashProvider _hashProvider; - private readonly IWriteStoredQueries _persistedQueryStore; + private readonly IOperationDocumentStorage _operationDocumentStorage; private WritePersistedQueryMiddleware(RequestDelegate next, IDocumentHashProvider documentHashProvider, - [SchemaService] IWriteStoredQueries persistedQueryStore) + [SchemaService] IOperationDocumentStorage operationDocumentStorage) { _next = next ?? throw new ArgumentNullException(nameof(next)); _hashProvider = documentHashProvider ?? throw new ArgumentNullException(nameof(documentHashProvider)); - _persistedQueryStore = persistedQueryStore ?? - throw new ArgumentNullException(nameof(persistedQueryStore)); + _operationDocumentStorage = operationDocumentStorage ?? + throw new ArgumentNullException(nameof(operationDocumentStorage)); } public async ValueTask InvokeAsync(IRequestContext context) @@ -35,25 +35,25 @@ public async ValueTask InvokeAsync(IRequestContext context) await _next(context).ConfigureAwait(false); if (!context.IsCachedDocument && - context.Document is { } && + context.Document is not null && context.DocumentId is { } documentId && - context.Request.Query is { } query && - context.Result is IQueryResult result && + context.Request.Document is { } document && + context.Result is IOperationResult result && context.IsValidDocument && - context.Request.Extensions is { } && + context.Request.Extensions is not null && context.Request.Extensions.TryGetValue(_persistedQuery, out var s) && s is IReadOnlyDictionary settings) { - IQueryResultBuilder builder = QueryResultBuilder.FromResult(result); + var resultBuilder = OperationResultBuilder.FromResult(result); // hash is found and matches the query key -> store the query if (DoHashesMatch(settings, documentId, _hashProvider.Name, out var userHash)) { // save the query - await _persistedQueryStore.WriteQueryAsync(documentId, query).ConfigureAwait(false); + await _operationDocumentStorage.SaveAsync(documentId, document).ConfigureAwait(false); // add persistence receipt to the result - builder.SetExtension( + resultBuilder.SetExtension( _persistedQuery, new Dictionary { @@ -65,7 +65,7 @@ context.Request.Extensions is { } && } else { - builder.SetExtension( + resultBuilder.SetExtension( _persistedQuery, new Dictionary { @@ -77,13 +77,13 @@ context.Request.Extensions is { } && }); } - context.Result = builder.Create(); + context.Result = resultBuilder.Build(); } } private static bool DoHashesMatch( IReadOnlyDictionary settings, - string? expectedHash, + OperationDocumentId expectedHash, string hashName, [NotNullWhen(true)] out string? userHash) { @@ -91,18 +91,18 @@ private static bool DoHashesMatch( h is string hash) { userHash = hash; - return hash.Equals(expectedHash, StringComparison.Ordinal); + return hash.Equals(expectedHash.Value, StringComparison.Ordinal); } userHash = null; return false; } - + public static RequestCoreMiddleware Create() => (core, next) => { var documentHashProvider = core.Services.GetRequiredService(); - var persistedQueryStore = core.SchemaServices.GetRequiredService(); + var persistedQueryStore = core.SchemaServices.GetRequiredService(); var middleware = new WritePersistedQueryMiddleware(next, documentHashProvider, persistedQueryStore); return context => middleware.InvokeAsync(context); }; diff --git a/src/HotChocolate/Core/src/Execution/Processing/DefaultTransactionScope.cs b/src/HotChocolate/Core/src/Execution/Processing/DefaultTransactionScope.cs index f80640cf0fd..2b0b022973b 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/DefaultTransactionScope.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/DefaultTransactionScope.cs @@ -37,7 +37,7 @@ public DefaultTransactionScope(IRequestContext context, TransactionScope transac /// public void Complete() { - if (Context.Result is QueryResult { Data: not null, Errors: null or { Count: 0, }, }) + if (Context.Result is OperationResult { Data: not null, Errors: null or { Count: 0, }, }) { Transaction.Complete(); } diff --git a/src/HotChocolate/Core/src/Execution/Processing/DeferredExecutionTaskResult.cs b/src/HotChocolate/Core/src/Execution/Processing/DeferredExecutionTaskResult.cs index 247e81e18d5..a5ea8798fc9 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/DeferredExecutionTaskResult.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/DeferredExecutionTaskResult.cs @@ -5,7 +5,7 @@ internal readonly struct DeferredExecutionTaskResult public DeferredExecutionTaskResult( uint taskId, uint parentTaskId, - IQueryResult? result = null) + IOperationResult? result = null) { TaskId = taskId; ParentTaskId = parentTaskId; @@ -16,5 +16,5 @@ public DeferredExecutionTaskResult( public uint ParentTaskId { get; } - public IQueryResult? Result { get; } + public IOperationResult? Result { get; } } diff --git a/src/HotChocolate/Core/src/Execution/Processing/DeferredStream.cs b/src/HotChocolate/Core/src/Execution/Processing/DeferredStream.cs index 4fde999aa77..2742c6b87cb 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/DeferredStream.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/DeferredStream.cs @@ -109,7 +109,7 @@ protected override async Task ExecuteAsync( catch (Exception ex) { var builder = operationContext.ErrorHandler.CreateUnexpectedError(ex); - var result = QueryResultBuilder.CreateError(builder.Build()); + var result = OperationResultBuilder.CreateError(builder.Build()); operationContext.DeferredScheduler.Complete(new(resultId, parentResultId, result)); } finally diff --git a/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs b/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs index 43fb397d8df..affdc984820 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs @@ -3,7 +3,7 @@ using HotChocolate.Execution.DependencyInjection; using HotChocolate.Execution.Instrumentation; using Microsoft.Extensions.DependencyInjection; -using static HotChocolate.Execution.QueryResultBuilder; +using static HotChocolate.Execution.OperationResultBuilder; namespace HotChocolate.Execution.Processing; @@ -94,7 +94,7 @@ public void Register(DeferredExecutionTask task, uint patchId) public void Complete(DeferredExecutionTaskResult result) => StateOwner.State.Complete(result); - public IAsyncEnumerable CreateResultStream(IQueryResult initialResult) + public IAsyncEnumerable CreateResultStream(IOperationResult initialResult) => new DeferredResultStream( initialResult, StateOwner, @@ -109,26 +109,26 @@ public void Clear() _parentContext = default!; } - private class DeferredResultStream : IAsyncEnumerable + private class DeferredResultStream : IAsyncEnumerable { - private readonly IQueryResult _initialResult; + private readonly IOperationResult _initialResult; private readonly DeferredWorkStateOwner _stateOwner; private readonly IOperation _operation; private readonly IExecutionDiagnosticEvents _diagnosticEvents; public DeferredResultStream( - IQueryResult initialResult, + IOperationResult initialResult, DeferredWorkStateOwner stateOwner, IOperation operation, IExecutionDiagnosticEvents diagnosticEvents) { - _initialResult = FromResult(initialResult).SetHasNext(true).Create(); + _initialResult = FromResult(initialResult).SetHasNext(true).Build(); _stateOwner = stateOwner; _operation = operation; _diagnosticEvents = diagnosticEvents; } - public async IAsyncEnumerator GetAsyncEnumerator( + public async IAsyncEnumerator GetAsyncEnumerator( CancellationToken cancellationToken = default) { var span = _diagnosticEvents.ExecuteStream(_operation); @@ -155,7 +155,7 @@ public async IAsyncEnumerator GetAsyncEnumerator( { if (hasNext) { - yield return new QueryResult(null, hasNext: false); + yield return new OperationResult(null, hasNext: false); } yield break; diff --git a/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkState.cs b/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkState.cs index 3c9ace9add0..9966dddc0fa 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkState.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkState.cs @@ -14,7 +14,7 @@ internal sealed class DeferredWorkState private readonly object _patchSync = new(); private readonly List _ready = []; - private readonly Queue _deliverable = new(); + private readonly Queue _deliverable = new(); private readonly HashSet _completed = []; private readonly HashSet _notPatchable = []; private SemaphoreSlim _semaphore = new(0); @@ -108,7 +108,7 @@ public void Complete(DeferredExecutionTaskResult result) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void EnqueueResult(IQueryResult? queryResult) + private void EnqueueResult(IOperationResult? queryResult) { lock (_deliverSync) { @@ -123,7 +123,7 @@ private void EnqueueResult(IQueryResult? queryResult) } } - public async ValueTask TryDequeueResultsAsync( + public async ValueTask TryDequeueResultsAsync( CancellationToken cancellationToken) { await _semaphore.WaitAsync(cancellationToken); @@ -133,7 +133,7 @@ private void EnqueueResult(IQueryResult? queryResult) if (_deliverable.Count > 0) { var hasNext = true; - var result = new IQueryResult[_deliverable.Count]; + var result = new IOperationResult[_deliverable.Count]; var consumed = 0; for (var i = 0; i < result.Length; i++) @@ -169,14 +169,14 @@ value is uint patchId && Array.Resize(ref result, consumed); } - return new QueryResult(null, incremental: result, hasNext: hasNext); + return new OperationResult(null, incremental: result, hasNext: hasNext); } } return null; static void AddRemovedResultSetsToNotPatchable( - IQueryResult result, + IOperationResult result, HashSet notPatchable) { if ((result.ContextData?.TryGetValue(RemovedResults, out var value) ?? false) && @@ -190,7 +190,7 @@ static void AddRemovedResultSetsToNotPatchable( } static void AddAllResultSetsToNotPatchable( - IQueryResult result, + IOperationResult result, HashSet notPatchable) { if ((result.ContextData?.TryGetValue(ExpectedPatches, out var value) ?? false) && diff --git a/src/HotChocolate/Core/src/Execution/Processing/OperationCompiler.BacklogItem.cs b/src/HotChocolate/Core/src/Execution/Processing/OperationCompiler.BacklogItem.cs index dada1b191e1..e3cf2917a43 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/OperationCompiler.BacklogItem.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/OperationCompiler.BacklogItem.cs @@ -5,30 +5,21 @@ namespace HotChocolate.Execution.Processing; public sealed partial class OperationCompiler { - private readonly struct BacklogItem + private readonly struct BacklogItem( + ObjectType type, + int selectionSetId, + Selection selection, + SelectionPath path, + IImmutableList optimizers) { - public BacklogItem( - ObjectType type, - int selectionSetId, - Selection selection, - SelectionPath path, - IImmutableList optimizers) - { - Type = type; - SelectionSetId = selectionSetId; - Selection = selection; - Path = path; - Optimizers = optimizers; - } + public ObjectType Type { get; } = type; - public ObjectType Type { get; } + public int SelectionSetId { get; } = selectionSetId; - public int SelectionSetId { get; } + public Selection Selection { get; } = selection; - public Selection Selection { get; } + public SelectionPath Path { get; } = path; - public SelectionPath Path { get; } - - public IImmutableList Optimizers { get; } + public IImmutableList Optimizers { get; } = optimizers; } } diff --git a/src/HotChocolate/Core/src/Execution/Processing/OperationContext.Pooling.cs b/src/HotChocolate/Core/src/Execution/Processing/OperationContext.Pooling.cs index f21ce9c4ea6..6f927ac7bbe 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/OperationContext.Pooling.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/OperationContext.Pooling.cs @@ -34,6 +34,7 @@ internal sealed partial class OperationContext private Func _resolveQueryRootValue = default!; private IBatchDispatcher _batchDispatcher = default!; private InputParser _inputParser = default!; + private int? _variableIndex; private object? _rootValue; private bool _isInitialized; @@ -60,7 +61,8 @@ public void Initialize( IOperation operation, IVariableValueCollection variables, object? rootValue, - Func resolveQueryRootValue) + Func resolveQueryRootValue, + int? variableIndex = null) { _requestContext = requestContext; _schema = requestContext.Schema; @@ -76,12 +78,23 @@ public void Initialize( _rootValue = rootValue; _resolveQueryRootValue = resolveQueryRootValue; _batchDispatcher = batchDispatcher; + _variableIndex = variableIndex; _isInitialized = true; IncludeFlags = _operation.CreateIncludeFlags(variables); _workScheduler.Initialize(batchDispatcher); _deferredWorkScheduler.Initialize(this); _resultBuilder.Initialize(_requestContext, _diagnosticEvents); + + if (requestContext.RequestIndex.HasValue) + { + _resultBuilder.SetRequestIndex(requestContext.RequestIndex.Value); + } + + if (variableIndex.HasValue) + { + _resultBuilder.SetVariableIndex(variableIndex.Value); + } } public void InitializeFrom(OperationContext context) @@ -106,6 +119,16 @@ public void InitializeFrom(OperationContext context) _workScheduler.Initialize(_batchDispatcher); _deferredWorkScheduler.InitializeFrom(this, context._deferredWorkScheduler); _resultBuilder.Initialize(_requestContext, _diagnosticEvents); + + if (context._requestContext.RequestIndex.HasValue) + { + _resultBuilder.SetRequestIndex(context._requestContext.RequestIndex.Value); + } + + if (context._variableIndex.HasValue) + { + _resultBuilder.SetVariableIndex(context._variableIndex.Value); + } } public void Clean() diff --git a/src/HotChocolate/Core/src/Execution/Processing/QueryExecutor.cs b/src/HotChocolate/Core/src/Execution/Processing/QueryExecutor.cs index 015951ccb30..721f5426b69 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/QueryExecutor.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/QueryExecutor.cs @@ -7,11 +7,11 @@ namespace HotChocolate.Execution.Processing; internal sealed class QueryExecutor { - public Task ExecuteAsync( + public Task ExecuteAsync( OperationContext operationContext) => ExecuteAsync(operationContext, ImmutableDictionary.Empty); - public Task ExecuteAsync( + public Task ExecuteAsync( OperationContext operationContext, IImmutableDictionary scopedContext) { @@ -28,7 +28,7 @@ public Task ExecuteAsync( return ExecuteInternalAsync(operationContext, scopedContext); } - private static async Task ExecuteInternalAsync( + private static async Task ExecuteInternalAsync( OperationContext operationContext, IImmutableDictionary scopedContext) { diff --git a/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.Pooling.cs b/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.Pooling.cs index fc050089fee..e5b0709fd12 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.Pooling.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.Pooling.cs @@ -41,6 +41,8 @@ public void Clear() _path = null; _label = null; _hasNext = null; + _requestIndex = null; + _variableIndex = null; } private void InitializeResult() diff --git a/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.cs b/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.cs index ebc296e7169..f022b87c093 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/Result/ResultBuilder.cs @@ -27,6 +27,8 @@ internal sealed partial class ResultBuilder private Path? _path; private string? _label; private bool? _hasNext; + private int? _requestIndex; + private int? _variableIndex; public IReadOnlyList Errors => _errors; @@ -203,9 +205,15 @@ public void AddPatchId(uint patchId) _patchIds.Add(patchId); } } + + public void SetRequestIndex(int requestIndex) + => _requestIndex = requestIndex; + + public void SetVariableIndex(int variableIndex) + => _variableIndex = variableIndex; // ReSharper disable InconsistentlySynchronizedField - public IQueryResult BuildResult() + public IOperationResult BuildResult() { ApplyNonNullViolations(_errors, _nonNullViolations, _fieldErrors); @@ -240,7 +248,7 @@ public IQueryResult BuildResult() _contextData.Add(WellKnownContextData.ExpectedPatches, _patchIds.ToArray()); } - var result = new QueryResult( + var result = new OperationResult( _data, _errors.Count == 0 ? null : _errors.ToArray(), CreateExtensionData(_extensions), @@ -253,7 +261,9 @@ public IQueryResult BuildResult() cleanupTasks: _cleanupTasks.Count == 0 ? _emptyCleanupTasks : _cleanupTasks.ToArray(), - isDataSet: true); + isDataSet: true, + requestIndex: _requestIndex, + variableIndex: _variableIndex); if (_data is not null) { diff --git a/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.Subscription.cs b/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.Subscription.cs index 76c6a77b239..f04199a1212 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.Subscription.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.Subscription.cs @@ -106,7 +106,7 @@ public static async ValueTask SubscribeAsync( return subscription; } - public IAsyncEnumerable ExecuteAsync() + public IAsyncEnumerable ExecuteAsync() => new SubscriptionEnumerable( _sourceStream, OnEvent, @@ -139,7 +139,7 @@ public async ValueTask DisposeAsync() /// /// Returns a query result which will be enqueued to the response stream. /// - private async Task OnEvent(object payload) + private async Task OnEvent(object payload) { using var es = _diagnosticEvents.OnSubscriptionEvent(new(this, payload)); using var serviceScope = _requestContext.Services.CreateScope(); @@ -171,7 +171,7 @@ private async Task OnEvent(object payload) eventServices, dispatcher, _requestContext.Operation!, - _requestContext.Variables!, + _requestContext.Variables![0], rootValue, _resolveQueryRootValue); @@ -239,7 +239,7 @@ private async ValueTask SubscribeAsync() _requestContext.Services, NoopBatchDispatcher.Default, _requestContext.Operation!, - _requestContext.Variables!, + _requestContext.Variables![0], rootValue, _resolveQueryRootValue); @@ -318,16 +318,16 @@ await rootSelection.Field.SubscribeResolver! } } - private sealed class SubscriptionEnumerable : IAsyncEnumerable + private sealed class SubscriptionEnumerable : IAsyncEnumerable { private readonly ISourceStream _sourceStream; - private readonly Func> _onEvent; + private readonly Func> _onEvent; private readonly Subscription _subscription; private readonly IExecutionDiagnosticEvents _diagnosticEvents; public SubscriptionEnumerable( ISourceStream sourceStream, - Func> onEvent, + Func> onEvent, Subscription subscription, IExecutionDiagnosticEvents diagnosticEvents) { @@ -337,7 +337,7 @@ public SubscriptionEnumerable( _diagnosticEvents = diagnosticEvents; } - public IAsyncEnumerator GetAsyncEnumerator( + public IAsyncEnumerator GetAsyncEnumerator( CancellationToken cancellationToken = default) { try @@ -361,10 +361,10 @@ public IAsyncEnumerator GetAsyncEnumerator( } } - private sealed class SubscriptionEnumerator : IAsyncEnumerator + private sealed class SubscriptionEnumerator : IAsyncEnumerator { private readonly IAsyncEnumerator _eventEnumerator; - private readonly Func> _onEvent; + private readonly Func> _onEvent; private readonly Subscription _subscription; private readonly IExecutionDiagnosticEvents _diagnosticEvents; private readonly CancellationToken _requestAborted; @@ -372,7 +372,7 @@ private sealed class SubscriptionEnumerator : IAsyncEnumerator public SubscriptionEnumerator( IAsyncEnumerator eventEnumerator, - Func> onEvent, + Func> onEvent, Subscription subscription, IExecutionDiagnosticEvents diagnosticEvents, CancellationToken requestAborted) @@ -384,7 +384,7 @@ public SubscriptionEnumerator( _requestAborted = requestAborted; } - public IQueryResult Current { get; private set; } = default!; + public IOperationResult Current { get; private set; } = default!; public async ValueTask MoveNextAsync() { @@ -420,9 +420,9 @@ public async ValueTask DisposeAsync() } } - private sealed class ErrorSubscriptionEnumerator : IAsyncEnumerator + private sealed class ErrorSubscriptionEnumerator : IAsyncEnumerator { - public IQueryResult Current => default!; + public IOperationResult Current => default!; public ValueTask MoveNextAsync() => new(false); diff --git a/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.cs b/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.cs index 58888151b9f..8e927a48581 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/SubscriptionExecutor.cs @@ -78,7 +78,7 @@ public async Task ExecuteAsync( await subscription.DisposeAsync().ConfigureAwait(false); } - return new QueryResult(null, ex.Errors); + return new OperationResult(null, ex.Errors); } catch (Exception ex) { @@ -91,7 +91,7 @@ public async Task ExecuteAsync( await subscription.DisposeAsync().ConfigureAwait(false); } - return new QueryResult(null, Unwrap(error)); + return new OperationResult(null, Unwrap(error)); } IReadOnlyList Unwrap(IError error) diff --git a/src/HotChocolate/Core/src/Execution/Processing/VariableValueCollection.cs b/src/HotChocolate/Core/src/Execution/Processing/VariableValueCollection.cs index a8d091cebcd..964feac35d3 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/VariableValueCollection.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/VariableValueCollection.cs @@ -5,15 +5,10 @@ namespace HotChocolate.Execution.Processing; -internal class VariableValueCollection : IVariableValueCollection +internal class VariableValueCollection( + Dictionary coercedValues) + : IVariableValueCollection { - private readonly Dictionary _coercedValues; - - public VariableValueCollection(Dictionary coercedValues) - { - _coercedValues = coercedValues; - } - public static VariableValueCollection Empty { get; } = new(new Dictionary()); @@ -24,7 +19,7 @@ public VariableValueCollection(Dictionary coerce return value; } - if (_coercedValues.ContainsKey(name)) + if (coercedValues.ContainsKey(name)) { throw ThrowHelper.VariableNotOfType(name, typeof(T)); } @@ -39,7 +34,7 @@ public bool TryGetVariable(string name, out T? value) throw new ArgumentNullException(nameof(name)); } - if (_coercedValues.TryGetValue(name, out var variableValue)) + if (coercedValues.TryGetValue(name, out var variableValue)) { var requestedType = typeof(T); @@ -86,7 +81,7 @@ public bool TryGetVariable(string name, out T? value) public IEnumerator GetEnumerator() { - foreach (var item in _coercedValues) + foreach (var item in coercedValues) { var type = item.Value.Type; var value = item.Value.ValueLiteral; diff --git a/src/HotChocolate/Core/src/Execution/RequestContext.cs b/src/HotChocolate/Core/src/Execution/RequestContext.cs index 85a8d4be0d9..62b327a161d 100644 --- a/src/HotChocolate/Core/src/Execution/RequestContext.cs +++ b/src/HotChocolate/Core/src/Execution/RequestContext.cs @@ -9,40 +9,35 @@ namespace HotChocolate.Execution; -internal sealed class RequestContext : IRequestContext +internal sealed class RequestContext( + ISchema schema, + ulong executorVersion, + IErrorHandler errorHandler, + IExecutionDiagnosticEvents diagnosticEvents) + : IRequestContext { private readonly ConcurrentDictionary _contextData = new(); private DocumentValidatorResult? _validationResult; - public RequestContext( - ISchema schema, - ulong executorVersion, - IErrorHandler errorHandler, - IExecutionDiagnosticEvents diagnosticEvents) - { - Schema = schema; - ExecutorVersion = executorVersion; - ErrorHandler = errorHandler; - DiagnosticEvents = diagnosticEvents; - } + public ISchema Schema { get; } = schema; - public ISchema Schema { get; } + public ulong ExecutorVersion { get; } = executorVersion; - public ulong ExecutorVersion { get; } + public int? RequestIndex { get; set; } public IServiceProvider Services { get; private set; } = default!; - public IErrorHandler ErrorHandler { get; } + public IErrorHandler ErrorHandler { get; } = errorHandler; - public IExecutionDiagnosticEvents DiagnosticEvents { get; } + public IExecutionDiagnosticEvents DiagnosticEvents { get; } = diagnosticEvents; - public IQueryRequest Request { get; private set; } = default!; + public IOperationRequest Request { get; private set; } = default!; public IDictionary ContextData => _contextData; public CancellationToken RequestAborted { get; set; } - public string? DocumentId { get; set; } + public OperationDocumentId? DocumentId { get; set; } public string? DocumentHash { get; set; } @@ -68,7 +63,7 @@ public DocumentValidatorResult? ValidationResult public IOperation? Operation { get; set; } - public IVariableValueCollection? Variables { get; set; } + public IReadOnlyList? Variables { get; set; } public IExecutionResult? Result { get; set; } @@ -95,6 +90,7 @@ public IRequestContext Clone() Variables = Variables, Result = Result, Exception = Exception, + RequestIndex = RequestIndex, }; foreach (var item in _contextData) @@ -105,17 +101,19 @@ public IRequestContext Clone() return cloned; } - public void Initialize(IQueryRequest request, IServiceProvider services) + public void Initialize(IOperationRequest request, IServiceProvider services) { Request = request; Services = services; - if (request.ContextData is not null) + if (request.ContextData is null) + { + return; + } + + foreach (var item in request.ContextData) { - foreach (var item in request.ContextData) - { - _contextData.TryAdd(item.Key, item.Value); - } + _contextData.TryAdd(item.Key, item.Value); } } @@ -140,5 +138,6 @@ public void Reset() Variables = default; Result = default; Exception = default; + RequestIndex = default; } } diff --git a/src/HotChocolate/Core/src/Execution/RequestExecutor.cs b/src/HotChocolate/Core/src/Execution/RequestExecutor.cs index 75710eed490..e6400bffac2 100644 --- a/src/HotChocolate/Core/src/Execution/RequestExecutor.cs +++ b/src/HotChocolate/Core/src/Execution/RequestExecutor.cs @@ -1,10 +1,11 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; -using HotChocolate.Execution.Batching; using HotChocolate.Fetching; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ObjectPool; @@ -15,9 +16,8 @@ internal sealed class RequestExecutor : IRequestExecutor { private readonly IServiceProvider _applicationServices; private readonly RequestDelegate _requestDelegate; - private readonly BatchExecutor _batchExecutor; private readonly ObjectPool _contextPool; - private readonly DefaultRequestContextAccessor _contextAccessor; + private readonly DefaultRequestContextAccessor _contextAccessor; private readonly IRequestContextEnricher[] _enricher; public RequestExecutor( @@ -25,7 +25,6 @@ public RequestExecutor( IServiceProvider applicationServices, IServiceProvider executorServices, RequestDelegate requestDelegate, - BatchExecutor batchExecutor, ObjectPool contextPool, DefaultRequestContextAccessor contextAccessor, ulong version) @@ -38,11 +37,9 @@ public RequestExecutor( throw new ArgumentNullException(nameof(executorServices)); _requestDelegate = requestDelegate ?? throw new ArgumentNullException(nameof(requestDelegate)); - _batchExecutor = batchExecutor ?? - throw new ArgumentNullException(nameof(batchExecutor)); _contextPool = contextPool ?? throw new ArgumentNullException(nameof(contextPool)); - _contextAccessor = contextAccessor ?? + _contextAccessor = contextAccessor ?? throw new ArgumentNullException(nameof(contextAccessor)); Version = version; @@ -70,13 +67,7 @@ static void CollectEnricher(IServiceProvider services, List ExecuteAsync( - IQueryRequest request, - CancellationToken cancellationToken = default) - => ExecuteAsync(request, true, cancellationToken); - - internal async Task ExecuteAsync( - IQueryRequest request, - bool scopeDataLoader, + IOperationRequest request, CancellationToken cancellationToken = default) { if (request is null) @@ -84,6 +75,15 @@ internal async Task ExecuteAsync( throw new ArgumentNullException(nameof(request)); } + return ExecuteAsync(request, true, null, cancellationToken); + } + + internal async Task ExecuteAsync( + IOperationRequest request, + bool scopeDataLoader, + int? requestIndex, + CancellationToken cancellationToken) + { IServiceScope? scope = null; if (request.Services is null) @@ -97,23 +97,26 @@ internal async Task ExecuteAsync( scope = _applicationServices.CreateScope(); } } - - var services = scope is null ? request.Services! : scope.ServiceProvider; + + var services = scope is null + ? request.Services! + : scope.ServiceProvider; + + if (scopeDataLoader) + { + // we ensure that at the begin of each execution there is a fresh batching scope. + services.InitializeDataLoaderScope(); + } var context = _contextPool.Get(); try { - if (scopeDataLoader) - { - // we ensure that at the begin of each execution there is a fresh batching scope. - services.InitializeDataLoaderScope(); - } - - context.RequestAborted = cancellationToken; context.Initialize(request, services); + context.RequestAborted = cancellationToken; + context.RequestIndex = requestIndex; EnrichContext(context); - + _contextAccessor.RequestContext = context; await _requestDelegate(context).ConfigureAwait(false); @@ -144,7 +147,7 @@ internal async Task ExecuteAsync( } public Task ExecuteBatchAsync( - IReadOnlyList requestBatch, + OperationRequestBatch requestBatch, CancellationToken cancellationToken = default) { if (requestBatch is null) @@ -154,30 +157,171 @@ public Task ExecuteBatchAsync( return Task.FromResult( new ResponseStream( - () => _batchExecutor.ExecuteAsync(this, requestBatch), + () => CreateResponseStream(requestBatch, cancellationToken), ExecutionResultKind.BatchResult)); } + private async IAsyncEnumerable CreateResponseStream( + OperationRequestBatch requestBatch, + [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + IServiceScope? scope = null; + + if (requestBatch.Services is null) + { + if (requestBatch.ContextData?.TryGetValue(nameof(IServiceScopeFactory), out var value) ?? false) + { + scope = ((IServiceScopeFactory)value!).CreateScope(); + } + else + { + scope = _applicationServices.CreateScope(); + } + } + + var services = scope is null + ? requestBatch.Services! + : scope.ServiceProvider; + + // we ensure that at the start of each execution there is a fresh batching scope. + services.InitializeDataLoaderScope(); + + var requests = requestBatch.Requests; + var requestCount = requests.Count; + var tasks = new List(requestCount); + + var completed = new ConcurrentStack(); + + for (var i = 0; i < requestCount; i++) + { + tasks.Add(ExecuteBatchItemAsync(requests[i], i, completed, cancellationToken)); + } + + var buffer = new IOperationResult[8]; + int bufferCount; + + do + { + bufferCount = completed.TryPopRange(buffer); + + for (var i = 0; i < bufferCount; i++) + { + yield return buffer[i]; + } + + if (bufferCount == 0) + { + if(tasks.Any(t => !t.IsCompleted)) + { + var task = await Task.WhenAny(tasks); + + if (task.Status is not TaskStatus.RanToCompletion) + { + // we await to throw if its not successful. + await task; + } + + tasks.Remove(task); + } + else + { + foreach (var task in tasks) + { + if (task.Status is not TaskStatus.RanToCompletion) + { + // we await to throw if it's not successful. + await task; + } + } + + tasks.Clear(); + } + } + } + while (tasks.Count > 0 || bufferCount > 0); + } + + private async Task ExecuteBatchItemAsync( + IOperationRequest request, + int requestIndex, + ConcurrentStack completed, + CancellationToken cancellationToken) + { + var result = await ExecuteAsync(request, false, requestIndex, cancellationToken).ConfigureAwait(false); + await UnwrapBatchItemResultAsync(result, completed, cancellationToken); + } + + private static async Task UnwrapBatchItemResultAsync( + IExecutionResult result, + ConcurrentStack completed, + CancellationToken cancellationToken) + { + switch (result) + { + case OperationResult singleResult: + completed.Push(singleResult); + break; + + case IResponseStream stream: + { + await foreach (var item in stream.ReadResultsAsync().WithCancellation(cancellationToken)) + { + completed.Push(item); + } + + break; + } + + case OperationResultBatch resultBatch: + { + List? tasks = null; + foreach (var item in resultBatch.Results) + { + if (item is OperationResult singleItem) + { + completed.Push(singleItem); + } + else + { + (tasks ??= []).Add(UnwrapBatchItemResultAsync(item, completed, cancellationToken)); + } + } + + if (tasks is not null) + { + await Task.WhenAll(tasks); + } + + break; + } + + default: + throw new InvalidOperationException(); + } + } + private void EnrichContext(IRequestContext context) { - if (_enricher.Length > 0) + if (_enricher.Length <= 0) { + return; + } + #if NET6_0_OR_GREATER - ref var start = ref MemoryMarshal.GetArrayDataReference(_enricher); - ref var end = ref Unsafe.Add(ref start, _enricher.Length); + ref var start = ref MemoryMarshal.GetArrayDataReference(_enricher); + ref var end = ref Unsafe.Add(ref start, _enricher.Length); #else - ref var start = ref MemoryMarshal.GetReference(_enricher.AsSpan()); - ref var end = ref Unsafe.Add(ref start, _enricher.Length); + ref var start = ref MemoryMarshal.GetReference(_enricher.AsSpan()); + ref var end = ref Unsafe.Add(ref start, _enricher.Length); #endif - while (Unsafe.IsAddressLessThan(ref start, ref end)) - { - start.Enrich(context); + while (Unsafe.IsAddressLessThan(ref start, ref end)) + { + start.Enrich(context); #pragma warning disable CS8619 - start = ref Unsafe.Add(ref start, 1); + start = ref Unsafe.Add(ref start, 1); #pragma warning restore CS8619 - } } } } diff --git a/src/HotChocolate/Core/src/Execution/RequestExecutorProxy.cs b/src/HotChocolate/Core/src/Execution/RequestExecutorProxy.cs index 8c349244709..4c1b2935906 100644 --- a/src/HotChocolate/Core/src/Execution/RequestExecutorProxy.cs +++ b/src/HotChocolate/Core/src/Execution/RequestExecutorProxy.cs @@ -52,19 +52,19 @@ public RequestExecutorProxy(IRequestExecutorResolver executorResolver, string sc /// Returns the execution result of the given GraphQL . /// /// If the request operation is a simple query or mutation the result is a - /// . + /// . /// /// If the request operation is a query or mutation where data is deferred, streamed or /// includes live data the result is a where each result - /// that the yields is a . + /// that the yields is a . /// /// If the request operation is a subscription the result is a /// where each result that the /// yields is a - /// . + /// . /// public async Task ExecuteAsync( - IQueryRequest request, + IOperationRequest request, CancellationToken cancellationToken = default) { if (request == null) @@ -97,7 +97,7 @@ await executor /// Returns a stream of query results. /// public async Task ExecuteBatchAsync( - IReadOnlyList requestBatch, + OperationRequestBatch requestBatch, CancellationToken cancellationToken = default) { if (requestBatch == null) diff --git a/src/HotChocolate/Core/src/Execution/RequestExecutorResolver.cs b/src/HotChocolate/Core/src/Execution/RequestExecutorResolver.cs index f36deccf0d2..0075eda225e 100644 --- a/src/HotChocolate/Core/src/Execution/RequestExecutorResolver.cs +++ b/src/HotChocolate/Core/src/Execution/RequestExecutorResolver.cs @@ -10,7 +10,6 @@ #if NET6_0_OR_GREATER using HotChocolate.Execution; #endif -using HotChocolate.Execution.Batching; using HotChocolate.Execution.Configuration; using HotChocolate.Execution.Errors; using HotChocolate.Execution.Instrumentation; @@ -271,7 +270,6 @@ await typeModuleChangeMonitor.ConfigureAsync(context, cancellationToken) serviceCollection.TryAddDiagnosticEvents(); serviceCollection.TryAddOperationExecutors(); - serviceCollection.TryAddTimespanProvider(); // register global error filters foreach (var errorFilter in _applicationServices.GetServices()) @@ -300,17 +298,6 @@ await typeModuleChangeMonitor.ConfigureAsync(context, cancellationToken) sp.GetRequiredService()); }); - serviceCollection.AddSingleton( - static sp => - { - var appServices = sp.GetRequiredService(); - - return new BatchExecutor( - sp.GetRequiredService(), - appServices.GetRequiredService(), - appServices.GetRequiredService()); - }); - serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton( @@ -328,21 +315,14 @@ await typeModuleChangeMonitor.ConfigureAsync(context, cancellationToken) }); serviceCollection.AddSingleton( - static sp => - { - var version = sp.GetRequiredService().Version; - var appServices = sp.GetRequiredService(); - - return new RequestExecutor( - sp.GetRequiredService(), - appServices, - sp, - sp.GetRequiredService(), - sp.GetRequiredService(), - sp.GetRequiredService>(), - sp.GetApplicationService(), - version); - }); + sp => new RequestExecutor( + sp.GetRequiredService(), + _applicationServices, + sp, + sp.GetRequiredService(), + sp.GetRequiredService>(), + sp.GetApplicationService(), + version)); OnConfigureSchemaServices(context, serviceCollection, setup); @@ -377,13 +357,10 @@ private static async ValueTask CreateSchemaAsync( return setup.Schema; } - var complexitySettings = executorOptions.Complexity; - context .SchemaBuilder .AddServices(schemaServices) - .SetContextData(typeof(RequestExecutorOptions).FullName!, executorOptions) - .SetContextData(typeof(ComplexityAnalyzerSettings).FullName!, complexitySettings); + .SetContextData(typeof(RequestExecutorOptions).FullName!, executorOptions); var descriptorContext = context.SchemaBuilder.CreateContext(); diff --git a/src/HotChocolate/Core/src/Execution/Serialization/EventStreamResultFormatter.cs b/src/HotChocolate/Core/src/Execution/Serialization/EventStreamResultFormatter.cs index 3f07ae79f7f..3fa4f4b5d60 100644 --- a/src/HotChocolate/Core/src/Execution/Serialization/EventStreamResultFormatter.cs +++ b/src/HotChocolate/Core/src/Execution/Serialization/EventStreamResultFormatter.cs @@ -1,10 +1,12 @@ using System; +using System.Buffers; +using System.Collections.Generic; using System.IO; +using System.IO.Pipelines; using System.Text.Json; using System.Threading; using System.Threading.Tasks; using HotChocolate.Utilities; -using static HotChocolate.Execution.ExecutionResultKind; namespace HotChocolate.Execution.Serialization; @@ -14,23 +16,14 @@ namespace HotChocolate.Execution.Serialization; /// public sealed class EventStreamResultFormatter : IExecutionResultFormatter { - private static readonly TimeSpan _keepAliveTimeSpan = TimeSpan.FromSeconds(12); - - private static readonly byte[] _eventField = "event: "u8.ToArray(); - private static readonly byte[] _dataField = "data: "u8.ToArray(); - private static readonly byte[] _nextEvent = "next"u8.ToArray(); - private static readonly byte[] _keepAlive = ":\n\n"u8.ToArray(); - private static readonly byte[] _completeEvent = "complete"u8.ToArray(); - private static readonly byte[] _newLine = "\n"u8.ToArray(); - private readonly JsonResultFormatter _payloadFormatter; private readonly JsonWriterOptions _options; - + /// - /// Creates a new instance of . + /// Initializes a new instance of . /// /// - /// The JSON result formatter options + /// The options to configure the JSON writer. /// public EventStreamResultFormatter(JsonResultFormatterOptions options) { @@ -38,195 +31,237 @@ public EventStreamResultFormatter(JsonResultFormatterOptions options) _payloadFormatter = new JsonResultFormatter(options); } - /// + /// + /// Formats an into a SSE stream. + /// + /// + /// + /// + /// + /// + /// public ValueTask FormatAsync( IExecutionResult result, Stream outputStream, CancellationToken cancellationToken = default) { - if (result is null) + if (result == null) { throw new ArgumentNullException(nameof(result)); } - if (outputStream is null) + if (outputStream == null) { throw new ArgumentNullException(nameof(outputStream)); } - - return FormatInternalAsync(result, outputStream, cancellationToken); + + return result switch + { + IOperationResult operationResult + => FormatOperationResultAsync(operationResult, outputStream, cancellationToken), + OperationResultBatch resultBatch + => FormatResultBatchAsync(resultBatch, outputStream, cancellationToken), + IResponseStream responseStream + => FormatResponseStreamAsync(responseStream, outputStream, cancellationToken), + _ => throw new NotSupportedException() + }; } - private async ValueTask FormatInternalAsync( - IExecutionResult result, + private async ValueTask FormatOperationResultAsync( + IOperationResult operationResult, Stream outputStream, CancellationToken ct) { - if (result.Kind is SingleResult) - { - await WriteNextMessageAsync((IQueryResult)result, outputStream, ct).ConfigureAwait(false); - await WriteNewLineAndFlushAsync(outputStream, ct).ConfigureAwait(false); - await WriteCompleteMessage(outputStream, ct).ConfigureAwait(false); - await WriteNewLineAndFlushAsync(outputStream, ct).ConfigureAwait(false); - } - else if (result.Kind is DeferredResult or BatchResult or SubscriptionResult) - { - var responseStream = (IResponseStream)result; - - // synchronization of the output stream is required to ensure that the messages are not - // interleaved. - using var synchronization = new SemaphoreSlim(1, 1); + using var buffer = new ArrayWriter(); + + MessageHelper.WriteNextMessage(_payloadFormatter, operationResult, buffer); + MessageHelper.WriteCompleteMessage(buffer); + + await outputStream.WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, ct).ConfigureAwait(false); + await outputStream.FlushAsync(ct).ConfigureAwait(false); + } - // we need to keep track if the stream is completed so that we can stop sending keep - // alive messages. - var completion = new TaskCompletionSource(); + private async ValueTask FormatResultBatchAsync( + OperationResultBatch resultBatch, + Stream outputStream, + CancellationToken ct) + { + var writer = PipeWriter.Create(outputStream); + ArrayWriter? buffer = null; + KeepAliveJob? keepAlive = null; + List? streams = null; - // we await all tasks so that we can catch all exceptions. - await Task.WhenAll( - ProcessResponseStreamAsync(synchronization, completion, responseStream, outputStream, ct), - SendKeepAliveMessagesAsync(synchronization, completion, outputStream, ct)); + try + { + foreach (var result in resultBatch.Results) + { + switch (result) + { + case IOperationResult operationResult: + buffer ??= new ArrayWriter(); + MessageHelper.WriteNextMessage(_payloadFormatter, operationResult, buffer); + writer.Write(buffer.GetWrittenSpan()); + await writer.FlushAsync(ct).ConfigureAwait(false); + keepAlive?.Reset(); + buffer.Reset(); + break; + + case IResponseStream responseStream: + keepAlive ??= new KeepAliveJob(writer); + streams ??= []; + var formatter = new StreamFormatter(_payloadFormatter, keepAlive, responseStream, writer); + streams.Add(formatter.ProcessAsync(ct)); + break; + + default: + throw new NotSupportedException( + "The result batch contains an unsupported result type."); + } + } } - - else + finally { - throw new NotSupportedException(); + keepAlive?.Dispose(); + buffer?.Dispose(); } + + MessageHelper.WriteCompleteMessage(writer); + await writer.FlushAsync(ct).ConfigureAwait(false); } - private static async Task SendKeepAliveMessagesAsync( - SemaphoreSlim synchronization, - TaskCompletionSource completion, + private async ValueTask FormatResponseStreamAsync( + IResponseStream responseStream, Stream outputStream, CancellationToken ct) { - while (true) - { - await Task.WhenAny(Task.Delay(_keepAliveTimeSpan, ct), completion.Task); + var writer = PipeWriter.Create(outputStream); - if (!ct.IsCancellationRequested && !completion.Task.IsCompleted) - { - // we do not need try-finally here because we dispose the semaphore in the parent - // method. - await synchronization.WaitAsync(ct); + using (var keepAlive = new KeepAliveJob(writer)) + { + var formatter = new StreamFormatter(_payloadFormatter, keepAlive, responseStream, writer); + await formatter.ProcessAsync(ct).ConfigureAwait(false); + } + + MessageHelper.WriteCompleteMessage(writer); + await writer.FlushAsync(ct).ConfigureAwait(false); + } - await WriteKeepAliveAndFlush(outputStream, ct); + private sealed class StreamFormatter( + JsonResultFormatter payloadFormatter, + KeepAliveJob keepAliveJob, + IResponseStream responseStream, + PipeWriter writer) + { + public async Task ProcessAsync(CancellationToken ct) + { + using var buffer = new ArrayWriter(); - synchronization.Release(); - } - else + await foreach (var result in responseStream.ReadResultsAsync() + .WithCancellation(ct) + .ConfigureAwait(false)) { - break; + try + { + MessageHelper.WriteNextMessage(payloadFormatter, result, buffer); + writer.Write(buffer.GetWrittenSpan()); + await writer.FlushAsync(ct).ConfigureAwait(false); + keepAliveJob.Reset(); + buffer.Reset(); + } + finally + { + await result.DisposeAsync().ConfigureAwait(false); + } } } } - private async Task ProcessResponseStreamAsync( - SemaphoreSlim synchronization, - TaskCompletionSource completion, - IResponseStream responseStream, - Stream outputStream, - CancellationToken ct) + private sealed class KeepAliveJob : IDisposable { - await foreach (var queryResult in responseStream.ReadResultsAsync().WithCancellation(ct).ConfigureAwait(false)) + private static readonly TimeSpan _timeout = TimeSpan.FromSeconds(12); + private static readonly TimeSpan _timeout1 = TimeSpan.FromSeconds(8); + private readonly PipeWriter _writer; + private readonly Timer _keepAliveTimer; + private DateTime _lastWriteTime = DateTime.UtcNow; + private bool _disposed; + + public KeepAliveJob(PipeWriter writer) { - // we do not need try-finally here because we dispose the semaphore in the parent - // method. + _writer = writer; + _keepAliveTimer = new Timer(_ => EnsureKeepAlive(), null, _timeout, _timeout); + } - await synchronization.WaitAsync(ct); + public void Reset() => _lastWriteTime = DateTime.UtcNow; - try + private void EnsureKeepAlive() + { + if (DateTime.UtcNow - _lastWriteTime >= _timeout1) { - await WriteNextMessageAsync(queryResult, outputStream, ct).ConfigureAwait(false); + Task.Run(WriteKeepAliveAsync); } - finally + return; + + async Task WriteKeepAliveAsync() { - await queryResult.DisposeAsync().ConfigureAwait(false); + try + { + _writer.Write(MessageHelper.KeepAlive()); + await _writer.FlushAsync().ConfigureAwait(false); + } + catch + { + // ignore + } } - - await WriteNewLineAndFlushAsync(outputStream, ct).ConfigureAwait(false); - - synchronization.Release(); } - await synchronization.WaitAsync(ct); - - await WriteCompleteMessage(outputStream, ct).ConfigureAwait(false); - await WriteNewLineAndFlushAsync(outputStream, ct).ConfigureAwait(false); - - synchronization.Release(); - completion.SetResult(true); - } - - private async ValueTask WriteNextMessageAsync( - IQueryResult result, - Stream outputStream, - CancellationToken ct) - { -#if NET6_0_OR_GREATER - await outputStream.WriteAsync(_eventField, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_nextEvent, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_newLine, ct).ConfigureAwait(false); -#else - await outputStream.WriteAsync(_eventField, 0, _eventField.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_nextEvent, 0, _nextEvent.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_newLine, 0, _newLine.Length, ct).ConfigureAwait(false); -#endif - - using var bufferWriter = new ArrayWriter(); - FormatPayload(bufferWriter, result); - -#if NET6_0_OR_GREATER - await outputStream.WriteAsync(_dataField, ct).ConfigureAwait(false); - await outputStream.WriteAsync(bufferWriter.GetWrittenMemory(), ct).ConfigureAwait(false); - await outputStream.WriteAsync(_newLine, ct).ConfigureAwait(false); -#else - var buffer = bufferWriter.GetInternalBuffer(); - await outputStream.WriteAsync(_dataField, 0, _dataField.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(buffer, 0, bufferWriter.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_newLine, 0, _newLine.Length, ct).ConfigureAwait(false); -#endif - } + public void Dispose() + { + if (_disposed) + { + return; + } - private void FormatPayload(ArrayWriter bufferWriter, IQueryResult result) - { - using var writer = new Utf8JsonWriter(bufferWriter, _options); - _payloadFormatter.Format(result, writer); + _disposed = true; + _keepAliveTimer.Dispose(); + } } - private static async ValueTask WriteCompleteMessage(Stream outputStream, CancellationToken ct) + private static class MessageHelper { -#if NET6_0_OR_GREATER - await outputStream.WriteAsync(_eventField, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_completeEvent, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_newLine, ct).ConfigureAwait(false); -#else - await outputStream.WriteAsync(_eventField, 0, _eventField.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_completeEvent, 0, _completeEvent.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(_newLine, 0, _newLine.Length, ct).ConfigureAwait(false); -#endif - } + private static readonly byte[] _nextEvent = "event: next\ndata: "u8.ToArray(); + private static readonly byte[] _completeEvent = "event: complete\n\n"u8.ToArray(); + private static readonly byte[] _keepAlive = ":\n\n"u8.ToArray(); + private static readonly byte[] _newLine = "\n"u8.ToArray(); + private static readonly byte[] _newLine2 = "\n\n"u8.ToArray(); + + public static void WriteNextMessage( + JsonResultFormatter payloadFormatter, + IOperationResult result, + ArrayWriter writer) + { + // write the SSE event field + var span = writer.GetSpan(_nextEvent.Length); + _nextEvent.CopyTo(span); + writer.Advance(_nextEvent.Length); + + // write the actual result data + payloadFormatter.Format(result, writer); + + // write the new line + span = writer.GetSpan(_newLine2.Length); + _newLine2.CopyTo(span); + writer.Advance(_newLine2.Length); + } - private static async ValueTask WriteNewLineAndFlushAsync( - Stream outputStream, - CancellationToken ct) - { -#if NET6_0_OR_GREATER - await outputStream.WriteAsync(_newLine, ct).ConfigureAwait(false); -#else - await outputStream.WriteAsync(_newLine, 0, _newLine.Length, ct).ConfigureAwait(false); -#endif - await outputStream.FlushAsync(ct).ConfigureAwait(false); - } + public static void WriteCompleteMessage( + IBufferWriter writer) + { + var span = writer.GetSpan(_completeEvent.Length); + _completeEvent.CopyTo(span); + writer.Advance(_completeEvent.Length); + } - private static async ValueTask WriteKeepAliveAndFlush( - Stream outputStream, - CancellationToken ct) - { -#if NET6_0_OR_GREATER - await outputStream.WriteAsync(_keepAlive, ct).ConfigureAwait(false); -#else - await outputStream.WriteAsync(_keepAlive, 0, _keepAlive.Length, ct).ConfigureAwait(false); -#endif - await outputStream.FlushAsync(ct).ConfigureAwait(false); + public static ReadOnlySpan KeepAlive() => _keepAlive; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.FieldNames.cs b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.FieldNames.cs index f58749e444d..096b2625523 100644 --- a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.FieldNames.cs +++ b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.FieldNames.cs @@ -23,4 +23,8 @@ public sealed partial class JsonResultFormatter private static ReadOnlySpan Column => "column"u8; private static ReadOnlySpan Incremental => "incremental"u8; + + private static ReadOnlySpan RequestIndex => "requestIndex"u8; + + private static ReadOnlySpan VariableIndex => "variableIndex"u8; } diff --git a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs index 3b42385cbff..79faf8175cc 100644 --- a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs +++ b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs @@ -16,9 +16,9 @@ namespace HotChocolate.Execution.Serialization; /// -/// The default JSON formatter for . +/// The default JSON formatter for . /// -public sealed partial class JsonResultFormatter : IQueryResultFormatter, IExecutionResultFormatter +public sealed partial class JsonResultFormatter : IOperationResultFormatter, IExecutionResultFormatter { private readonly JsonWriterOptions _options; private readonly JsonSerializerOptions _serializerOptions; @@ -45,14 +45,22 @@ public async ValueTask FormatAsync( Stream outputStream, CancellationToken cancellationToken = default) { - if (result.Kind is ExecutionResultKind.SingleResult) + switch (result) { - await FormatAsync((IQueryResult)result, outputStream, cancellationToken) - .ConfigureAwait(false); - } - else - { - throw JsonFormatter_ResultNotSupported(nameof(JsonResultFormatter)); + case IOperationResult singleResult: + await FormatInternalAsync(singleResult, outputStream, cancellationToken).ConfigureAwait(false); + break; + + case OperationResultBatch resultBatch: + await FormatInternalAsync(resultBatch, outputStream, cancellationToken).ConfigureAwait(false); + break; + + case IResponseStream responseStream: + await FormatInternalAsync(responseStream, outputStream, cancellationToken).ConfigureAwait(false); + break; + + default: + throw JsonFormatter_ResultNotSupported(nameof(JsonResultFormatter)); } } @@ -68,7 +76,7 @@ await FormatAsync((IQueryResult)result, outputStream, cancellationToken) /// /// is null. /// - public unsafe string Format(IQueryResult result) + public unsafe string Format(IOperationResult result) { if (result is null) { @@ -98,7 +106,7 @@ public unsafe string Format(IQueryResult result) /// is null. /// is null. /// - public void Format(IQueryResult result, Utf8JsonWriter writer) + public void Format(IOperationResult result, Utf8JsonWriter writer) { if (result is null) { @@ -176,8 +184,8 @@ public void FormatErrors(IReadOnlyList errors, Utf8JsonWriter writer) writer.WriteEndArray(); } - /// - public void Format(IQueryResult result, IBufferWriter writer) + /// + public void Format(IOperationResult result, IBufferWriter writer) { if (result is null) { @@ -191,17 +199,17 @@ public void Format(IQueryResult result, IBufferWriter writer) FormatInternal(result, writer); } - - private void FormatInternal(IQueryResult result, IBufferWriter writer) + + private void FormatInternal(IOperationResult result, IBufferWriter writer) { using var jsonWriter = new Utf8JsonWriter(writer, _options); WriteResult(jsonWriter, result); jsonWriter.Flush(); } - /// + /// public ValueTask FormatAsync( - IQueryResult result, + IOperationResult result, Stream outputStream, CancellationToken cancellationToken = default) { @@ -219,7 +227,7 @@ public ValueTask FormatAsync( } private async ValueTask FormatInternalAsync( - IQueryResult result, + IOperationResult result, Stream outputStream, CancellationToken cancellationToken = default) { @@ -239,10 +247,102 @@ await outputStream await outputStream.FlushAsync(cancellationToken).ConfigureAwait(false); } - private void WriteResult(Utf8JsonWriter writer, IQueryResult result) + private async ValueTask FormatInternalAsync( + OperationResultBatch resultBatch, + Stream outputStream, + CancellationToken cancellationToken = default) + { + using var buffer = new ArrayWriter(); + + foreach (var result in resultBatch.Results) + { + switch (result) + { + case IOperationResult singleResult: + FormatInternal(singleResult, buffer); + break; + + case IResponseStream batchResult: + { + await foreach (var partialResult in batchResult.ReadResultsAsync() + .WithCancellation(cancellationToken) + .ConfigureAwait(false)) + { + try + { + FormatInternal(partialResult, buffer); + } + finally + { + await partialResult.DisposeAsync().ConfigureAwait(false); + } + } + break; + } + } + } + +#if NETSTANDARD2_0 + await outputStream + .WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, cancellationToken) + .ConfigureAwait(false); +#else + await outputStream + .WriteAsync(buffer.GetWrittenMemory(), cancellationToken) + .ConfigureAwait(false); +#endif + + await outputStream.FlushAsync(cancellationToken).ConfigureAwait(false); + } + + private async ValueTask FormatInternalAsync( + IResponseStream batchResult, + Stream outputStream, + CancellationToken cancellationToken = default) + { + using var buffer = new ArrayWriter(); + + await foreach (var partialResult in batchResult.ReadResultsAsync() + .WithCancellation(cancellationToken) + .ConfigureAwait(false)) + { + try + { + FormatInternal(partialResult, buffer); + } + finally + { + await partialResult.DisposeAsync().ConfigureAwait(false); + } + } + +#if NETSTANDARD2_0 + await outputStream + .WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, cancellationToken) + .ConfigureAwait(false); +#else + await outputStream + .WriteAsync(buffer.GetWrittenMemory(), cancellationToken) + .ConfigureAwait(false); +#endif + + await outputStream.FlushAsync(cancellationToken).ConfigureAwait(false); + } + + private void WriteResult(Utf8JsonWriter writer, IOperationResult result) { writer.WriteStartObject(); + if (result.RequestIndex.HasValue) + { + writer.WriteNumber(RequestIndex, result.RequestIndex.Value); + } + + if (result.VariableIndex.HasValue) + { + writer.WriteNumber(VariableIndex, result.VariableIndex.Value); + } + WriteErrors(writer, result.Errors); WriteData(writer, result); WriteItems(writer, result.Items); @@ -256,7 +356,7 @@ private void WriteResult(Utf8JsonWriter writer, IQueryResult result) private static void WritePatchInfo( Utf8JsonWriter writer, - IQueryResult result) + IOperationResult result) { if (result.Label is not null) { @@ -271,7 +371,7 @@ private static void WritePatchInfo( private static void WriteHasNext( Utf8JsonWriter writer, - IQueryResult result) + IOperationResult result) { if (result.HasNext.HasValue) { @@ -281,7 +381,7 @@ private static void WriteHasNext( private void WriteData( Utf8JsonWriter writer, - IQueryResult result) + IOperationResult result) { if (!result.IsDataSet) { @@ -293,7 +393,7 @@ private void WriteData( writer.WriteNull(Data); return; } - + writer.WritePropertyName(Data); if (result.Data is ObjectResult resultMap) @@ -440,7 +540,7 @@ private void WriteExtensions( } } - private void WriteIncremental(Utf8JsonWriter writer, IReadOnlyList? patches) + private void WriteIncremental(Utf8JsonWriter writer, IReadOnlyList? patches) { if (patches is { Count: > 0, }) { @@ -759,4 +859,4 @@ private void WriteFieldValue( break; } } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.Constants.cs b/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.Constants.cs deleted file mode 100644 index 130dccc718d..00000000000 --- a/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.Constants.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace HotChocolate.Execution.Serialization; - -public sealed partial class MultiPartResultFormatter -{ - private static byte[] ContentType { get; } = - [ - (byte)'C', (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'t', - (byte)'-', (byte)'T', (byte)'y', (byte)'p', (byte)'e', (byte)':', (byte)' ', - (byte)'a', (byte)'p', (byte)'p', (byte)'l', (byte)'i', (byte)'c', (byte)'a', - (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'/', (byte)'j', (byte)'s', - (byte)'o', (byte)'n', (byte)';', (byte)' ', (byte)'c', (byte)'h', (byte)'a', - (byte)'r', (byte)'s', (byte)'e', (byte)'t', (byte)'=', (byte)'u', (byte)'t', - (byte)'f', (byte)'-', (byte)'8', - ]; - - private static byte[] Start { get; } = - [ - (byte)'-', (byte)'-', (byte)'-', - ]; - - private static byte[] End { get; } = - [ - (byte)'-', (byte)'-', (byte)'-', (byte)'-', (byte)'-', - ]; - - private static byte[] CrLf { get; } = - [ - (byte)'\r', (byte)'\n', - ]; -} diff --git a/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.cs b/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.cs index 105968b7e0b..7fc8ceaa49a 100644 --- a/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.cs +++ b/src/HotChocolate/Core/src/Execution/Serialization/MultiPartResultFormatter.cs @@ -1,10 +1,10 @@ using System; +using System.Buffers; using System.IO; using System.Threading; using System.Threading.Tasks; using HotChocolate.Utilities; using static HotChocolate.Execution.ExecutionResultKind; -using static HotChocolate.Execution.ThrowHelper; namespace HotChocolate.Execution.Serialization; @@ -12,9 +12,9 @@ namespace HotChocolate.Execution.Serialization; /// The default MultiPart formatter for . /// https://github.com/graphql/graphql-over-http/blob/master/rfcs/IncrementalDelivery.md /// -public sealed partial class MultiPartResultFormatter : IExecutionResultFormatter +public sealed class MultiPartResultFormatter : IExecutionResultFormatter { - private readonly IQueryResultFormatter _payloadFormatter; + private readonly IOperationResultFormatter _payloadFormatter; /// /// Creates a new instance of . @@ -30,112 +30,159 @@ public MultiPartResultFormatter(JsonResultFormatterOptions options = default) /// /// Creates a new instance of . /// - /// + /// /// The serializer that shall be used to serialize query results. /// /// - /// is null. + /// is null. /// - public MultiPartResultFormatter(IQueryResultFormatter queryResultFormatter) + public MultiPartResultFormatter(IOperationResultFormatter operationResultFormatter) { - _payloadFormatter = queryResultFormatter ?? - throw new ArgumentNullException(nameof(queryResultFormatter)); + _payloadFormatter = operationResultFormatter ?? + throw new ArgumentNullException(nameof(operationResultFormatter)); } - /// + /// + /// Formats an into a multipart stream. + /// + /// + /// The result that shall be formatted. + /// + /// + /// The stream to which the result shall be written. + /// + /// + /// The cancellation token. + /// + /// + /// A task representing the asynchronous operation. + /// + /// + /// is null. + /// + /// + /// The formatter does not support the specified result. + /// public ValueTask FormatAsync( IExecutionResult result, Stream outputStream, CancellationToken cancellationToken = default) { - if (result is null) + if (result == null) { throw new ArgumentNullException(nameof(result)); } - if (outputStream is null) + if (outputStream == null) { throw new ArgumentNullException(nameof(outputStream)); } - return result.Kind switch + if (result.Kind == SubscriptionResult) + { + throw new NotSupportedException( + "Subscriptions are not supported by this formatter."); + } + + return result switch { - SingleResult => - WriteSingleResponseAsync( - (IQueryResult)result, - outputStream, - cancellationToken), - DeferredResult or BatchResult or SubscriptionResult - => WriteManyResponsesAsync( - (IResponseStream)result, - outputStream, - cancellationToken), - _ => throw MultiPartFormatter_ResultNotSupported( - nameof(MultiPartResultFormatter)), + IOperationResult operationResult + => FormatOperationResultAsync(operationResult, outputStream, cancellationToken), + OperationResultBatch resultBatch + => FormatResultBatchAsync(resultBatch, outputStream, cancellationToken), + IResponseStream responseStream + => FormatResponseStreamAsync(responseStream, outputStream, cancellationToken), + _ => throw new NotSupportedException() }; } - /// - /// Formats a response stream and writes the formatted result to - /// the given . - /// - /// - /// The response stream that shall be formatted. - /// - /// - /// The stream to which the formatted shall be written to. - /// - /// - /// The cancellation token. - /// - /// - /// - public ValueTask FormatAsync( - IResponseStream responseStream, + private async ValueTask FormatOperationResultAsync( + IOperationResult result, Stream outputStream, - CancellationToken cancellationToken = default) + CancellationToken ct = default) { - if (responseStream is null) - { - throw new ArgumentNullException(nameof(responseStream)); - } + using var buffer = new ArrayWriter(); + MessageHelper.WriteNext(buffer); + + // First we write the header of the part. + MessageHelper.WriteResultHeader(buffer); + + // Next we write the payload of the part. + MessageHelper.WritePayload(buffer, result, _payloadFormatter); + + // Last we write the end of the part. + MessageHelper.WriteEnd(buffer); + + await outputStream.WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, ct).ConfigureAwait(false); + await outputStream.FlushAsync(ct).ConfigureAwait(false); + } - if (outputStream is null) + private async ValueTask FormatResultBatchAsync( + OperationResultBatch resultBatch, + Stream outputStream, + CancellationToken ct = default) + { + ArrayWriter? buffer = null; + foreach (var result in resultBatch.Results) { - throw new ArgumentNullException(nameof(outputStream)); + switch (result) + { + case IOperationResult operationResult: + buffer ??= new ArrayWriter(); + MessageHelper.WriteNext(buffer); + MessageHelper.WriteResultHeader(buffer); + MessageHelper.WritePayload(buffer, operationResult, _payloadFormatter); + MessageHelper.WriteEnd(buffer); + await outputStream.WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, ct).ConfigureAwait(false); + await outputStream.FlushAsync(ct).ConfigureAwait(false); + break; + + case IResponseStream responseStream: + await FormatResponseStreamAsync(responseStream, outputStream, ct).ConfigureAwait(false); + break; + } } - return WriteManyResponsesAsync(responseStream, outputStream, cancellationToken); + buffer?.Dispose(); } - private async ValueTask WriteManyResponsesAsync( + private async ValueTask FormatResponseStreamAsync( IResponseStream responseStream, Stream outputStream, CancellationToken ct = default) { // first we create the iterator. - await using var enumerator = responseStream.ReadResultsAsync().GetAsyncEnumerator(ct); + using var buffer = new ArrayWriter(); + await using var enumerator = responseStream.ReadResultsAsync().GetAsyncEnumerator(ct); var first = true; while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { try { + buffer.Reset(); + if (first || responseStream.Kind is not DeferredResult) { - await WriteNextAsync(outputStream, ct).ConfigureAwait(false); + MessageHelper.WriteNext(buffer); first = false; } - // Now we can write the header and body of the part. - await WriteResultAsync(enumerator.Current, outputStream, ct).ConfigureAwait(false); + // First we write the header of the part. + MessageHelper.WriteResultHeader(buffer); + + // Next we write the payload of the part. + MessageHelper.WritePayload(buffer, enumerator.Current, _payloadFormatter); if (responseStream.Kind is DeferredResult && (enumerator.Current.HasNext ?? false)) { - await WriteNextAsync(outputStream, ct).ConfigureAwait(false); + // If the result is a deferred result and has a next result we need to + // write a new part so that the client knows that there is more to come. + MessageHelper.WriteNext(buffer); } - // we flush to make sure that the result is written to the network stream. + // Now we can write the part to the output stream and flush this chunk. + await outputStream.WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, ct).ConfigureAwait(false); await outputStream.FlushAsync(ct).ConfigureAwait(false); } finally @@ -146,85 +193,50 @@ private async ValueTask WriteManyResponsesAsync( } } - - await WriteEndAsync(outputStream, ct).ConfigureAwait(false); + // After all parts have been written we need to write the final boundary. + buffer.Reset(); + MessageHelper.WriteEnd(buffer); + await outputStream.WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, ct).ConfigureAwait(false); await outputStream.FlushAsync(ct).ConfigureAwait(false); } - private async ValueTask WriteSingleResponseAsync( - IQueryResult queryResult, - Stream outputStream, - CancellationToken ct = default) + private static class MessageHelper { - // Before each part of the multi-part response, a boundary (CRLF, ---, CRLF) - // is sent. - await WriteNextAsync(outputStream, ct).ConfigureAwait(false); + private static ReadOnlySpan ContentType => "Content-Type: application/json; charset=utf-8\r\n\r\n"u8; + private static ReadOnlySpan Start => "\r\n---\r\n"u8; + private static ReadOnlySpan End => "\r\n-----\r\n"u8; + private static ReadOnlySpan CrLf => "\r\n"u8; - try + public static void WriteNext(IBufferWriter writer) { - // Now we can write the header and body of the part. - await WriteResultAsync(queryResult, outputStream, ct).ConfigureAwait(false); + var span = writer.GetSpan(Start.Length); + Start.CopyTo(span); + writer.Advance(Start.Length); } - finally + + public static void WriteEnd(IBufferWriter writer) { - // The result objects use pooled memory so we need to ensure that they - // return the memory by disposing them. - await queryResult.DisposeAsync().ConfigureAwait(false); + var span = writer.GetSpan(End.Length); + End.CopyTo(span); + writer.Advance(End.Length); } - await WriteEndAsync(outputStream, ct).ConfigureAwait(false); - await outputStream.FlushAsync(ct).ConfigureAwait(false); - } + public static void WritePayload( + IBufferWriter writer, + IOperationResult result, + IOperationResultFormatter payloadFormatter) + => payloadFormatter.Format(result, writer); - private async ValueTask WriteResultAsync( - IQueryResult result, - Stream outputStream, - CancellationToken ct) - { - using var writer = new ArrayWriter(); - _payloadFormatter.Format(result, writer); - - await WriteResultHeaderAsync(outputStream, ct).ConfigureAwait(false); - - // The payload is sent, followed by a CRLF. - var buffer = writer.GetInternalBuffer(); - await outputStream.WriteAsync(buffer, 0, writer.Length, ct).ConfigureAwait(false); - } - - private static async ValueTask WriteResultHeaderAsync( - Stream outputStream, - CancellationToken ct) - { - // Each part of the multipart response must contain a Content-Type header. - // Similar to the GraphQL specification this specification does not require - // a specific serialization format. For consistency and ease of notation, - // examples of the response are given in JSON throughout the spec. - await outputStream.WriteAsync(ContentType, 0, ContentType.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(CrLf, 0, CrLf.Length, ct).ConfigureAwait(false); - - // After all headers, an additional CRLF is sent. - await outputStream.WriteAsync(CrLf, 0, CrLf.Length, ct).ConfigureAwait(false); - } - - private static async ValueTask WriteNextAsync( - Stream outputStream, - CancellationToken ct) - { - // Before each part of the multi-part response, a boundary (CRLF, ---, CRLF) - // is sent. - await outputStream.WriteAsync(CrLf, 0, CrLf.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(Start, 0, Start.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(CrLf, 0, CrLf.Length, ct).ConfigureAwait(false); - } - - private static async ValueTask WriteEndAsync( - Stream outputStream, - CancellationToken ct) - { - // After the final payload, the terminating boundary of - // CRLF, ----- followed by CRLF is sent. - await outputStream.WriteAsync(CrLf, 0, CrLf.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(End, 0, End.Length, ct).ConfigureAwait(false); - await outputStream.WriteAsync(CrLf, 0, CrLf.Length, ct).ConfigureAwait(false); + public static void WriteResultHeader(IBufferWriter writer) + { + // Each part of the multipart response must contain a Content-Type header. + // Similar to the GraphQL specification this specification does not require + // a specific serialization format. For consistency and ease of notation, + // examples of the response are given in JSON throughout the spec. + // After all headers, an additional CRLF is sent. + var span = writer.GetSpan(ContentType.Length); + ContentType.CopyTo(span); + writer.Advance(ContentType.Length); + } } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Types.CursorPagination/IndexEdge.cs b/src/HotChocolate/Core/src/Types.CursorPagination/IndexEdge.cs index ff2bc980e70..93bd0528129 100644 --- a/src/HotChocolate/Core/src/Types.CursorPagination/IndexEdge.cs +++ b/src/HotChocolate/Core/src/Types.CursorPagination/IndexEdge.cs @@ -23,4 +23,4 @@ public static IndexEdge Create(T node, int index) var cursor = IndexCursor.Format(buffer.Slice(0, written)); return new IndexEdge(node, cursor, index); } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/src/Types.Errors/IPayloadErrorFactory.cs b/src/HotChocolate/Core/src/Types.Errors/IPayloadErrorFactory.cs index f53d01f7b16..50f122b9d76 100644 --- a/src/HotChocolate/Core/src/Types.Errors/IPayloadErrorFactory.cs +++ b/src/HotChocolate/Core/src/Types.Errors/IPayloadErrorFactory.cs @@ -14,7 +14,7 @@ namespace HotChocolate.Types; public interface IPayloadErrorFactory where TException : Exception { /// - /// Translates a exception of type to a GraphQL error of + /// Translates an exception of type to a GraphQL error of /// type /// /// diff --git a/src/HotChocolate/Core/src/Types.Json/JsonObjectTypeExtensions.cs b/src/HotChocolate/Core/src/Types.Json/JsonObjectTypeExtensions.cs index a262e9b6021..d61c5a798f9 100644 --- a/src/HotChocolate/Core/src/Types.Json/JsonObjectTypeExtensions.cs +++ b/src/HotChocolate/Core/src/Types.Json/JsonObjectTypeExtensions.cs @@ -241,11 +241,11 @@ internal static void InferResolver( { return null; } - + return DateTime.Parse( property.Value.GetString()!, CultureInfo.InvariantCulture, - DateTimeStyles.AssumeUniversal); + DateTimeStyles.None); }; return; diff --git a/src/HotChocolate/Core/src/Types/Extensions/DirectiveTypeExtensions.cs b/src/HotChocolate/Core/src/Types/Extensions/DirectiveTypeExtensions.cs deleted file mode 100644 index 6beffc1a5ec..00000000000 --- a/src/HotChocolate/Core/src/Types/Extensions/DirectiveTypeExtensions.cs +++ /dev/null @@ -1,12 +0,0 @@ -using HotChocolate.Types; - -#nullable enable - -namespace HotChocolate; - -public static class DirectiveTypeExtensions -{ - public static ISchemaBuilder AddCostDirectiveType( - this ISchemaBuilder builder) => - builder.AddDirectiveType(); -} diff --git a/src/HotChocolate/Core/src/Types/Properties/TypeResources.Designer.cs b/src/HotChocolate/Core/src/Types/Properties/TypeResources.Designer.cs index f32413f3bbb..af27302ff64 100644 --- a/src/HotChocolate/Core/src/Types/Properties/TypeResources.Designer.cs +++ b/src/HotChocolate/Core/src/Types/Properties/TypeResources.Designer.cs @@ -453,12 +453,6 @@ internal static string LongType_Description { } } - internal static string MultiplierPathType_Description { - get { - return ResourceManager.GetString("MultiplierPathType_Description", resourceCulture); - } - } - internal static string NameType_Description { get { return ResourceManager.GetString("NameType_Description", resourceCulture); @@ -1251,18 +1245,6 @@ internal static string SchemaBuilderExtensions_AddInputObjectType_TIsSchemaType } } - internal static string CostDirective_ComplexityCannotBeBelowOne { - get { - return ResourceManager.GetString("CostDirective_ComplexityCannotBeBelowOne", resourceCulture); - } - } - - internal static string CostDirective_DefaultMultiplierCannotBeBelowTwo { - get { - return ResourceManager.GetString("CostDirective_DefaultMultiplierCannotBeBelowTwo", resourceCulture); - } - } - internal static string EventMessageParameterExpressionBuilder_MessageNotFound { get { return ResourceManager.GetString("EventMessageParameterExpressionBuilder_MessageNotFound", resourceCulture); diff --git a/src/HotChocolate/Core/src/Types/Properties/TypeResources.resx b/src/HotChocolate/Core/src/Types/Properties/TypeResources.resx index 8dc25ac02c1..91c6eb05849 100644 --- a/src/HotChocolate/Core/src/Types/Properties/TypeResources.resx +++ b/src/HotChocolate/Core/src/Types/Properties/TypeResources.resx @@ -224,9 +224,6 @@ In some cases, you need to provide options to alter GraphQL's execution behavior The `Long` scalar type represents non-fractional signed whole 64-bit numeric values. Long can represent values between -(2^63) and 2^63 - 1. - - The multiplier path scalar represents a valid GraphQL multiplier path string. - The name scalar represents a valid GraphQL name as specified in the spec and can be used to refer to fields or types. @@ -627,12 +624,6 @@ Type: `{0}` The specified type `{0}` is a GraphQL schema type. AddInputObjectType<T> is a helper method to register a runtime type as GraphQL input object type. Use AddType<T> to register GraphQL schema types. - - The complexity cannot be below one. - - - Default multiplier cannot be below two. - The event message parameter can only be used in a subscription context. diff --git a/src/HotChocolate/Core/src/Types/SchemaBuilder.cs b/src/HotChocolate/Core/src/Types/SchemaBuilder.cs index 43e3450d759..fafdb3afa09 100644 --- a/src/HotChocolate/Core/src/Types/SchemaBuilder.cs +++ b/src/HotChocolate/Core/src/Types/SchemaBuilder.cs @@ -36,7 +36,6 @@ public partial class SchemaBuilder : ISchemaBuilder [ typeof(IntrospectionTypeInterceptor), typeof(InterfaceCompletionTypeInterceptor), - typeof(CostTypeInterceptor), typeof(MiddlewareValidationTypeInterceptor), typeof(EnableTrueNullabilityTypeInterceptor), ]; diff --git a/src/HotChocolate/Core/src/Types/Types/Attributes/CostAttribute.cs b/src/HotChocolate/Core/src/Types/Types/Attributes/CostAttribute.cs deleted file mode 100644 index 560da23a0a6..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Attributes/CostAttribute.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using HotChocolate.Properties; -using HotChocolate.Types.Descriptors; - -#nullable enable - -namespace HotChocolate.Types; - -/// -/// The cost directive can be used to express the expected -/// cost that a resolver incurs on the system. -/// -public sealed class CostAttribute : ObjectFieldDescriptorAttribute -{ - private readonly int _complexity; - private readonly int? _defaultMultiplier; - private readonly MultiplierPathString[] _multipliers; - - public CostAttribute() - { - _complexity = 1; - _multipliers = Array.Empty(); - } - - public CostAttribute(int complexity) - { - if (complexity <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(complexity), - complexity, - TypeResources.CostDirective_ComplexityCannotBeBelowOne); - } - - _complexity = complexity; - _multipliers = Array.Empty(); - } - - public CostAttribute( - int complexity, - params string[] multipliers) - { - if (complexity <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(complexity), - complexity, - TypeResources.CostDirective_ComplexityCannotBeBelowOne); - } - - if (multipliers is null) - { - throw new ArgumentNullException(nameof(multipliers)); - } - - _complexity = complexity; - _multipliers = multipliers.Select(t => new MultiplierPathString(t)).Where(t => t.HasValue).ToArray(); - } - - public CostAttribute( - int complexity, - int defaultMultiplier, - params string[] multipliers) - { - if (complexity <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(complexity), - complexity, - TypeResources.CostDirective_ComplexityCannotBeBelowOne); - } - - if (defaultMultiplier <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(defaultMultiplier), - defaultMultiplier, - TypeResources.CostDirective_DefaultMultiplierCannotBeBelowTwo); - } - - if (multipliers is null) - { - throw new ArgumentNullException(nameof(multipliers)); - } - - _complexity = complexity; - _defaultMultiplier = defaultMultiplier; - _multipliers = multipliers.Select(t => new MultiplierPathString(t)).Where(t => t.HasValue).ToArray(); - } - - protected override void OnConfigure( - IDescriptorContext context, - IObjectFieldDescriptor descriptor, - MemberInfo member) - { - if (_defaultMultiplier.HasValue) - { - descriptor.Directive( - new CostDirective( - _complexity, - _defaultMultiplier.Value, - _multipliers)); - } - else - { - descriptor.Directive( - new CostDirective( - _complexity, - _multipliers)); - } - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/CostDirective.cs b/src/HotChocolate/Core/src/Types/Types/Directives/CostDirective.cs deleted file mode 100644 index 424161320f1..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/CostDirective.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using HotChocolate.Properties; - -namespace HotChocolate.Types; - -/// -/// The cost directive can be used to express the expected -/// cost that a resolver incurs on the system. -/// -#if NET6_0_OR_GREATER -[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] -#endif -public sealed class CostDirective -{ - /// - /// Initializes a new instance of . - /// - public CostDirective() - { - Complexity = 1; - Multipliers = Array.Empty(); - } - - /// - /// Initializes a new instance of . - /// - /// - /// The complexity of the field. - /// - /// - /// is less than 0. - /// - public CostDirective(int complexity) - { - if (complexity < 0) - { - throw new ArgumentOutOfRangeException( - nameof(complexity), - complexity, - TypeResources.CostDirective_ComplexityCannotBeBelowOne); - } - - Complexity = complexity; - Multipliers = Array.Empty(); - } - - /// - /// Initializes a new instance of . - /// - /// - /// The complexity of the field. - /// - /// - /// The multiplier paths. - /// - /// - /// is less than 0. - /// - /// - /// is null. - /// - public CostDirective( - int complexity, - params MultiplierPathString[] multipliers) - { - if (complexity < 0) - { - throw new ArgumentOutOfRangeException( - nameof(complexity), - complexity, - TypeResources.CostDirective_ComplexityCannotBeBelowOne); - } - - if (multipliers is null) - { - throw new ArgumentNullException(nameof(multipliers)); - } - - Complexity = complexity; - Multipliers = multipliers.Where(t => t.HasValue).ToArray(); - } - - /// - /// Initializes a new instance of . - /// - /// - /// The complexity of the field. - /// - /// - /// The default multiplier. - /// - /// - /// The multiplier paths. - /// - /// - /// is less than 0. - /// - /// - /// is null. - /// - public CostDirective( - int complexity, - int defaultMultiplier, - params MultiplierPathString[] multipliers) - { - if (complexity < 0) - { - throw new ArgumentOutOfRangeException( - nameof(complexity), - complexity, - TypeResources.CostDirective_ComplexityCannotBeBelowOne); - } - - if (defaultMultiplier <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(defaultMultiplier), - defaultMultiplier, - TypeResources.CostDirective_DefaultMultiplierCannotBeBelowTwo); - } - - if (multipliers is null) - { - throw new ArgumentNullException(nameof(multipliers)); - } - - Complexity = complexity; - DefaultMultiplier = defaultMultiplier; - Multipliers = multipliers.Where(t => t.HasValue).ToArray(); - } - - // this constructor is used for serialization. - private CostDirective( - int complexity, - IReadOnlyList multipliers, - int? defaultMultiplier) - { - Complexity = complexity; - Multipliers = multipliers; - DefaultMultiplier = defaultMultiplier; - } - - /// - /// Gets the complexity of the field. - /// - public int Complexity { get; } - - /// - /// Gets the multiplier paths. - /// - public IReadOnlyList Multipliers { get; } - - /// - /// Gets the default multiplier. - /// - public int? DefaultMultiplier { get; } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/CostDirectiveType.cs b/src/HotChocolate/Core/src/Types/Types/Directives/CostDirectiveType.cs deleted file mode 100644 index 7de080bef3e..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/CostDirectiveType.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace HotChocolate.Types; - -/// -/// The cost directive can be used to express the expected -/// cost that a resolver incurs on the system. -/// -public sealed class CostDirectiveType : DirectiveType -{ - protected override void Configure(IDirectiveTypeDescriptor descriptor) - { - descriptor - .Name("cost") - .Description( - "The cost directives is used to express the complexity " + - "of a field.") - .Location(DirectiveLocation.FieldDefinition); - - descriptor - .Argument(t => t.Complexity) - .Name("complexity") - .Description("Defines the complexity of the field.") - .Type>() - .DefaultValue(1); - - descriptor - .Argument(t => t.Multipliers) - .Name("multipliers") - .Description( - "Defines field arguments that act as " + - "complexity multipliers.") - .Type>>(); - - descriptor - .Argument(t => t.DefaultMultiplier) - .Name("defaultMultiplier") - .Description("Gets the default multiplier.") - .Type(); - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/CostInterfaceFieldDescriptorExtensions.cs b/src/HotChocolate/Core/src/Types/Types/Directives/CostInterfaceFieldDescriptorExtensions.cs deleted file mode 100644 index 6e4d32f5542..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/CostInterfaceFieldDescriptorExtensions.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; - -namespace HotChocolate.Types; - -public static class CostInterfaceFieldDescriptorExtensions -{ - /// - /// The cost directive can be used to express the expected - /// cost that a resolver incurs on the system. - /// - /// - /// The interface field descriptor. - /// - /// - /// The complexity of the field. - /// - /// - /// Returns the object field descriptor for configuration chaining. - /// - /// - /// is null. - /// - public static IInterfaceFieldDescriptor Cost( - this IInterfaceFieldDescriptor descriptor, - int complexity) - { - if (descriptor is null) - { - throw new ArgumentNullException(nameof(descriptor)); - } - - return descriptor.Directive(new CostDirective(complexity)); - } - - /// - /// The cost directive can be used to express the expected - /// cost that a resolver incurs on the system. - /// - /// - /// The interface field descriptor. - /// - /// - /// The complexity of the field. - /// - /// - /// The multiplier path. - /// - /// - /// Returns the object field descriptor for configuration chaining. - /// - /// - /// is null. - /// - public static IInterfaceFieldDescriptor Cost( - this IInterfaceFieldDescriptor descriptor, - int complexity, - MultiplierPathString multiplier) - { - if (descriptor is null) - { - throw new ArgumentNullException(nameof(descriptor)); - } - - return descriptor.Directive(new CostDirective(complexity, multiplier)); - } - - /// - /// The cost directive can be used to express the expected - /// cost that a resolver incurs on the system. - /// - /// - /// The interface field descriptor. - /// - /// - /// The complexity of the field. - /// - /// - /// The multiplier paths. - /// - /// - /// - /// is null. - /// - public static IInterfaceFieldDescriptor Cost( - this IInterfaceFieldDescriptor descriptor, - int complexity, - params MultiplierPathString[] multipliers) - { - if (descriptor is null) - { - throw new ArgumentNullException(nameof(descriptor)); - } - - return descriptor.Directive(new CostDirective(complexity, multipliers)); - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/CostObjectFieldDescriptorExtensions.cs b/src/HotChocolate/Core/src/Types/Types/Directives/CostObjectFieldDescriptorExtensions.cs deleted file mode 100644 index 95a6bf6e87c..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/CostObjectFieldDescriptorExtensions.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; - -namespace HotChocolate.Types; - -public static class CostObjectFieldDescriptorExtensions -{ - /// - /// The cost directive can be used to express the expected - /// cost that a resolver incurs on the system. - /// - /// - /// The object field descriptor. - /// - /// - /// The complexity of the field. - /// - /// - /// Returns the object field descriptor for configuration chaining. - /// - /// - /// is null. - /// - public static IObjectFieldDescriptor Cost( - this IObjectFieldDescriptor descriptor, - int complexity) - { - if (descriptor is null) - { - throw new ArgumentNullException(nameof(descriptor)); - } - - return descriptor.Directive(new CostDirective(complexity)); - } - - /// - /// The cost directive can be used to express the expected - /// cost that a resolver incurs on the system. - /// - /// - /// The object field descriptor. - /// - /// - /// The complexity of the field. - /// - /// - /// The multiplier path. - /// - /// - /// Returns the object field descriptor for configuration chaining. - /// - /// - /// is null. - /// - public static IObjectFieldDescriptor Cost( - this IObjectFieldDescriptor descriptor, - int complexity, - MultiplierPathString multiplier) - { - if (descriptor is null) - { - throw new ArgumentNullException(nameof(descriptor)); - } - - return descriptor.Directive(new CostDirective(complexity, multiplier)); - } - - /// - /// The cost directive can be used to express the expected - /// cost that a resolver incurs on the system. - /// - /// - /// The object field descriptor. - /// - /// - /// The complexity of the field. - /// - /// - /// The multiplier paths. - /// - /// - /// - /// is null. - /// - public static IObjectFieldDescriptor Cost( - this IObjectFieldDescriptor descriptor, - int complexity, - params MultiplierPathString[] multipliers) - { - if (descriptor is null) - { - throw new ArgumentNullException(nameof(descriptor)); - } - - return descriptor.Directive(new CostDirective(complexity, multipliers)); - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/CostTypeInterceptor.cs b/src/HotChocolate/Core/src/Types/Types/Directives/CostTypeInterceptor.cs deleted file mode 100644 index 5c538306f8d..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/CostTypeInterceptor.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using HotChocolate.Configuration; -using HotChocolate.Language; -using HotChocolate.Types.Descriptors; -using HotChocolate.Types.Descriptors.Definitions; -using HotChocolate.Types.Pagination; -using HotChocolate.Utilities; - -#nullable enable - -namespace HotChocolate.Types; - -internal class CostTypeInterceptor : TypeInterceptor -{ - private const string _connectionType = - "HotChocolate.Types.Pagination.Connection"; - private const string _complexitySettings = - "HotChocolate.Execution.Options.ComplexityAnalyzerSettings"; - private bool _pagingSettingsResolved; - private bool _costSettingsResolved; - private PagingOptions _pagingOptions; - private ICostSettings _costSettings = default!; - - public override void OnBeforeRegisterDependencies( - ITypeDiscoveryContext discoveryContext, - DefinitionBase definition) - { - EnsurePagingSettingsAreLoaded(discoveryContext.DescriptorContext); - EnsureCostSettingsAreLoaded(discoveryContext.DescriptorContext); - - if (!_costSettings.Enable) - { - return; - } - - // if the cost settings are set to apply default cost we need to ensure that - // object types that we apply defaults to have type dependencies to the - // cost directive. - if (_costSettings.ApplyDefaults && - !discoveryContext.IsIntrospectionType && - definition is ObjectTypeDefinition objectDef && - objectDef.Fields.Any(CanApplyDefaultCost)) - { - var directive = - discoveryContext.TypeInspector.GetType(typeof(CostDirectiveType)); - - discoveryContext.Dependencies.Add(new( - TypeReference.Create(directive), - TypeDependencyFulfilled.Completed)); - } - } - - public override void OnBeforeCompleteType( - ITypeCompletionContext completionContext, - DefinitionBase definition) - { - if (!_costSettings.Enable || !_costSettings.ApplyDefaults) - { - return; - } - - if (!completionContext.IsIntrospectionType && - definition is ObjectTypeDefinition objectDef) - { - foreach (var field in objectDef.Fields) - { - if (CanApplyDefaultCost(field)) - { - if (IsConnection(field)) - { - ApplyConnectionCosts(field); - } - else if (IsDataResolver(field)) - { - ApplyDataResolverCosts(field); - } - } - } - } - } - - private void ApplyConnectionCosts(ObjectFieldDefinition field) - { - var multipliers = new ListValueNode( - new StringValueNode("first"), - new StringValueNode("last")); - - var defaultMultiplier = _pagingOptions.DefaultPageSize ?? 10; - - field.Directives.Add( - new DirectiveDefinition( - new DirectiveNode( - "cost", - new ArgumentNode("complexity", _costSettings.DefaultResolverComplexity), - new ArgumentNode("multipliers", multipliers), - new ArgumentNode("defaultMultiplier", defaultMultiplier)))); - } - - private void ApplyDataResolverCosts(ObjectFieldDefinition field) - { - field.Directives.Add( - new DirectiveDefinition( - new DirectiveNode( - "cost", - new ArgumentNode("complexity", _costSettings.DefaultResolverComplexity)))); - } - - private bool CanApplyDefaultCost(ObjectFieldDefinition field) - { - if (field.IsIntrospectionField) - { - return false; - } - - var directives = field.GetDirectives(); - return directives is { Count: 0, } || !directives.Any(IsCostDirective); - } - - private static bool IsCostDirective(DirectiveDefinition directive) - { - if (directive.Type is NameDirectiveReference { Name: "cost", }) - { - return true; - } - - if (directive.Type is ExtendedTypeDirectiveReference { Type.Type: { } runtimeType, } && - runtimeType == typeof(CostDirective)) - { - return true; - } - - return false; - } - - /// - /// Defines if a resolver is possible fetching data and causing higher impact on the system. - /// - internal static bool IsDataResolver(ObjectFieldDefinition field) - { - if (field.PureResolver is not null && field.MiddlewareDefinitions.Count == 0) - { - return false; - } - - if (field.Resolver is not null) - { - return true; - } - - var resolver = field.ResolverMember ?? field.Member; - - if (resolver is MethodInfo method) - { - if (typeof(Task).IsAssignableFrom(method.ReturnType) || - typeof(IQueryable).IsAssignableFrom(method.ReturnType) || - typeof(IExecutable).IsAssignableFrom(method.ReturnType)) - { - return true; - } - - if (method.ReturnType.IsGenericType && - method.ReturnType.GetGenericTypeDefinition() == typeof(ValueTask<>)) - { - return true; - } - } - - return false; - } - - private static bool IsConnection(ObjectFieldDefinition field) => - field.GetCustomSettings() - .OfType() - .Any(t => t.FullName.EqualsOrdinal(_connectionType)); - - private void EnsurePagingSettingsAreLoaded(IDescriptorContext descriptorContext) - { - if (!_pagingSettingsResolved) - { - _pagingOptions = descriptorContext.GetSettings(_pagingOptions); - _pagingSettingsResolved = true; - } - } - - private void EnsureCostSettingsAreLoaded(IDescriptorContext descriptorContext) - { - if (!_costSettingsResolved) - { - _costSettings = - descriptorContext.ContextData.TryGetValue(_complexitySettings, out var value) && - value is ICostSettings costSettings - ? costSettings - : new DefaultCostSettings(); - _costSettingsResolved = true; - } - } - - private sealed class DefaultCostSettings : ICostSettings - { - public bool Enable => false; - public bool ApplyDefaults => false; - public int DefaultComplexity => 1; - public int DefaultResolverComplexity => 5; - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/Directives.cs b/src/HotChocolate/Core/src/Types/Types/Directives/Directives.cs index 34e250968e5..fc0c51f94a1 100644 --- a/src/HotChocolate/Core/src/Types/Types/Directives/Directives.cs +++ b/src/HotChocolate/Core/src/Types/Types/Directives/Directives.cs @@ -39,12 +39,7 @@ internal static IReadOnlyList CreateReferences( { directiveTypes.Add(typeInspector.GetTypeRef(typeof(StreamDirectiveType))); } - - if (descriptorContext.Options.EnableTrueNullability) - { - directiveTypes.Add(typeInspector.GetTypeRef(typeof(NullBubblingDirective))); - } - + if (descriptorContext.Options.EnableTag) { directiveTypes.Add(typeInspector.GetTypeRef(typeof(Tag))); diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/MultiplierPathString.cs b/src/HotChocolate/Core/src/Types/Types/Directives/MultiplierPathString.cs deleted file mode 100644 index e2781539627..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/MultiplierPathString.cs +++ /dev/null @@ -1,344 +0,0 @@ -using System; -using System.ComponentModel; -using System.Globalization; -using HotChocolate.Language; -using HotChocolate.Properties; - -namespace HotChocolate.Types; - -/// -/// The type name string guarantees that a string adheres to the -/// GraphQL spec rules: /[_A-Za-z][_0-9A-Za-z]*/ -/// -[TypeConverter(typeof(MultiplierPathStringConverter))] -public struct MultiplierPathString : IEquatable -{ - - /// - /// Initializes a new instance of the - /// struct. - /// - /// The actual type name string - public MultiplierPathString(string value) - { - if (!IsValidPath(value)) - { - throw new ArgumentException( - TypeResourceHelper.Type_Name_IsNotValid(value), - nameof(value)); - } - Value = value; - } - - /// - /// The name value. - /// - public string Value { get; } - - /// - /// true if the name is not empty - /// - public bool HasValue - { - get - { - return !IsEmpty; - } - } - - public bool IsEmpty - { - get => string.IsNullOrEmpty(Value); - } - - /// - /// Provides the name string. - /// - /// The name string value - public override string ToString() - { - return Value; - } - - /// - /// Appends a to this - /// instance and returns a new instance of - /// representing the combined - /// . - /// - /// The combined . - public MultiplierPathString Add(MultiplierPathString other) - { - return new(Value + other.Value); - } - - /// - /// Compares this value - /// to another value using a specific - /// type. - /// - /// - /// The second for comparison. - /// - /// - /// The type to use. - /// - /// - /// true if both values - /// are equal. - /// - public bool Equals( - MultiplierPathString other, - StringComparison comparisonType) - { - if (!HasValue && !other.HasValue) - { - return true; - } - return string.Equals(Value, other.Value, comparisonType); - } - - /// - /// Compares this value to - /// another value using - /// comparison type. - /// - /// - /// The second for comparison. - /// - /// - /// true if both - /// values are equal. - /// - public bool Equals(MultiplierPathString other) => - Equals(other, StringComparison.Ordinal); - - /// - /// Compares this value to - /// another value using - /// comparison. - /// - /// - /// The second for comparison. - /// - /// - /// true if both values - /// are equal. - /// - public override bool Equals(object obj) - { - if (obj is null) - { - return IsEmpty; - } - return obj is MultiplierPathString n && Equals(n); - } - - /// - /// Serves as a hash function for a - /// object. - /// - /// - /// A hash code for this instance that is suitable for use in hashing - /// algorithms and data structures such as a hash table. - /// - public override int GetHashCode() - { - return HasValue ? StringComparer.Ordinal.GetHashCode(Value) : 0; - } - - /// - /// Operator call through to Equals - /// - /// The left parameter - /// The right parameter - /// - /// true if both - /// values are equal. - /// - public static bool operator ==( - MultiplierPathString left, - MultiplierPathString right) - { - return left.Equals(right); - } - - /// - /// Operator call through to Equals - /// - /// The left parameter - /// The right parameter - /// - /// true if both values - /// are not equal. - /// - public static bool operator !=( - MultiplierPathString left, - MultiplierPathString right) - { - return !left.Equals(right); - } - - /// - /// - /// The left parameter - /// The right parameter - /// The ToString combination of both values - public static string operator +(string left, MultiplierPathString right) - { - // This overload exists to prevent the implicit - // string<->MultiplierPathString - // converter from trying to call the - // MultiplierPathString+MultiplierPathString operator - // for things that are not name strings. - return string.Concat(left, right.ToString()); - } - - /// - /// - /// The left parameter - /// The right parameter - /// The ToString combination of both values - public static string operator +(MultiplierPathString left, string right) - { - // This overload exists to prevent the implicit - // string<->MultiplierPathString - // converter from trying to call the - // MultiplierPathString+MultiplierPathString operator - // for things that are not name strings. - return string.Concat(left.ToString(), right); - } - - /// - /// Operator call through to Add - /// - /// The left parameter - /// The right parameter - /// - /// The combination of both values - /// - public static MultiplierPathString operator +( - MultiplierPathString left, - MultiplierPathString right) - { - return left.Add(right); - } - - /// - /// Implicitly creates a new from - /// the given string. - /// - /// The string. - public static implicit operator MultiplierPathString(string s) - => ConvertFromString(s); - - /// - /// Implicitly calls ToString(). - /// - /// - public static implicit operator string(MultiplierPathString name) - => name.ToString(); - - internal static MultiplierPathString ConvertFromString(string s) - => string.IsNullOrEmpty(s) - ? new MultiplierPathString() - : new MultiplierPathString(s); - - public static bool IsValidPath(string name) - { - if (name is null || name.Length == 0) - { - return false; - } - - if (name[0].IsLetterOrUnderscore()) - { - if (name.Length > 1) - { - for (var i = 1; i < name.Length; i++) - { - if (!name[i].IsLetterOrDigitOrUnderscore() - && name[i] != GraphQLConstants.Dot) - { - return false; - } - } - } - - return true; - } - - return false; - } - - public static bool IsValidPath(ReadOnlySpan name) - { - if (name.Length == 0) - { - return false; - } - - if (name[0].IsLetterOrUnderscore()) - { - if (name.Length > 1) - { - for (var i = 1; i < name.Length; i++) - { - if (!name[i].IsLetterOrDigitOrUnderscore() - && name[i] != GraphQLConstants.Dot) - { - return false; - } - } - } - - return true; - } - - return false; - } -} - -internal class MultiplierPathStringConverter - : TypeConverter -{ - public override bool CanConvertFrom( - ITypeDescriptorContext context, - Type sourceType) => - sourceType == typeof(string) - || base.CanConvertFrom(context, sourceType); - - public override object ConvertFrom( - ITypeDescriptorContext context, - CultureInfo culture, - object value) => - value is string - ? MultiplierPathString.ConvertFromString((string)value) - : base.ConvertFrom(context, culture, value); - - public override object ConvertTo( - ITypeDescriptorContext context, - CultureInfo culture, - object value, - Type destinationType) => - destinationType == typeof(string) - ? value.ToString() - : base.ConvertTo(context, culture, value, destinationType); -} - -public static class MultiplierPathStringExtensions -{ - public static MultiplierPathString EnsureNotEmpty( - this MultiplierPathString name, - string argumentName) - { - if (name.IsEmpty) - { - throw new ArgumentException( - TypeResources.Name_Cannot_BeEmpty, - argumentName); - } - - return name; - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Directives/NullBubblingDirective.cs b/src/HotChocolate/Core/src/Types/Types/Directives/NullBubblingDirective.cs deleted file mode 100644 index 4e8fec48fc9..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Directives/NullBubblingDirective.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace HotChocolate.Types; - -[DirectiveType( - WellKnownDirectives.NullBubbling, - DirectiveLocation.Query | - DirectiveLocation.Mutation | - DirectiveLocation.Subscription)] -public class NullBubblingDirective -{ - public NullBubblingDirective(bool enable = true) - { - Enable = enable; - } - - [DefaultValue(true)] - [GraphQLName(WellKnownDirectives.Enable)] - public bool Enable { get; } -} \ No newline at end of file diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/DateType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/DateType.cs index 912389526aa..42bf8a70b44 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/DateType.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/DateType.cs @@ -132,7 +132,7 @@ private static bool TryDeserializeFromString( if (DateTime.TryParse( serialized, CultureInfo.InvariantCulture, - DateTimeStyles.AssumeLocal, + DateTimeStyles.None, out var dateTime)) { value = dateTime.Date; diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/MultiplierPathType.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/MultiplierPathType.cs deleted file mode 100644 index d17cbee5a9f..00000000000 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/MultiplierPathType.cs +++ /dev/null @@ -1,124 +0,0 @@ -using HotChocolate.Language; -using HotChocolate.Properties; - -#nullable enable - -namespace HotChocolate.Types; - -/// -/// The name scalar represents a valid GraphQL name as specified in the spec -/// and can be used to refer to fields or types. -/// -public class MultiplierPathType - : ScalarType -{ - /// - /// Initializes a new instance of the class. - /// - public MultiplierPathType( - string name, - string? description = null, - BindingBehavior bind = BindingBehavior.Explicit) - : base(name, bind) - { - Description = description; - } - - /// - /// Initializes a new instance of the class. - /// - [ActivatorUtilitiesConstructor] - public MultiplierPathType() - : this( - ScalarNames.MultiplierPath, - TypeResources.MultiplierPathType_Description, - BindingBehavior.Implicit) - { - } - - protected override bool IsInstanceOfType(StringValueNode valueSyntax) - { - return MultiplierPathString.IsValidPath(valueSyntax.AsSpan()); - } - - protected override MultiplierPathString ParseLiteral(StringValueNode valueSyntax) - { - if (IsInstanceOfType(valueSyntax)) - { - return new MultiplierPathString(valueSyntax.Value); - } - - throw new SerializationException( - TypeResourceHelper.Scalar_Cannot_ParseLiteral(Name, valueSyntax.GetType()), - this); - } - - protected override StringValueNode ParseValue(MultiplierPathString runtimeValue) - { - return new StringValueNode(runtimeValue.Value); - } - - public override IValueNode ParseResult(object? resultValue) - { - if (resultValue is null) - { - return NullValueNode.Default; - } - - if (resultValue is string s) - { - return new StringValueNode(s); - } - - if (resultValue is MultiplierPathString p) - { - return new StringValueNode(p.Value); - } - - throw new SerializationException( - TypeResourceHelper.Scalar_Cannot_ParseResult(Name, resultValue.GetType()), - this); - } - - public override bool TrySerialize(object? runtimeValue, out object? resultValue) - { - if (runtimeValue is null) - { - resultValue = null; - return true; - } - - if (runtimeValue is MultiplierPathString path) - { - resultValue = path.Value; - return true; - } - - resultValue = null; - return false; - } - - public override bool TryDeserialize(object? resultValue, out object? runtimeValue) - { - if (resultValue is null) - { - runtimeValue = null; - return true; - } - - if (resultValue is string s) - { - runtimeValue = new MultiplierPathString(s); - return true; - } - - if (resultValue is MultiplierPathString p) - { - runtimeValue = p; - return true; - } - - runtimeValue = null; - return false; - } -} diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarNames.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarNames.cs index f204f8a66da..f56b08da4f6 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarNames.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/ScalarNames.cs @@ -18,7 +18,6 @@ public static class ScalarNames public const string DateTime = nameof(DateTime); public const string Date = nameof(Date); public const string TimeSpan = nameof(TimeSpan); - public const string MultiplierPath = nameof(MultiplierPath); public const string Name = nameof(Name); public const string PaginationAmount = nameof(PaginationAmount); public const string JSON = nameof(JSON); diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/Scalars.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/Scalars.cs index 548f3a3de4b..ef210b6bbc5 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/Scalars.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/Scalars.cs @@ -30,7 +30,6 @@ public static class Scalars { typeof(Guid), typeof(UuidType) }, { typeof(DateTime), typeof(DateTimeType) }, { typeof(DateTimeOffset), typeof(DateTimeType) }, - { typeof(MultiplierPathString), typeof(MultiplierPathType) }, { typeof(byte[]), typeof(ByteArrayType) }, { typeof(TimeSpan), typeof(TimeSpanType) }, @@ -60,8 +59,7 @@ public static class Scalars { ScalarNames.Date, typeof(DateType) }, { ScalarNames.TimeSpan, typeof(TimeSpanType) }, { ScalarNames.Any, typeof(AnyType) }, - - { ScalarNames.MultiplierPath, typeof(MultiplierPathType) }, + { ScalarNames.ByteArray, typeof(ByteArrayType) }, { ScalarNames.JSON, typeof(JsonType) }, diff --git a/src/HotChocolate/Core/src/Types/Utilities/DefaultTypeConverter.Setup.cs b/src/HotChocolate/Core/src/Types/Utilities/DefaultTypeConverter.Setup.cs index 5d48fd8dc91..9821d1169b1 100644 --- a/src/HotChocolate/Core/src/Types/Utilities/DefaultTypeConverter.Setup.cs +++ b/src/HotChocolate/Core/src/Types/Utilities/DefaultTypeConverter.Setup.cs @@ -48,7 +48,16 @@ private static void RegisterDateTimeConversions( DefaultTypeConverter registry) { registry.Register(from => from.UtcDateTime); - registry.Register(from => from); + registry.Register( + from => + { + if (from.Kind is DateTimeKind.Unspecified) + { + from = DateTime.SpecifyKind(from, DateTimeKind.Utc); + } + + return new DateTimeOffset(from); + }); registry.Register(from => from.ToUnixTimeSeconds()); registry.Register(from => FromUnixTimeSeconds(from)); diff --git a/src/HotChocolate/Core/src/Validation/DocumentValidator.cs b/src/HotChocolate/Core/src/Validation/DocumentValidator.cs index 31b4b57412d..b78d73eec2f 100644 --- a/src/HotChocolate/Core/src/Validation/DocumentValidator.cs +++ b/src/HotChocolate/Core/src/Validation/DocumentValidator.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using HotChocolate.Execution; using HotChocolate.Language; using HotChocolate.Validation.Options; @@ -67,7 +68,7 @@ public DocumentValidator( public ValueTask ValidateAsync( ISchema schema, DocumentNode document, - string documentId, + OperationDocumentId documentId, IDictionary contextData, bool onlyNonCachable, CancellationToken cancellationToken = default) @@ -82,7 +83,7 @@ public ValueTask ValidateAsync( throw new ArgumentNullException(nameof(document)); } - if (documentId is null) + if (documentId.IsEmpty) { throw new ArgumentNullException(nameof(documentId)); } @@ -172,7 +173,7 @@ private async ValueTask RunResultAggregators( private void PrepareContext( ISchema schema, DocumentNode document, - string documentId, + OperationDocumentId documentId, DocumentValidatorContext context, IDictionary contextData) { diff --git a/src/HotChocolate/Core/src/Validation/DocumentValidatorContext.cs b/src/HotChocolate/Core/src/Validation/DocumentValidatorContext.cs index 084655c6c9f..dd0ce8297a2 100644 --- a/src/HotChocolate/Core/src/Validation/DocumentValidatorContext.cs +++ b/src/HotChocolate/Core/src/Validation/DocumentValidatorContext.cs @@ -34,7 +34,7 @@ public ISchema Schema } } - public string DocumentId { get; set; } = default!; + public OperationDocumentId DocumentId { get; set; } public OperationType? OperationType { get; set; } diff --git a/src/HotChocolate/Core/src/Validation/IDocumentValidator.cs b/src/HotChocolate/Core/src/Validation/IDocumentValidator.cs index cc3d16bc09c..3bcaf836658 100644 --- a/src/HotChocolate/Core/src/Validation/IDocumentValidator.cs +++ b/src/HotChocolate/Core/src/Validation/IDocumentValidator.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using HotChocolate.Execution; using HotChocolate.Language; namespace HotChocolate.Validation; @@ -45,7 +46,7 @@ public interface IDocumentValidator ValueTask ValidateAsync( ISchema schema, DocumentNode document, - string documentId, + OperationDocumentId documentId, IDictionary contextData, bool onlyNonCacheable, CancellationToken cancellationToken = default); diff --git a/src/HotChocolate/Core/src/Validation/IDocumentValidatorContext.cs b/src/HotChocolate/Core/src/Validation/IDocumentValidatorContext.cs index 98cbb584c00..0fcc148476f 100644 --- a/src/HotChocolate/Core/src/Validation/IDocumentValidatorContext.cs +++ b/src/HotChocolate/Core/src/Validation/IDocumentValidatorContext.cs @@ -19,7 +19,7 @@ public interface IDocumentValidatorContext /// /// Gets the unique document identifier. /// - string DocumentId { get; } + OperationDocumentId DocumentId { get; } /// /// Gets the current operation type. diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QuerySourceTextTests.cs b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationDocumentSourceTextTests.cs similarity index 61% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/QuerySourceTextTests.cs rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationDocumentSourceTextTests.cs index c82cda15d60..9df492e6837 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QuerySourceTextTests.cs +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationDocumentSourceTextTests.cs @@ -7,14 +7,14 @@ namespace HotChocolate.Execution; -public class QuerySourceTextTests +public class OperationDocumentSourceTextTests { [Fact] public void Create_Document_IsNull() { // arrange // act - void Action() => new QuerySourceText(null); + void Action() => new OperationDocumentSourceText(null); // assert Assert.Throws(Action); @@ -25,10 +25,10 @@ public void Create_Document() { // arrange // act - var query = new QuerySourceText("{ a }"); + var query = new OperationDocumentSourceText("{ a }"); // assert - Assert.Equal("{ a }", query.Text); + Assert.Equal("{ a }", query.SourceText); } [Fact] @@ -36,7 +36,7 @@ public void QueryDocument_ToString() { // arrange // act - var query = new QuerySourceText("{ a }"); + var query = new OperationDocumentSourceText("{ a }"); // assert query.ToString().MatchSnapshot(); @@ -47,7 +47,7 @@ public void QueryDocument_ToSource() { // arrange // act - var query = new QuerySourceText("{ a }"); + var query = new OperationDocumentSourceText("{ a }"); // assert Utf8GraphQLParser @@ -60,7 +60,7 @@ public void QueryDocument_ToSource() public async Task QuerySourceText_WriteToAsync() { // arrange - var query = new QuerySourceText("{ a }"); + var query = new OperationDocumentSourceText("{ a }"); byte[] buffer; // act @@ -73,28 +73,7 @@ public async Task QuerySourceText_WriteToAsync() // assert Utf8GraphQLParser .Parse(buffer) - .Print(true) - .MatchSnapshot(); - } - - [Fact] - public void QuerySourceText_WriteTo() - { - // arrange - var query = new QuerySourceText("{ a }"); - byte[] buffer; - - // act - using (var stream = new MemoryStream()) - { - query.WriteTo(stream); - buffer = stream.ToArray(); - } - - // assert - Utf8GraphQLParser - .Parse(buffer) - .Print(true) + .Print() .MatchSnapshot(); } } \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryDocumentTests.cs b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationDocumentTests.cs similarity index 67% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryDocumentTests.cs rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationDocumentTests.cs index eb6f1ea1108..42d23d1dec4 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryDocumentTests.cs +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationDocumentTests.cs @@ -7,14 +7,14 @@ namespace HotChocolate.Execution; -public class QueryDocumentTests +public class OperationDocumentTests { [Fact] public void Create_Document_IsNull() { // arrange // act - void Action() => new QueryDocument(null); + void Action() => new OperationDocument(null); // assert Assert.Throws(Action); @@ -27,7 +27,7 @@ public void Create_Document() var document = Utf8GraphQLParser.Parse("{ a }"); // act - var query = new QueryDocument(document); + var query = new OperationDocument(document); // assert Assert.Equal(document, query.Document); @@ -40,7 +40,7 @@ public void QueryDocument_ToString() var document = Utf8GraphQLParser.Parse("{ a }"); // act - var query = new QueryDocument(document); + var query = new OperationDocument(document); // assert query.Document.ToString(false).MatchSnapshot(); @@ -53,7 +53,7 @@ public void QueryDocument_ToSource() var document = Utf8GraphQLParser.Parse("{ a }"); // act - var query = new QueryDocument(document); + var query = new OperationDocument(document); // assert Utf8GraphQLParser @@ -67,7 +67,7 @@ public async Task QueryDocument_WriteToAsync() { // arrange var document = Utf8GraphQLParser.Parse("{ a }"); - var query = new QueryDocument(document); + var query = new OperationDocument(document); byte[] buffer; // act @@ -83,26 +83,4 @@ public async Task QueryDocument_WriteToAsync() .Print(true) .MatchSnapshot(); } - - [Fact] - public void QueryDocument_WriteTo() - { - // arrange - var document = Utf8GraphQLParser.Parse("{ a }"); - var query = new QueryDocument(document); - byte[] buffer; - - // act - using (var stream = new MemoryStream()) - { - query.WriteTo(stream); - buffer = stream.ToArray(); - } - - // assert - Utf8GraphQLParser - .Parse(buffer) - .Print(true) - .MatchSnapshot(); - } } \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryResultBuilderTests.cs b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationResultBuilderTests.cs similarity index 72% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryResultBuilderTests.cs rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationResultBuilderTests.cs index d2c75082ef4..aa0fffbef65 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryResultBuilderTests.cs +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/OperationResultBuilderTests.cs @@ -4,14 +4,14 @@ namespace HotChocolate.Execution; -public class QueryResultBuilderTests +public class OperationResultBuilderTests { [Fact] public void Create_Result_Without_Data_And_Errors() { // arrange // act - Action result = () => QueryResultBuilder.New().Create(); + Action result = () => OperationResultBuilder.New().Build(); // assert Assert.Throws(result); @@ -21,35 +21,35 @@ public void Create_Result_Without_Data_And_Errors() public void Create_Result_Set_Data() { // arrange - var builder = new QueryResultBuilder(); + var builder = new OperationResultBuilder(); // act builder.SetData(new Dictionary { { "a", "b" }, }); // assert - builder.Create().MatchSnapshot(); + builder.Build().MatchSnapshot(); } [Fact] public void Create_Result_Set_Items() { // arrange - var builder = new QueryResultBuilder(); + var builder = new OperationResultBuilder(); // act builder.SetItems(new List { 1, }); // assert - builder.Create().MatchSnapshot(); + builder.Build().MatchSnapshot(); } [Fact] public void ExpectQueryResult() { // arrange - IExecutionResult result = QueryResultBuilder.New() + IExecutionResult result = OperationResultBuilder.New() .SetData(new Dictionary { { "a", "b" }, }) - .Create(); + .Build(); // act var queryResult = result.ExpectQueryResult(); @@ -62,9 +62,9 @@ public void ExpectQueryResult() public void ExpectResponseStream() { // arrange - IExecutionResult result = QueryResultBuilder.New() + IExecutionResult result = OperationResultBuilder.New() .SetData(new Dictionary { { "a", "b" }, }) - .Create(); + .Build(); // act void Fail() => result.ExpectResponseStream(); diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryRequestBuilderTests.cs b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryRequestBuilderTests.cs index 4f371407ad3..88800baad1e 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryRequestBuilderTests.cs +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/QueryRequestBuilderTests.cs @@ -6,7 +6,7 @@ namespace HotChocolate.Execution; -public class QueryRequestBuilderTests +public class OperationRequestBuilderTests { [Fact] public void BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery() @@ -14,9 +14,9 @@ public void BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .Build(); // assert request.MatchSnapshot(); @@ -30,26 +30,25 @@ public void BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery() // act var request = - QueryRequestBuilder.New() - .SetQuery(query) - .Create(); + OperationRequestBuilder.Create() + .SetDocument(query) + .Build(); // assert request.MatchSnapshot(); } [Fact] - public void BuildRequest_Empty_QueryRequestBuilderException() + public void BuildRequest_Empty_OperationRequestBuilderException() { // arrange // act Action action = () => - QueryRequestBuilder.New() - .Create(); + OperationRequestBuilder.Create() + .Build(); // assert - Assert.Throws(action) - .Message.MatchSnapshot(); + Assert.Throws(action).Message.MatchSnapshot(); } [InlineData("")] @@ -60,79 +59,26 @@ public void SetQuery_NullOrEmpty_ArgumentException(string query) // arrange // act void Action() => - QueryRequestBuilder.New() - .SetQuery(query) - .Create(); + OperationRequestBuilder.Create() + .SetDocument(query) + .Build(); // assert - Assert.Equal("sourceText", + Assert.Equal( + "sourceText", Assert.Throws(Action).ParamName); } - [Fact] - public void BuildRequest_QueryAndAddVariables_RequestIsCreated() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddVariableValue("one", "foo") - .AddVariableValue("two", "bar") - .Create(); - - // assert - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetVariables_RequestIsCreated() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddVariableValue("one", "foo") - .AddVariableValue("two", "bar") - .SetVariableValues(new Dictionary - { - { "three", "baz" }, - }) - .Create(); - - // assert - // only three should be in the request - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetVariable_RequestIsCreated() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddVariableValue("one", "foo") - .SetVariableValue("one", "bar") - .Create(); - - // assert - // one should be bar - request.MatchSnapshot(); - } - [Fact] public void BuildRequest_QueryAndSetNewVariable_RequestIsCreated() { // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .SetVariableValue("one", "bar") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .SetVariableValues(new Dictionary { ["one"] = "bar", }) + .Build(); // assert // one should be bar @@ -145,12 +91,11 @@ public void BuildRequest_QueryAndResetVariables_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddVariableValue("one", "foo") - .AddVariableValue("two", "bar") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .SetVariableValues(new Dictionary { ["one"] = "bar", }) .SetVariableValues(null) - .Create(); + .Build(); // assert // no variable should be in the request @@ -163,11 +108,11 @@ public void BuildRequest_QueryAndAddProperties_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .AddGlobalState("one", "foo") .AddGlobalState("two", "bar") - .Create(); + .Build(); // assert request.MatchSnapshot(); @@ -179,15 +124,16 @@ public void BuildRequest_QueryAndSetProperties_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .AddGlobalState("one", "foo") .AddGlobalState("two", "bar") - .InitializeGlobalState(new Dictionary - { - { "three", "baz" }, - }) - .Create(); + .SetGlobalState( + new Dictionary + { + { "three", "baz" }, + }) + .Build(); // assert // only three should exist @@ -200,11 +146,11 @@ public void BuildRequest_QueryAndSetProperty_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .AddGlobalState("one", "foo") .SetGlobalState("one", "bar") - .Create(); + .Build(); // assert // one should be bar @@ -217,10 +163,10 @@ public void BuildRequest_QueryAndSetNewProperty_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .SetGlobalState("one", "bar") - .Create(); + .Build(); // assert // one should be bar @@ -233,12 +179,12 @@ public void BuildRequest_QueryAndResetProperties_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .AddGlobalState("one", "foo") .AddGlobalState("two", "bar") - .InitializeGlobalState(null) - .Create(); + .SetGlobalState(null) + .Build(); // assert // no property should be in the request @@ -251,10 +197,10 @@ public void BuildRequest_QueryAndInitialValue_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .SetGlobalState(WellKnownContextData.InitialValue, new { a = "123", }) - .Create(); + .Build(); // assert request.MatchSnapshot(); @@ -266,10 +212,10 @@ public void BuildRequest_QueryAndOperation_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .SetOperation("bar") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .SetOperationName("bar") + .Build(); // assert request.MatchSnapshot(); @@ -281,11 +227,11 @@ public void BuildRequest_QueryAndResetOperation_RequestIsCreated() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .SetOperation("bar") - .SetOperation(null) - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .SetOperationName("bar") + .SetOperationName(null) + .Build(); // assert // the operation should be null @@ -300,11 +246,13 @@ public void BuildRequest_QueryAndServices_RequestIsCreated() // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .SetServices(new DictionaryServiceProvider( - service.GetType(), service)) - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .SetServices( + new DictionaryServiceProvider( + service.GetType(), + service)) + .Build(); // assert request.MatchSnapshot(); @@ -318,14 +266,13 @@ public void BuildRequest_SetAll_RequestIsCreated() // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .SetOperation("bar") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .SetOperationName("bar") .AddGlobalState("one", "foo") - .AddVariableValue("two", "bar") - .SetServices(new DictionaryServiceProvider( - service.GetType(), service)) - .Create(); + .SetVariableValues(new Dictionary { { "two", "bar" }, }) + .SetServices(new DictionaryServiceProvider(service.GetType(), service)) + .Build(); // assert request.MatchSnapshot(); @@ -337,10 +284,10 @@ public void BuildRequest_QueryAndTryAddProperties_PropertyIsSet() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .TryAddGlobalState("one", "bar") - .Create(); + .Build(); // assert request.MatchSnapshot(); @@ -352,227 +299,13 @@ public void BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet() // arrange // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .AddGlobalState("one", "foo") .TryAddGlobalState("one", "bar") - .Create(); - - // assert - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndTryAddVariable_VariableIsSet() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .TryAddVariableValue("one", "bar") - .Create(); - - // assert - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndTryAddVariable_VariableIsNotSet() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddVariableValue("one", "foo") - .TryAddVariableValue("one", "bar") - .Create(); - - // assert - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndTryAddExtension_ExtensionIsSet() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .TryAddExtension("one", "bar") - .Create(); + .Build(); // assert request.MatchSnapshot(); } - - [Fact] - public void BuildRequest_QueryAndTryAddExtension_ExtensionIsNotSet() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .TryAddExtension("one", "bar") - .Create(); - - // assert - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndAddExtension_RequestIsCreated() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .AddExtension("two", "bar") - .Create(); - - // assert - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_1() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .AddExtension("two", "bar") - .SetExtensions(new Dictionary - { - { "three", "baz" }, - }) - .Create(); - - // assert - // only three should exist - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_2() - { - // arrange - IReadOnlyDictionary ext = - new Dictionary - { - { "three", "baz" }, - }; - - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .AddExtension("two", "bar") - .SetExtensions(ext) - .Create(); - - // assert - // only three should exist - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_3() - { - // arrange - IReadOnlyDictionary ext = - new Dictionary - { - { "three", "baz" }, - }; - - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .AddExtension("two", "bar") - .SetExtensions(ext) - .AddExtension("four", "bar") - .Create(); - - // assert - // only three should exist - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_4() - { - // arrange - IDictionary ext = - new Dictionary - { - { "three", "baz" }, - }; - - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .AddExtension("two", "bar") - .SetExtensions(ext) - .Create(); - - // assert - // only three should exist - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_5() - { - // arrange - IDictionary ext = - new Dictionary - { - { "three", "baz" }, - }; - - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .AddExtension("two", "bar") - .SetExtensions(ext) - .AddExtension("four", "bar") - .Create(); - - // assert - // only three should exist - request.MatchSnapshot(); - } - - [Fact] - public void BuildRequest_QueryAndSetExtension_RequestIsCreated() - { - // arrange - // act - var request = - QueryRequestBuilder.New() - .SetQuery("{ foo }") - .AddExtension("one", "foo") - .SetExtension("one", "bar") - .Create(); - - // assert - // one should be bar - request.MatchSnapshot(); - } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_ToSource.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentSourceTextTests.QueryDocument_ToSource.snap similarity index 100% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_ToSource.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentSourceTextTests.QueryDocument_ToSource.snap diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_ToString.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentSourceTextTests.QueryDocument_ToString.snap similarity index 100% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_ToString.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentSourceTextTests.QueryDocument_ToString.snap diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_WriteTo.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentSourceTextTests.QuerySourceText_WriteToAsync.snap similarity index 100% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_WriteTo.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentSourceTextTests.QuerySourceText_WriteToAsync.snap diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_WriteToAsync.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentTests.QueryDocument_ToSource.snap similarity index 100% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryDocumentTests.QueryDocument_WriteToAsync.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentTests.QueryDocument_ToSource.snap diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QueryDocument_ToString.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentTests.QueryDocument_ToString.snap similarity index 100% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QueryDocument_ToString.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentTests.QueryDocument_ToString.snap diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QueryDocument_ToSource.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentTests.QueryDocument_WriteToAsync.snap similarity index 100% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QueryDocument_ToSource.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationDocumentTests.QueryDocument_WriteToAsync.snap diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_Empty_OperationRequestBuilderException.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_Empty_OperationRequestBuilderException.snap new file mode 100644 index 00000000000..861c09c37a7 --- /dev/null +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_Empty_OperationRequestBuilderException.snap @@ -0,0 +1 @@ +A GraphQL operation document or a document id is required to create a query request. diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap similarity index 96% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap index 5996867c173..f8b271359e7 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_OnlyQueryDocIsSet_RequestHasOnlyQuery.snap @@ -1,5 +1,5 @@ { - "Query": { + "Document": { "Document": { "Kind": "Document", "Location": { @@ -62,8 +62,8 @@ "FieldsCount": 1 } }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap similarity index 62% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap index 0c4611b1dcd..11979678674 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap similarity index 67% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap index 8189a5c9992..a6ed3262679 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndAddProperties_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap similarity index 70% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap index fcc3c3f1861..63adace1221 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndInitialValue_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap similarity index 62% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap index f08b7c812bf..cf9e5f5c421 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndOperation_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": "bar", "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap similarity index 62% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap index 0c4611b1dcd..11979678674 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_OnlyQueryIsSet_RequestHasOnlyQuery.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetOperation_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap similarity index 54% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap index 620bea3a35c..a6ed3262679 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap @@ -1,14 +1,15 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, "ContextData": { - "three": "baz" + "one": "foo", + "two": "bar" }, "Services": null, "Flags": "AllowAll" diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap similarity index 62% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap index 0c4611b1dcd..11979678674 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndResetVariables_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap similarity index 62% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap index da8e941d23f..26a67805655 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndServices_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap similarity index 65% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap index e556452d31f..7790c6eaa9c 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetNewProperty_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap similarity index 65% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap index f0f0939ba7f..60a9c7a9ce7 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetNewVariable_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": { "one": "bar" diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap new file mode 100644 index 00000000000..a6ed3262679 --- /dev/null +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperties_RequestIsCreated.snap @@ -0,0 +1,16 @@ +{ + "Document": { + "SourceText": "{ foo }" + }, + "DocumentId": null, + "DocumentHash": null, + "OperationName": null, + "VariableValues": null, + "Extensions": null, + "ContextData": { + "one": "foo", + "two": "bar" + }, + "Services": null, + "Flags": "AllowAll" +} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap similarity index 65% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap index e556452d31f..7790c6eaa9c 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap similarity index 65% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap index 317394cc331..9069a813d29 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsNotSet.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap similarity index 65% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap index e556452d31f..7790c6eaa9c 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetProperty_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_QueryAndTryAddProperties_PropertyIsSet.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": null, "VariableValues": null, "Extensions": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap similarity index 67% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap index 2f0056d5829..ffd043cb751 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationRequestBuilderTests.BuildRequest_SetAll_RequestIsCreated.snap @@ -1,9 +1,9 @@ { - "Query": { - "Text": "{ foo }" + "Document": { + "SourceText": "{ foo }" }, - "QueryId": null, - "QueryHash": null, + "DocumentId": null, + "DocumentHash": null, "OperationName": "bar", "VariableValues": { "two": "bar" diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryResultBuilderTests.Create_Result_Set_Data.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationResultBuilderTests.Create_Result_Set_Data.snap similarity index 82% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryResultBuilderTests.Create_Result_Set_Data.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationResultBuilderTests.Create_Result_Set_Data.snap index 961e89812b7..bfc3b0ae68b 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryResultBuilderTests.Create_Result_Set_Data.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationResultBuilderTests.Create_Result_Set_Data.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryResultBuilderTests.Create_Result_Set_Items.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationResultBuilderTests.Create_Result_Set_Items.snap similarity index 82% rename from src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryResultBuilderTests.Create_Result_Set_Items.snap rename to src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationResultBuilderTests.Create_Result_Set_Items.snap index d3e4003be27..749e7e86bf6 100644 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryResultBuilderTests.Create_Result_Set_Items.snap +++ b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/OperationResultBuilderTests.Create_Result_Set_Items.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": null, diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_Empty_QueryRequestBuilderException.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_Empty_QueryRequestBuilderException.snap deleted file mode 100644 index 132941d9ef9..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_Empty_QueryRequestBuilderException.snap +++ /dev/null @@ -1 +0,0 @@ -You must specify a query before creating a query request. diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddExtension_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddExtension_RequestIsCreated.snap deleted file mode 100644 index 76a7c10aa3a..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddExtension_RequestIsCreated.snap +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "one": "foo", - "two": "bar" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddVariables_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddVariables_RequestIsCreated.snap deleted file mode 100644 index 5c50210857f..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndAddVariables_RequestIsCreated.snap +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": { - "one": "foo", - "two": "bar" - }, - "Extensions": null, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap deleted file mode 100644 index 0c4611b1dcd..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndResetProperties_RequestIsCreated.snap +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": null, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtension_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtension_RequestIsCreated.snap deleted file mode 100644 index 8c0edb8aedc..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtension_RequestIsCreated.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "one": "bar" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_1.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_1.snap deleted file mode 100644 index e37c861998e..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_1.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "three": "baz" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_2.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_2.snap deleted file mode 100644 index e37c861998e..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_2.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "three": "baz" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_3.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_3.snap deleted file mode 100644 index 3021283e274..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_3.snap +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "three": "baz", - "four": "bar" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_4.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_4.snap deleted file mode 100644 index e37c861998e..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_4.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "three": "baz" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_5.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_5.snap deleted file mode 100644 index 3021283e274..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetExtensions_RequestIsCreated_5.snap +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "three": "baz", - "four": "bar" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariable_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariable_RequestIsCreated.snap deleted file mode 100644 index f0f0939ba7f..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariable_RequestIsCreated.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": { - "one": "bar" - }, - "Extensions": null, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariables_RequestIsCreated.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariables_RequestIsCreated.snap deleted file mode 100644 index d58030521bf..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndSetVariables_RequestIsCreated.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": { - "three": "baz" - }, - "Extensions": null, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsNotSet.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsNotSet.snap deleted file mode 100644 index 76072ef01fa..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsNotSet.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "one": "foo" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsSet.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsSet.snap deleted file mode 100644 index 8c0edb8aedc..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddExtension_ExtensionIsSet.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": null, - "Extensions": { - "one": "bar" - }, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsNotSet.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsNotSet.snap deleted file mode 100644 index 9814d8b1cb6..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsNotSet.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": { - "one": "foo" - }, - "Extensions": null, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsSet.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsSet.snap deleted file mode 100644 index f0f0939ba7f..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QueryRequestBuilderTests.BuildRequest_QueryAndTryAddVariable_VariableIsSet.snap +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Query": { - "Text": "{ foo }" - }, - "QueryId": null, - "QueryHash": null, - "OperationName": null, - "VariableValues": { - "one": "bar" - }, - "Extensions": null, - "ContextData": null, - "Services": null, - "Flags": "AllowAll" -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteTo.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteTo.snap deleted file mode 100644 index 1e07d8b20f3..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteTo.snap +++ /dev/null @@ -1,3 +0,0 @@ -{ - a -} diff --git a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteToAsync.snap b/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteToAsync.snap deleted file mode 100644 index 1e07d8b20f3..00000000000 --- a/src/HotChocolate/Core/test/Abstractions.Tests/Execution/__snapshots__/QuerySourceTextTests.QuerySourceText_WriteToAsync.snap +++ /dev/null @@ -1,3 +0,0 @@ -{ - a -} diff --git a/src/HotChocolate/Core/test/Authorization.Tests/AnnotationBasedAuthorizationTests.cs b/src/HotChocolate/Core/test/Authorization.Tests/AnnotationBasedAuthorizationTests.cs index 9d7dee948e1..06505a3b27f 100644 --- a/src/HotChocolate/Core/test/Authorization.Tests/AnnotationBasedAuthorizationTests.cs +++ b/src/HotChocolate/Core/test/Authorization.Tests/AnnotationBasedAuthorizationTests.cs @@ -412,10 +412,7 @@ public async Task Authorize_Schema_Field() options => { options.ConfigureSchemaField = - descriptor => - { - descriptor.Authorize("READ_INTRO", ApplyPolicy.Validation); - }; + descriptor => { descriptor.Authorize("READ_INTRO", ApplyPolicy.Validation); }; }); var executor = await services.GetRequestExecutorAsync(); @@ -466,10 +463,7 @@ public async Task Authorize_Type_Field() options => { options.ConfigureTypeField = - descriptor => - { - descriptor.Authorize("READ_INTRO", ApplyPolicy.Validation); - }; + descriptor => { descriptor.Authorize("READ_INTRO", ApplyPolicy.Validation); }; }); var executor = await services.GetRequestExecutorAsync(); @@ -520,10 +514,7 @@ public async Task Authorize_Node_Field() options => { options.ConfigureNodeFields = - descriptor => - { - descriptor.Authorize("READ_NODE", ApplyPolicy.Validation); - }; + descriptor => { descriptor.Authorize("READ_NODE", ApplyPolicy.Validation); }; }); var executor = await services.GetRequestExecutorAsync(); @@ -628,8 +619,8 @@ public async Task Authorize_Node_Field_Inferred_Explicit_NodeResolver() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($id: ID!) { node(id: $id) { @@ -637,8 +628,8 @@ public async Task Authorize_Node_Field_Inferred_Explicit_NodeResolver() } } """) - .SetVariableValue("id", id) - .Create()); + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()); // assert Snapshot @@ -687,8 +678,8 @@ public async Task Authorize_Node_Field_Inferred_Explicit_NodeResolver_TypePolicy // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($id: ID!) { node(id: $id) { @@ -696,8 +687,8 @@ public async Task Authorize_Node_Field_Inferred_Explicit_NodeResolver_TypePolicy } } """) - .SetVariableValue("id", id) - .Create()); + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()); // assert Snapshot @@ -744,10 +735,7 @@ public async Task Authorize_Nodes_Field() options => { options.ConfigureNodeFields = - descriptor => - { - descriptor.Authorize("READ_NODE", ApplyPolicy.Validation); - }; + descriptor => { descriptor.Authorize("READ_NODE", ApplyPolicy.Validation); }; }); var executor = await services.GetRequestExecutorAsync(); @@ -798,10 +786,7 @@ public async Task Skip_Authorize_On_Node_Field() options => { options.ConfigureNodeFields = - descriptor => - { - descriptor.Authorize("READ_NODE", ApplyPolicy.Validation); - }; + descriptor => { descriptor.Authorize("READ_NODE", ApplyPolicy.Validation); }; }); var executor = await services.GetRequestExecutorAsync(); @@ -857,10 +842,7 @@ public async Task Assert_UserState_Exists() options => { options.ConfigureNodeFields = - descriptor => - { - descriptor.Authorize("READ_NODE"); - }; + descriptor => { descriptor.Authorize("READ_NODE"); }; }); var executor = await services.GetRequestExecutorAsync(); @@ -869,7 +851,7 @@ public async Task Assert_UserState_Exists() var result = await executor.ExecuteAsync( builder => builder - .SetQuery( + .SetDocument( """ { nodes(ids: "abc") { @@ -928,7 +910,7 @@ public async Task Skip_After_Validation_For_Null() var result = await executor.ExecuteAsync( builder => builder - .SetQuery( + .SetDocument( """ { null @@ -1156,4 +1138,4 @@ public ValueTask AuthorizeAsync( CancellationToken cancellationToken = default) => new(AuthorizeResult.NotAllowed); } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/BatchQueryExecutorTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Batching/BatchQueryExecutorTests.cs deleted file mode 100644 index a586f0a4b72..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/BatchQueryExecutorTests.cs +++ /dev/null @@ -1,439 +0,0 @@ -using CookieCrumble; -using Microsoft.Extensions.DependencyInjection; -using HotChocolate.StarWars; -using HotChocolate.Tests; -using HotChocolate.Types; -using static HotChocolate.Tests.TestHelper; -using Snapshot = Snapshooter.Xunit.Snapshot; - -namespace HotChocolate.Execution.Batching; - -public class BatchQueryExecutorTests -{ - [Fact] - public async Task ExecuteExportScalar() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddStarWarsTypes() - .AddExportDirectiveType() - .Services - .AddStarWarsRepositories()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @" - query getHero { - hero(episode: EMPIRE) { - id @export - } - }") - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @" - query getHuman { - human(id: $id) { - name - } - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [LocalFact] - public async Task ExecuteExportScalarList() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddStarWarsTypes() - .AddExportDirectiveType() - .Services - .AddStarWarsRepositories()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @" - query getHero { - hero(episode: EMPIRE) { - friends { - nodes { - id @export(as: ""abc"") - } - } - } - }") - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @" - query getCharacter { - character(characterIds: $abc) { - name - } - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task ExecuteExportScalarList_ExplicitVariable() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddStarWarsTypes() - .AddExportDirectiveType() - .Services - .AddStarWarsRepositories()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @" - query getHero { - hero(episode: EMPIRE) { - friends { - nodes { - id @export(as: ""abc"") - } - } - } - }") - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @" - query getCharacter($abc: [String!]!) { - character(characterIds: $abc) { - name - } - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task ExecuteExportObject() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddStarWarsTypes() - .AddExportDirectiveType() - .AddInMemorySubscriptions() - .Services - .AddStarWarsRepositories()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @"mutation firstReview { - createReview( - episode: NEW_HOPE - review: { commentary: ""foo"", stars: 4 }) - @export(as: ""r"") { - commentary - stars - } - }") - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @" - mutation secondReview { - createReview( - episode: EMPIRE - review: $r) { - commentary - stars - } - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task ExecuteExportLeafList() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddQueryType(d => d.Name("Query") - .Field("foo") - .Argument("bar", a => a.Type>()) - .Type>() - .Resolve(ctx => - { - var list = ctx.ArgumentValue>("bar"); - - if (list is null) - { - return - [ - "123", - "456", - ]; - } - - list.Add("789"); - return list; - })) - .AddExportDirectiveType()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @"{ - foo @export(as: ""b"") - }") - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @"{ - foo(bar: $b) - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task ExecuteExportObjectList() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddDocumentFromString( - @" - type Query { - foo(f: [FooInput]) : [Foo] - } - - type Foo { - bar: String! - } - - input FooInput { - bar: String! - }") - .AddResolver("Query", "foo", ctx => - { - var list = ctx.ArgumentValue>("f"); - - if (list is null) - { - return - [ - new Dictionary - { - { "bar", "123" }, - }, - - ]; - } - - list.Add(new Dictionary - { - { "bar" , "456" }, - }); - return list; - }) - .UseField(next => context => - { - var o = context.Parent(); - if (o is Dictionary d - && d.TryGetValue(context.ResponseName, out var v)) - { - context.Result = v; - } - return next(context); - }) - .AddExportDirectiveType()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @"{ - foo @export(as: ""b"") - { - bar - } - }") - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @"{ - foo(f: $b) - { - bar - } - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task Add_Value_To_Variable_List() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddQueryType(d => d.Name("Query") - .Field("foo") - .Argument("bar", a => a.Type>()) - .Type>() - .Resolve(ctx => - { - var list = ctx.ArgumentValue>("bar"); - list.Add("789"); - return list; - })) - .AddExportDirectiveType()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @"query foo1($b: [String]) { - foo(bar: $b) @export(as: ""b"") - }") - .AddVariableValue("b", new[] { "123", }) - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @"query foo2($b: [String]) { - foo(bar: $b) - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task Convert_List_To_Single_Value_With_Converters() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddQueryType(d => - { - d.Name("Query"); - - d.Field("foo") - .Argument("bar", a => a.Type>()) - .Type>() - .Resolve(ctx => - { - var list = ctx.ArgumentValue>("bar"); - list.Add("789"); - return list; - }); - - d.Field("baz") - .Argument("bar", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("bar")); - }) - .AddExportDirectiveType()); - - // act - var batch = new List - { - QueryRequestBuilder.New() - .SetQuery( - @"query foo1($b1: [String]) { - foo(bar: $b1) @export(as: ""b2"") - }") - .AddVariableValue("b1", new[] { "123", }) - .Create(), - QueryRequestBuilder.New() - .SetQuery( - @"query foo2($b2: String) { - baz(bar: $b2) - }") - .Create(), - }; - - var batchResult = await executor.ExecuteBatchAsync(batch); - - // assert - await batchResult.MatchSnapshotAsync(); - } - - [Fact] - public async Task Batch_Is_Null() - { - // arrange - Snapshot.FullName(); - - var executor = await CreateExecutorAsync(c => c - .AddStarWarsTypes() - .AddExportDirectiveType() - .Services - .AddStarWarsRepositories()); - - // act - Task Action() => executor.ExecuteBatchAsync(null!); - - // assert - await Assert.ThrowsAsync(Action); - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/CollectVariablesVisitorTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Batching/CollectVariablesVisitorTests.cs deleted file mode 100644 index e32e0e8c63a..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/CollectVariablesVisitorTests.cs +++ /dev/null @@ -1,143 +0,0 @@ -using HotChocolate.Language; -using HotChocolate.Language.Utilities; -using HotChocolate.StarWars; -using Snapshooter.Xunit; - -namespace HotChocolate.Execution.Batching; - -public class CollectVariablesVisitorTests -{ - [Fact] - public void FindUndeclaredVariables() - { - // arrange - var schema = SchemaBuilder.New() - .AddStarWarsTypes() - .Create(); - - var document = Utf8GraphQLParser.Parse( - @" - query getHero { - hero(episode: $ep) { - name - } - }"); - - var operation = document.Definitions - .OfType() - .First(); - - var visitor = new CollectVariablesVisitor(schema); - var visitationMap = new CollectVariablesVisitationMap(); - - // act - operation.Accept( - visitor, - visitationMap, - _ => VisitorAction.Continue); - - // assert - var variables = operation.VariableDefinitions.ToList(); - variables.AddRange(visitor.VariableDeclarations); - operation = operation.WithVariableDefinitions(variables); - - new DocumentNode( - new IDefinitionNode[] - { - operation, - }).Print().MatchSnapshot(); - } - - [Fact] - public void FindUndeclaredVariablesInlineFragment() - { - // arrange - var schema = SchemaBuilder.New() - .AddStarWarsTypes() - .Create(); - - var document = Utf8GraphQLParser.Parse( - @" - query getHero { - ... on Query { - hero(episode: $ep) { - name - } - } - }"); - - var operation = document.Definitions - .OfType() - .First(); - - var visitor = new CollectVariablesVisitor(schema); - var visitationMap = new CollectVariablesVisitationMap(); - - // act - operation.Accept( - visitor, - visitationMap, - node => VisitorAction.Continue); - - // assert - var variables = operation.VariableDefinitions.ToList(); - variables.AddRange(visitor.VariableDeclarations); - operation = operation.WithVariableDefinitions(variables); - - new DocumentNode( - new IDefinitionNode[] - { - operation, - }).Print().MatchSnapshot(); - } - - [Fact] - public void FindUndeclaredVariablesFragmentDefinition() - { - // arrange - var schema = SchemaBuilder.New() - .AddStarWarsTypes() - .Create(); - - var document = Utf8GraphQLParser.Parse( - @" - query getHero { - ... q - } - - fragment q on Query { - hero(episode: $ep) { - name - } - } - "); - - var operation = document.Definitions - .OfType() - .First(); - - var visitor = new CollectVariablesVisitor(schema); - var visitationMap = new CollectVariablesVisitationMap(); - visitationMap.Initialize( - document.Definitions.OfType() - .ToDictionary(t => t.Name.Value)); - - // act - operation.Accept( - visitor, - visitationMap, - _ => VisitorAction.Continue); - - // assert - var variables = operation.VariableDefinitions.ToList(); - variables.AddRange(visitor.VariableDeclarations); - operation = operation.WithVariableDefinitions(variables); - - var definitions = new List(); - definitions.Add(operation); - definitions.AddRange( - document.Definitions.OfType()); - - new DocumentNode(definitions).Print().MatchSnapshot(); - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Add_Value_To_Variable_List.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Add_Value_To_Variable_List.snap deleted file mode 100644 index c74cbbd0b59..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Add_Value_To_Variable_List.snap +++ /dev/null @@ -1 +0,0 @@ -[{"data":{"foo":["123","789"]}},{"data":{"foo":["123","789","789"]}}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Convert_List_To_Single_Value_With_Converters.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Convert_List_To_Single_Value_With_Converters.snap deleted file mode 100644 index 01ae21e715c..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.Convert_List_To_Single_Value_With_Converters.snap +++ /dev/null @@ -1 +0,0 @@ -[{"data":{"foo":["123","789"]}},{"data":{"baz":"123,789"}}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportLeafList.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportLeafList.snap deleted file mode 100644 index 79450c0c836..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportLeafList.snap +++ /dev/null @@ -1 +0,0 @@ -[{"data":{"foo":["123","456"]}},{"data":{"foo":["123","456","789"]}}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObject.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObject.snap deleted file mode 100644 index b749eab59aa..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObject.snap +++ /dev/null @@ -1 +0,0 @@ -[{"data":{"createReview":{"commentary":"foo","stars":4}}},{"data":{"createReview":{"commentary":"foo","stars":4}}}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObjectList.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObjectList.snap deleted file mode 100644 index a3fd01fbd35..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportObjectList.snap +++ /dev/null @@ -1 +0,0 @@ -[{"data":{"foo":[{"bar":"123"}]}},{"data":{"foo":[{"bar":"123"},{"bar":"456"}]}}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalar.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalar.snap deleted file mode 100644 index 5b1ca7554cd..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalar.snap +++ /dev/null @@ -1 +0,0 @@ -[{"data":{"hero":{"id":"1000"}}},{"data":{"human":{"name":"Luke Skywalker"}}}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList.snap deleted file mode 100644 index e7ed1657700..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList.snap +++ /dev/null @@ -1,39 +0,0 @@ -[{ - "data": { - "hero": { - "friends": { - "nodes": [ - { - "id": "1002" - }, - { - "id": "1003" - }, - { - "id": "2000" - }, - { - "id": "2001" - } - ] - } - } - } -},{ - "data": { - "character": [ - { - "name": "Han Solo" - }, - { - "name": "Leia Organa" - }, - { - "name": "C-3PO" - }, - { - "name": "R2-D2" - } - ] - } -}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList_ExplicitVariable.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList_ExplicitVariable.snap deleted file mode 100644 index e7ed1657700..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/BatchQueryExecutorTests.ExecuteExportScalarList_ExplicitVariable.snap +++ /dev/null @@ -1,39 +0,0 @@ -[{ - "data": { - "hero": { - "friends": { - "nodes": [ - { - "id": "1002" - }, - { - "id": "1003" - }, - { - "id": "2000" - }, - { - "id": "2001" - } - ] - } - } - } -},{ - "data": { - "character": [ - { - "name": "Han Solo" - }, - { - "name": "Leia Organa" - }, - { - "name": "C-3PO" - }, - { - "name": "R2-D2" - } - ] - } -}] diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariables.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariables.snap deleted file mode 100644 index a89d3d65c8c..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariables.snap +++ /dev/null @@ -1,5 +0,0 @@ -query getHero($ep: Episode!) { - hero(episode: $ep) { - name - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesFragmentDefinition.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesFragmentDefinition.snap deleted file mode 100644 index b5a4602cddb..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesFragmentDefinition.snap +++ /dev/null @@ -1,9 +0,0 @@ -query getHero($ep: Episode!) { - ... q -} - -fragment q on Query { - hero(episode: $ep) { - name - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesInlineFragment.snap b/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesInlineFragment.snap deleted file mode 100644 index 48f3e0c31b3..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Batching/__snapshots__/CollectVariablesVisitorTests.FindUndeclaredVariablesInlineFragment.snap +++ /dev/null @@ -1,7 +0,0 @@ -query getHero($ep: Episode!) { - ... on Query { - hero(episode: $ep) { - name - } - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/CodeFirstTests.cs b/src/HotChocolate/Core/test/Execution.Tests/CodeFirstTests.cs index c33218e826f..3fae472ce97 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/CodeFirstTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/CodeFirstTests.cs @@ -24,7 +24,7 @@ public async Task ExecuteOneFieldQueryWithProperty() var result = await schema.MakeExecutable().ExecuteAsync("{ test }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -43,7 +43,7 @@ public async Task AllowFiveToken_Success() var result = await executor.ExecuteAsync("{ a: test }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); } [Fact] @@ -62,7 +62,7 @@ public async Task AllowFiveToken_Fail() // assert Assert.Collection( - Assert.IsType(result).Errors!, + Assert.IsType(result).Errors!, e => Assert.Equal("Document contains more than 5 tokens. Parsing aborted.", e.Message)); } @@ -81,7 +81,7 @@ public async Task AllowSixNode_Success() var result = await executor.ExecuteAsync("{ a: test }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); } [Fact] @@ -100,7 +100,7 @@ public async Task AllowSixNodes_Fail() // assert Assert.Collection( - Assert.IsType(result).Errors!, + Assert.IsType(result).Errors!, e => Assert.Equal("Document contains more than 6 nodes. Parsing aborted.", e.Message)); } @@ -117,7 +117,7 @@ public async Task ExecuteOneFieldQueryWithMethod() await schema.MakeExecutable().ExecuteAsync("{ test }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -134,7 +134,7 @@ public async Task ExecuteOneFieldQueryWithQuery() await schema.MakeExecutable().ExecuteAsync("{ query }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -158,7 +158,7 @@ ... on Foo { nameFoo } "); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -248,7 +248,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ drink { ... on Tea { kind } } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -282,7 +282,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ dog { name } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -298,7 +298,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ dog { desc } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -314,7 +314,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ dog { name2 } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -330,7 +330,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ dog { names } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); await result.MatchSnapshotAsync(); } @@ -360,9 +360,9 @@ public async Task EnsureThatFieldsWithDifferentCasingAreNotMerged() public async Task EnsureThatArgumentDefaultIsUsedWhenVariableValueIsOmitted() { var request = - QueryRequestBuilder.New() - .SetQuery("query($v: String) { foo(value: $v) }") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("query($v: String) { foo(value: $v) }") + .Build(); await new ServiceCollection() .AddGraphQL() diff --git a/src/HotChocolate/Core/test/Execution.Tests/DeferTests.cs b/src/HotChocolate/Core/test/Execution.Tests/DeferTests.cs index f1335de1516..579e72a1efa 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/DeferTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/DeferTests.cs @@ -80,7 +80,7 @@ ... @defer(if: false) { } }"); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } [Fact] @@ -91,9 +91,9 @@ public async Task InlineFragment_Defer_If_Variable_Set_To_false() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery( + OperationRequestBuilder + .Create() + .SetDocument( @"query($defer: Boolean!) { ... @defer(if: $defer) { person(id: ""UGVyc29uOjE="") { @@ -101,10 +101,10 @@ ... @defer(if: $defer) { } } }") - .SetVariableValue("defer", false) - .Create()); + .SetVariableValues(new Dictionary { {"defer", false }, }) + .Build()); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } [Fact] @@ -193,7 +193,7 @@ fragment Foo on Query { } }"); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } [Fact] @@ -204,9 +204,9 @@ public async Task FragmentSpread_Defer_If_Variable_Set_To_false() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery( + OperationRequestBuilder + .Create() + .SetDocument( @"query ($defer: Boolean!) { ... Foo @defer(if: $defer) } @@ -216,9 +216,9 @@ fragment Foo on Query { id } }") - .SetVariableValue("defer", false) - .Create()); + .SetVariableValues(new Dictionary { {"defer", false }, }) + .Build()); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } } diff --git a/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_Validation.Tests.cs b/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_Validation.Tests.cs index 1054ccd9d42..bbab33bc6fe 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_Validation.Tests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_Validation.Tests.cs @@ -79,10 +79,10 @@ public async Task AddIntrospectionAllowedRule_IntegrationTest_NotAllowed() .AddQueryType(d => d.Name("Query").Field("foo").Resolve("bar")) .AddIntrospectionAllowedRule() .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") - .Create()) + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") + .Build()) .MatchSnapshotAsync(); } @@ -96,10 +96,10 @@ public async Task AllowIntrospection_IntegrationTest_NotAllowed() .AddQueryType(d => d.Name("Query").Field("foo").Resolve("bar")) .AllowIntrospection(false) .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") - .Create()) + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") + .Build()) .MatchSnapshotAsync(); } @@ -113,10 +113,10 @@ public async Task AllowIntrospection_IntegrationTest_Allowed() .AddQueryType(d => d.Name("Query").Field("foo").Resolve("bar")) .AllowIntrospection(true) .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") - .Create()) + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") + .Build()) .MatchSnapshotAsync(); } @@ -130,11 +130,11 @@ public async Task AllowIntrospection_IntegrationTest_NotAllowed_CustomMessage() .AddQueryType(d => d.Name("Query").Field("foo").Resolve("bar")) .AllowIntrospection(false) .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") .SetIntrospectionNotAllowedMessage("Bar") - .Create()) + .Build()) .MatchSnapshotAsync(); } @@ -148,11 +148,11 @@ public async Task AddIntrospectionAllowedRule_IntegrationTest_NotAllowed_CustomM .AddQueryType(d => d.Name("Query").Field("foo").Resolve("bar")) .AddIntrospectionAllowedRule() .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") .SetIntrospectionNotAllowedMessage(() => "Bar") - .Create()) + .Build()) .MatchSnapshotAsync(); } @@ -166,11 +166,11 @@ public async Task AddIntrospectionAllowedRule_IntegrationTest_NotAllowed_CustomM .AddQueryType(d => d.Name("Query").Field("foo").Resolve("bar")) .AddIntrospectionAllowedRule() .ExecuteRequestAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") .SetIntrospectionNotAllowedMessage("Baz") - .Create()) + .Build()) .MatchSnapshotAsync(); } @@ -190,19 +190,19 @@ public async Task AddIntrospectionAllowedRule_IntegrationTest_Allowed() var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") .AllowIntrospection() - .Create()); + .Build()); results.Add(result.ToJson()); result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ __schema { description } }") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ __schema { description } }") + .Build()); results.Add(result.ToJson()); results.MatchSnapshot(); @@ -228,4 +228,4 @@ public void Validate(IDocumentValidatorContext context, DocumentNode document) throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/DependencyInjectionTests.cs b/src/HotChocolate/Core/test/Execution.Tests/DependencyInjectionTests.cs index e81fbcee78c..48765a2e3d3 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/DependencyInjectionTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/DependencyInjectionTests.cs @@ -52,11 +52,11 @@ public async Task Extension_With_Scoped_Constructor_Injection() { result[0] = await executor .ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ hello }") + OperationRequestBuilder + .Create() + .SetDocument("{ hello }") .SetServices(scope.ServiceProvider) - .Create()) + .Build()) .ToJsonAsync(); } @@ -64,11 +64,11 @@ public async Task Extension_With_Scoped_Constructor_Injection() { result[1] = await executor .ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ hello }") + OperationRequestBuilder + .Create() + .SetDocument("{ hello }") .SetServices(scope.ServiceProvider) - .Create()) + .Build()) .ToJsonAsync(); } @@ -118,11 +118,11 @@ public async Task Type_With_Scoped_Constructor_Injection() { result[0] = await executor .ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ hello }") + OperationRequestBuilder + .Create() + .SetDocument("{ hello }") .SetServices(scope.ServiceProvider) - .Create()) + .Build()) .ToJsonAsync(); } @@ -130,11 +130,11 @@ public async Task Type_With_Scoped_Constructor_Injection() { result[1] = await executor .ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ hello }") + OperationRequestBuilder + .Create() + .SetDocument("{ hello }") .SetServices(scope.ServiceProvider) - .Create()) + .Build()) .ToJsonAsync(); } @@ -161,11 +161,11 @@ public async Task Keyed_Services_Do_Not_Throw() await executor .ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ hello }") + OperationRequestBuilder + .Create() + .SetDocument("{ hello }") .SetServices(scope.ServiceProvider) - .Create()) + .Build()) .ToJsonAsync() .MatchSnapshotAsync(); } diff --git a/src/HotChocolate/Core/test/Execution.Tests/Errors/ErrorBehaviorTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Errors/ErrorBehaviorTests.cs index 2a85650d4b3..5cb1708805a 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Errors/ErrorBehaviorTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Errors/ErrorBehaviorTests.cs @@ -210,7 +210,7 @@ public class Query { public Task Error1() { - throw new QueryException("query error 1"); + throw new GraphQLException("query error 1"); } public Task Error2() @@ -229,7 +229,7 @@ public class Query public async Task Error4() { await Task.Delay(1); - throw new QueryException("query error 4"); + throw new GraphQLException("query error 4"); } public async Task Error5() @@ -249,7 +249,7 @@ public class Query public string? Error7() { - throw new QueryException("query error 7"); + throw new GraphQLException("query error 7"); } public string? Error8() @@ -264,7 +264,7 @@ public class Query .Build(); } - public string? Error10 => throw new QueryException("query error 10"); + public string? Error10 => throw new GraphQLException("query error 10"); public string? Error11 => throw new Exception("query error 11"); diff --git a/src/HotChocolate/Core/test/Execution.Tests/Errors/NullErrorPropagationTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Errors/NullErrorPropagationTests.cs index e16ac6814ae..aa53616e8dc 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Errors/NullErrorPropagationTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Errors/NullErrorPropagationTests.cs @@ -9,12 +9,12 @@ public async Task Lists_NullableElementIsNull() { // arrange using var snapshot = SnapshotHelpers.StartResultSnapshot(); - + var executor = await CreateExecutorAsync(); var request = - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ { foo { @@ -43,7 +43,7 @@ public async Task Lists_NullableElementIsNull() """) .AddGlobalState("a", null) .AddGlobalState("b", "not_null") - .Create(); + .Build(); // act var result = await executor.ExecuteAsync(request); @@ -61,14 +61,14 @@ public async Task List_NonNullElementIsNull(string fieldType) { // arrange using var snapshot = SnapshotHelpers.StartResultSnapshot(fieldType); - + var executor = await CreateExecutorAsync(); var request = - QueryRequestBuilder.New() - .SetQuery($"{{ foo {{ {fieldType} {{ b }} }} }}") + OperationRequestBuilder.Create() + .SetDocument($"{{ foo {{ {fieldType} {{ b }} }} }}") .AddGlobalState("b", null) - .Create(); + .Build(); // act var result = await executor.ExecuteAsync(request); @@ -86,14 +86,14 @@ public async Task List_NonNullElementHasError(string fieldType) { // arrange using var snapshot = SnapshotHelpers.StartResultSnapshot(fieldType); - + var executor = await CreateExecutorAsync(); var request = - QueryRequestBuilder.New() - .SetQuery($"{{ foo {{ {fieldType} {{ c }} }} }}") + OperationRequestBuilder.Create() + .SetDocument($"{{ foo {{ {fieldType} {{ c }} }} }}") .AddGlobalState("b", null) - .Create(); + .Build(); // act var result = await executor.ExecuteAsync(request); @@ -109,14 +109,14 @@ public async Task Object_NonNullElementIsNull(string fieldType) { // arrange using var snapshot = SnapshotHelpers.StartResultSnapshot(fieldType); - + var executor = await CreateExecutorAsync(); var request = - QueryRequestBuilder.New() - .SetQuery($"{{ foo {{ {fieldType} {{ b }} }} }}") + OperationRequestBuilder.Create() + .SetDocument($"{{ foo {{ {fieldType} {{ b }} }} }}") .AddGlobalState("b", null) - .Create(); + .Build(); // act var result = await executor.ExecuteAsync(request); @@ -132,14 +132,14 @@ public async Task Object_NonNullElementHasError(string fieldType) { // arrange using var snapshot = SnapshotHelpers.StartResultSnapshot(fieldType); - + var executor = await CreateExecutorAsync(); var request = - QueryRequestBuilder.New() - .SetQuery($"{{ foo {{ {fieldType} {{ c }} }} }}") + OperationRequestBuilder.Create() + .SetDocument($"{{ foo {{ {fieldType} {{ c }} }} }}") .AddGlobalState("b", null) - .Create(); + .Build(); // act var result = await executor.ExecuteAsync(request); @@ -150,12 +150,12 @@ public async Task Object_NonNullElementHasError(string fieldType) private static async Task CreateExecutorAsync() { - const string schema = + const string schema = """ type Query { foo: Foo } - + type Foo { nullable_list_nullable_element: [Bar] nonnull_list_nullable_element: [Bar]! @@ -164,7 +164,7 @@ type Foo { nonnull_prop: Bar! nullable_prop: Bar } - + type Bar { a: String b: String! @@ -187,4 +187,4 @@ type Bar { .AddResolver("Bar", "c", _ => throw new GraphQLException("ERROR")) .BuildRequestExecutorAsync(); } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/HotChocolate.Execution.Tests.csproj b/src/HotChocolate/Core/test/Execution.Tests/HotChocolate.Execution.Tests.csproj index bc27600a1db..1e0c41768fe 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/HotChocolate.Execution.Tests.csproj +++ b/src/HotChocolate/Core/test/Execution.Tests/HotChocolate.Execution.Tests.csproj @@ -14,6 +14,18 @@ + + + + + + + + + + + + Always @@ -26,4 +38,8 @@ + + + + diff --git a/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/ApolloTracingTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/ApolloTracingTests.cs deleted file mode 100644 index 6a3280a84bf..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/ApolloTracingTests.cs +++ /dev/null @@ -1,114 +0,0 @@ -using HotChocolate.Execution.Options; -using Microsoft.Extensions.DependencyInjection; -using Snapshooter.Xunit; -using static HotChocolate.Tests.TestHelper; - -namespace HotChocolate.Execution.Instrumentation; - -public class DiagnosticsEventsTests -{ - [Fact] - public async Task ApolloTracing_Always() - { - // arrange - var executor = await CreateExecutorAsync(c => c - .AddDocumentFromString( - @" - type Query { - a: String - }") - .AddResolver("Query", "a", () => "hello world a") - .AddApolloTracing(TracingPreference.Always, new TestTimestampProvider())); - - // act - var result = await executor.ExecuteAsync("{ a }"); - - // assert - result.ToJson().MatchSnapshot(); - } - - [Fact] - public async Task ApolloTracing_Always_Parsing_And_Validation_Is_Cached() - { - // arrange - var executor = await CreateExecutorAsync(c => c - .AddDocumentFromString( - @" - type Query { - a: String - }") - .AddResolver("Query", "a", () => "hello world a") - .AddApolloTracing(TracingPreference.Always, new TestTimestampProvider())); - - // act - await executor.ExecuteAsync("{ a }"); - - // the second execution will not parse or validate since these steps are cached. - var result = await executor.ExecuteAsync("{ a }"); - - // assert - result.ToJson().MatchSnapshot(); - } - - [Fact] - public async Task ApolloTracing_OnDemand_NoHeader() - { - // arrange - var executor = await CreateExecutorAsync(c => c - .AddDocumentFromString( - @" - type Query { - a: String - }") - .AddResolver("Query", "a", () => "hello world a") - .AddApolloTracing(TracingPreference.OnDemand, new TestTimestampProvider())); - - // act - var result = await executor.ExecuteAsync("{ a }"); - - // assert - result.ToJson().MatchSnapshot(); - } - - [Fact] - public async Task ApolloTracing_OnDemand_WithHeader() - { - // arrange - var executor = await CreateExecutorAsync(c => c - .AddDocumentFromString( - @" - type Query { - a: String - }") - .AddResolver("Query", "a", () => "hello world a") - .AddApolloTracing(TracingPreference.OnDemand, new TestTimestampProvider())); - - // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetGlobalState(WellKnownContextData.EnableTracing, true) - .Create()); - - // assert - result.ToJson().MatchSnapshot(); - } - - private sealed class TestTimestampProvider : ITimestampProvider - { - private DateTime _utcNow = new DateTime(2010, 10, 10, 12, 00, 00); - private long _nowInNanoseconds = 10; - - public DateTime UtcNow() - { - var time = _utcNow; - _utcNow = _utcNow.AddMilliseconds(50); - return time; - } - - public long NowInNanoseconds() - { - return _nowInNanoseconds += 20; - } - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/DiagnosticListenerTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/DiagnosticListenerTests.cs index 9209c9fd443..0d9c9ec310b 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/DiagnosticListenerTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Instrumentation/DiagnosticListenerTests.cs @@ -23,7 +23,7 @@ public async Task Intercept_Resolver_Result_With_Listener() var result = await executor.ExecuteAsync("{ hero { name } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); Assert.Collection(listener.Results, r => Assert.IsType(r)); } @@ -63,7 +63,7 @@ public async Task Intercept_Resolver_Result_With_Multiple_Listener() var result = await executor.ExecuteAsync("{ hero { name } }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); Assert.Collection(listenerA.Results, r => Assert.IsType(r)); Assert.Collection(listenerB.Results, r => Assert.IsType(r)); } diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/Cancellation/CancellationTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/Cancellation/CancellationTests.cs index f3b049b7802..1526ffb9775 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/Cancellation/CancellationTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/Cancellation/CancellationTests.cs @@ -24,9 +24,9 @@ public async Task Serial_Ensure_Execution_Waits_For_Tasks() // act await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ task1 task2 }") - .Create(), + OperationRequestBuilder.Create() + .SetDocument("{ task1 task2 }") + .Build(), cts.Token); // assert @@ -131,7 +131,7 @@ public async Task GetTask2() return "bar"; } } - + protected static async Task TryTest(Func action) { // we will try four times .... diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/Components/VariableCoercionIntegrationTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/Components/VariableCoercionIntegrationTests.cs index d5b3f4bcc86..3602c29fcc1 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/Components/VariableCoercionIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/Components/VariableCoercionIntegrationTests.cs @@ -20,11 +20,11 @@ public async Task Nullables_And_NonNullables_Are_Set() new ObjectFieldNode("surname", "Smith")); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", user) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", user }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -40,11 +40,11 @@ public async Task Nullables_Are_Not_Set_NonNullables_Are_Set() new ObjectFieldNode("name", "Oliver")); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", user) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", user }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -61,11 +61,11 @@ public async Task Nullables_Are_Set_And_NonNullables_Are_Set_To_Null() new ObjectFieldNode("surname", "Smith")); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", user) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", user }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -81,11 +81,11 @@ public async Task Nullables_Are_Set_And_NonNullables_Not_Are_Set() new ObjectFieldNode("surname", "Smith")); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", user) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", user }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -100,11 +100,11 @@ public async Task Empty_Object() var user = new ObjectValueNode(); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", user) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", user }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -117,11 +117,11 @@ public async Task Variable_Null() var executor = await CreateSchemaAsync(); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", null) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", null }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -134,10 +134,10 @@ public async Task Variable_Not_Provided() var executor = await CreateSchemaAsync(); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -155,11 +155,11 @@ public async Task Invalid_Field_Provided() new ObjectFieldNode("foo", "bar")); var request = - QueryRequestBuilder - .New() - .SetQuery("mutation($user: UserInput!) { addUser(user: $user) }") - .SetVariableValue("user", user) - .Create(); + OperationRequestBuilder + .Create() + .SetDocument("mutation($user: UserInput!) { addUser(user: $user) }") + .SetVariableValues(new Dictionary { {"user", user }, }) + .Build(); await executor.ExecuteAsync(request).MatchSnapshotAsync(); } @@ -213,4 +213,4 @@ protected override void Configure(IInputObjectTypeDescriptor descriptor) .Description("User's surname"); } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs index e2fa17b6a26..135b27bbb8d 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs @@ -184,10 +184,10 @@ public async Task ClassDataLoader() .GetRequiredService() .GetDataLoader(_ => throw new Exception()); - context.Result = QueryResultBuilder - .FromResult((IQueryResult)context.Result!) + context.Result = OperationResultBuilder + .FromResult((IOperationResult)context.Result!) .AddExtension("loads", dataLoader.Loads) - .Create(); + .Build(); }) .UseDefaultPipeline()); @@ -195,8 +195,8 @@ public async Task ClassDataLoader() snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ a: withDataLoader(key: ""a"") b: withDataLoader(key: ""b"") @@ -204,28 +204,28 @@ await executor.ExecuteAsync( c: withDataLoader(key: ""c"") } }") - .Create())); + .Build())); snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ a: withDataLoader(key: ""a"") }") - .Create())); + .Build())); snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ c: withDataLoader(key: ""c"") }") - .Create())); + .Build())); // assert snapshot.MatchMarkdown(); } - + [Fact] public async Task ClassDataLoader_Out_Off_GraphQL_Context_Not_Initialized() { @@ -245,10 +245,10 @@ public async Task ClassDataLoader_Out_Off_GraphQL_Context_Not_Initialized() .GetRequiredService() .GetDataLoader(_ => throw new Exception()); - context.Result = QueryResultBuilder - .FromResult((IQueryResult)context.Result!) + context.Result = OperationResultBuilder + .FromResult((IOperationResult)context.Result!) .AddExtension("loads", dataLoader.Loads) - .Create(); + .Build(); }) .UseDefaultPipeline() .Services @@ -260,7 +260,7 @@ public async Task ClassDataLoader_Out_Off_GraphQL_Context_Not_Initialized() var result = await dataLoader.LoadAsync("a"); Assert.Equal("a", result); } - + [Fact] public async Task ClassDataLoader_Out_Off_GraphQL_Context() { @@ -280,10 +280,10 @@ public async Task ClassDataLoader_Out_Off_GraphQL_Context() .GetRequiredService() .GetDataLoader(_ => throw new Exception()); - context.Result = QueryResultBuilder - .FromResult((IQueryResult)context.Result!) + context.Result = OperationResultBuilder + .FromResult((IOperationResult)context.Result!) .AddExtension("loads", dataLoader.Loads) - .Create(); + .Build(); }) .UseDefaultPipeline() .Services @@ -298,7 +298,7 @@ public async Task ClassDataLoader_Out_Off_GraphQL_Context() var result = await dataLoader.LoadAsync("a"); Assert.Equal("a", result); } - + [Fact] public async Task ClassDataLoader_Out_Off_GraphQL_Context_Just_Works() { @@ -318,10 +318,10 @@ public async Task ClassDataLoader_Out_Off_GraphQL_Context_Just_Works() .GetRequiredService() .GetDataLoader(_ => throw new Exception()); - context.Result = QueryResultBuilder - .FromResult((IQueryResult)context.Result!) + context.Result = OperationResultBuilder + .FromResult((IOperationResult)context.Result!) .AddExtension("loads", dataLoader.Loads) - .Create(); + .Build(); }) .UseDefaultPipeline() .Services @@ -349,31 +349,31 @@ public async Task StackedDataLoader() // act snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ a: withStackedDataLoader(key: ""a"") b: withStackedDataLoader(key: ""b"") }") - .Create())); + .Build())); snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ a: withStackedDataLoader(key: ""a"") }") - .Create())); + .Build())); snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ c: withStackedDataLoader(key: ""c"") }") - .Create())); + .Build())); // assert snapshot.MatchMarkdown(); @@ -397,41 +397,41 @@ public async Task ClassDataLoader_Resolve_From_DependencyInjection() var dataLoader = (TestDataLoader)context.Services.GetRequiredService(); - context.Result = QueryResultBuilder - .FromResult(((IQueryResult)context.Result!)) + context.Result = OperationResultBuilder + .FromResult(((IOperationResult)context.Result!)) .AddExtension("loads", dataLoader.Loads) - .Create(); + .Build(); }) .UseDefaultPipeline()); // act snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ a: dataLoaderWithInterface(key: ""a"") b: dataLoaderWithInterface(key: ""b"") }") - .Create())); + .Build())); snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ a: dataLoaderWithInterface(key: ""a"") }") - .Create())); + .Build())); snapshot.Add( await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ c: dataLoaderWithInterface(key: ""c"") }") - .Create())); + .Build())); // assert snapshot.MatchMarkdown(); @@ -686,4 +686,4 @@ public CounterDataLoader(DataLoaderOptions options) : base(options) protected override Task LoadSingleAsync(string key, CancellationToken cancellationToken) => Task.FromResult(key + Counter); } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/UseDataLoaderTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/UseDataLoaderTests.cs index b498355e048..30b67ddd442 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/UseDataLoaderTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/UseDataLoaderTests.cs @@ -162,7 +162,7 @@ public async Task UseDataLoader_Schema_BatchDataloader_Single_Execute() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.Create(@"{ single { id }}")); + OperationRequest.FromSourceText("{ single { id }}")); // assert result.ToJson().MatchSnapshot(); @@ -182,7 +182,7 @@ public async Task UseDataLoader_Schema_BatchDataloader_Multiple_Execute() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.Create(@"{ multiple { id }}")); + OperationRequest.FromSourceText("{ multiple { id }}")); // assert result.ToJson().MatchSnapshot(); @@ -202,7 +202,7 @@ public async Task UseDataLoader_Schema_GroupedDataloader_Single_Execute() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.Create(@"{ single { id }}")); + OperationRequest.FromSourceText("{ single { id }}")); // assert result.ToJson().MatchSnapshot(); @@ -222,7 +222,7 @@ public async Task UseDataLoader_Schema_GroupedDataloader_Multiple_Execute() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.Create(@"{ multiple { id }}")); + OperationRequest.FromSourceText("{ multiple { id }}")); // assert result.ToJson().MatchSnapshot(); @@ -297,4 +297,4 @@ public Foo(int id) public int Id { get; } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/InputObjectsCanBeVariablesTest.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/InputObjectsCanBeVariablesTest.cs index b6a8d379970..e0febe4b437 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/InputObjectsCanBeVariablesTest.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/InputObjectsCanBeVariablesTest.cs @@ -14,27 +14,25 @@ public async Task EnsureInputObjectsCanBeVariablesTest() Snapshot.FullName(); await ExpectValid( - @" - query ($a: String $b: String) { - anything(foo: { - a: $a - b: $b - }) { - a - b - } + """ + query ($a: String $b: String) { + anything(foo: { + a: $a + b: $b + }) { + a + b } - ", + } + """, r => r.AddQueryType(), - r => r.SetVariableValue( - "a", - "a" - ) - .SetVariableValue( - "b", - "b" - ) - ).MatchSnapshotAsync(); + r => r.SetVariableValues( + new Dictionary + { + { "a", "a" }, + { "b", "b" }, + })) + .MatchSnapshotAsync(); } [Fact] @@ -43,23 +41,20 @@ public async Task EnsureInputObjectsCanBeVariablesAndLiteralsTest() Snapshot.FullName(); await ExpectValid( - @" - query ($a: String) { - anything(foo: { - a: $a - b: ""b"" - }) { - a - b - } - } - ", + """ + query ($a: String) { + anything(foo: { + a: $a + b: "b" + }) { + a + b + } + } + """, r => r.AddQueryType(), - r => r.SetVariableValue( - "a", - "a" - ) - ).MatchSnapshotAsync(); + r => r.SetVariableValues(new Dictionary { { "a", "a" }, })) + .MatchSnapshotAsync(); } [Fact] @@ -97,4 +92,4 @@ public class Foo public string A { get; set; } public string B { get; set; } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/ListTypeTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/ListTypeTests.cs index bc5e1a90ae2..06fa1951bd4 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/ListTypeTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/ListTypeTests.cs @@ -14,15 +14,13 @@ public async Task Ensure_List_Elements_Can_Be_Variables() Snapshot.FullName(); await ExpectValid( - @" + """ query ($a: String $b: String) { list(items: [$a $b]) - }", - b => b - .AddQueryType(), - r => r - .SetVariableValue("a", "a") - .SetVariableValue("b", "b")) + } + """, + b => b.AddQueryType(), + r => r.SetVariableValues(new Dictionary { {"a", "a" }, {"b", "b" }, })) .MatchSnapshotAsync(); } @@ -30,4 +28,4 @@ public class Query { public List GetList(List items) => items; } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/StarWarsCodeFirst/StarWarsCodeFirstTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/StarWarsCodeFirst/StarWarsCodeFirstTests.cs index aee8d44f7c3..64ccf54f2dc 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/StarWarsCodeFirst/StarWarsCodeFirstTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/StarWarsCodeFirst/StarWarsCodeFirstTests.cs @@ -174,7 +174,8 @@ query HeroNameAndFriends($episode: Episode) { } } }", - request: c => c.SetVariableValue("episode", new EnumValueNode("JEDI"))) + request: c => c.SetVariableValues( + new Dictionary { { "episode", new EnumValueNode("JEDI") }, })) .MatchSnapshotAsync(); } @@ -213,9 +214,12 @@ friends @include(if: $withFriends) { } } }", - request: c => c - .SetVariableValue("episode", new EnumValueNode("JEDI")) - .SetVariableValue("withFriends", new BooleanValueNode(false))) + request: c => c.SetVariableValues( + new Dictionary + { + { "episode", new EnumValueNode("JEDI") }, + { "withFriends", new BooleanValueNode(false) }, + })) .MatchSnapshotAsync(); } @@ -235,9 +239,12 @@ friends @include(if: $withFriends) { } } }", - request: r => r - .SetVariableValue("episode", new EnumValueNode("JEDI")) - .SetVariableValue("withFriends", new BooleanValueNode(true))) + request: r => r.SetVariableValues( + new Dictionary + { + { "episode", new EnumValueNode("JEDI") }, + { "withFriends", new BooleanValueNode(true) }, + })) .MatchSnapshotAsync(); } @@ -257,9 +264,12 @@ friends @skip(if: $withFriends) { } } }", - request: r => r - .SetVariableValue("episode", new EnumValueNode("JEDI")) - .SetVariableValue("withFriends", new BooleanValueNode(false))) + request: r => r.SetVariableValues( + new Dictionary + { + { "episode", new EnumValueNode("JEDI") }, + { "withFriends", new BooleanValueNode(false) }, + })) .MatchSnapshotAsync(); } @@ -279,9 +289,12 @@ friends @skip(if: $withFriends) { } } }", - request: r => r - .SetVariableValue("episode", new EnumValueNode("JEDI")) - .SetVariableValue("withFriends", new BooleanValueNode(true))) + request: r => r.SetVariableValues( + new Dictionary + { + { "episode", new EnumValueNode("JEDI") }, + { "withFriends", new BooleanValueNode(true) }, + })) .MatchSnapshotAsync(); } @@ -301,9 +314,12 @@ friends @skip(if: $withFriends) { } } }", - request: r => r - .SetVariableValue("episode", "JEDI") - .SetVariableValue("withFriends", false)) + request: r => r.SetVariableValues( + new Dictionary + { + { "episode", new EnumValueNode("JEDI") }, + { "withFriends", new BooleanValueNode(false) }, + })) .MatchSnapshotAsync(); } @@ -321,14 +337,19 @@ mutation CreateReviewForEpisode( } }", request: r => r - .SetVariableValue("ep", new EnumValueNode("JEDI")) - .SetVariableValue( - "review", - new ObjectValueNode( - new ObjectFieldNode("stars", new IntValueNode(5)), - new ObjectFieldNode( - "commentary", - new StringValueNode("This is a great movie!"))))) + .SetVariableValues( + new Dictionary + { + { "ep", new EnumValueNode("JEDI") }, + { + "review", + new ObjectValueNode( + new ObjectFieldNode("stars", new IntValueNode(5)), + new ObjectFieldNode( + "commentary", + new StringValueNode("This is a great movie!"))) + }, + })) .MatchSnapshotAsync(); } @@ -347,26 +368,27 @@ mutation CreateReviewForEpisode( }", configure: c => { - c.AddInputParser(options => - { - options.IgnoreAdditionalInputFields = true; - }); + c.AddInputParser(options => { options.IgnoreAdditionalInputFields = true; }); AddDefaultConfiguration(c); }, request: r => r - .SetVariableValue("ep", new EnumValueNode("JEDI")) - .SetVariableValue( - "review", - new ObjectValueNode( - // Invalid fields - new ObjectFieldNode("foo", new IntValueNode(1)), - new ObjectFieldNode("ignoreMe", new StringValueNode("ignored")), - // Valid fields - new ObjectFieldNode("stars", new IntValueNode(5)), - new ObjectFieldNode( - "commentary", - new StringValueNode("This is a great movie!")))) - ) + .SetVariableValues( + new Dictionary + { + { "ep", new EnumValueNode("JEDI") }, + { + "review", + new ObjectValueNode( + // Invalid fields + new ObjectFieldNode("foo", new IntValueNode(1)), + new ObjectFieldNode("ignoreMe", new StringValueNode("ignored")), + // Valid fields + new ObjectFieldNode("stars", new IntValueNode(5)), + new ObjectFieldNode( + "commentary", + new StringValueNode("This is a great movie!"))) + }, + })) .MatchSnapshotAsync(); } @@ -388,15 +410,20 @@ mutation CreateReviewForEpisode( } }", request: r => r - .SetVariableValue("ep", new EnumValueNode("JEDI")) - .SetVariableValue("ep2", new EnumValueNode("JEDI")) - .SetVariableValue( - "review", - new ObjectValueNode( - new ObjectFieldNode("stars", new IntValueNode(5)), - new ObjectFieldNode( - "commentary", - new StringValueNode("This is a great movie!"))))) + .SetVariableValues( + new Dictionary + { + { "ep", new EnumValueNode("JEDI") }, + { "ep2", new EnumValueNode("JEDI") }, + { + "review", + new ObjectValueNode( + new ObjectFieldNode("stars", new IntValueNode(5)), + new ObjectFieldNode( + "commentary", + new StringValueNode("This is a great movie!"))) + }, + })) .MatchSnapshotAsync(); } @@ -405,7 +432,7 @@ public async Task GraphQLOrgMutationExample_With_ValueVariables() { Snapshot.FullName(); await ExpectValid( - @" + """ mutation CreateReviewForEpisode( $ep: Episode! $stars: Int! @@ -416,11 +443,16 @@ mutation CreateReviewForEpisode( stars commentary } - }", + } + """, request: r => r - .SetVariableValue("ep", new EnumValueNode("JEDI")) - .SetVariableValue("stars", new IntValueNode(5)) - .SetVariableValue("commentary", new StringValueNode("This is a great movie!"))) + .SetVariableValues( + new Dictionary + { + { "ep", new EnumValueNode("JEDI") }, + { "stars", new IntValueNode(5) }, + { "commentary", new StringValueNode("This is a great movie!") }, + })) .MatchSnapshotAsync(); } @@ -429,7 +461,7 @@ public async Task GraphQLOrgInlineFragmentExample1() { Snapshot.FullName(); await ExpectValid( - @" + """ query HeroForEpisode($ep: Episode!) { hero(episode: $ep) { name @@ -440,8 +472,10 @@ ... on Human { height } } - }", - request: r => r.SetVariableValue("ep", new EnumValueNode("JEDI"))) + } + """, + request: r => r.SetVariableValues( + new Dictionary { { "ep", new EnumValueNode("JEDI") }, })) .MatchSnapshotAsync(); } @@ -450,7 +484,7 @@ public async Task GraphQLOrgInlineFragmentExample2() { Snapshot.FullName(); await ExpectValid( - @" + """ query HeroForEpisode($ep: Episode!) { hero(episode: $ep) { name @@ -461,8 +495,10 @@ ... on Human { height } } - }", - request: r => r.SetVariableValue("ep", new EnumValueNode("EMPIRE"))) + } + """, + request: r => r.SetVariableValues( + new Dictionary { { "ep", new EnumValueNode("EMPIRE") }, })) .MatchSnapshotAsync(); } @@ -471,9 +507,9 @@ public async Task GraphQLOrgMetaFieldAndUnionExample() { Snapshot.FullName(); await ExpectValid( - @" + """ { - search(text: ""an"") { + search(text: "an") { __typename ... on Human { name @@ -488,7 +524,8 @@ ... on Starship { length } } - }") + } + """) .MatchSnapshotAsync(); } @@ -497,15 +534,19 @@ public async Task NonNullListVariableValues() { Snapshot.FullName(); await ExpectValid( - @" + """ query op($ep: [Episode!]!) { heroes(episodes: $ep) { name } - }", - request: r => r - .SetVariableValue("ep", new ListValueNode(new EnumValueNode("EMPIRE")))) + } + """, + request: r => r.SetVariableValues( + new Dictionary + { + { "ep", new ListValueNode(new EnumValueNode("EMPIRE")) }, + })) .MatchSnapshotAsync(); } @@ -514,7 +555,7 @@ public async Task ConditionalInlineFragment() { Snapshot.FullName(); await ExpectValid( - @" + """ { heroes(episodes: [EMPIRE]) { name @@ -522,7 +563,8 @@ ... @include(if: true) { height } } - }") + } + """) .MatchSnapshotAsync(); } @@ -531,13 +573,14 @@ public async Task NonNullEnumsSerializeCorrectlyFromVariables() { Snapshot.FullName(); await ExpectValid( - @" + """ query getHero($episode: Episode!) { hero(episode: $episode) { name } - }", - request: r => r.SetVariableValue("episode", "NEW_HOPE")) + } + """, + request: r => r.SetVariableValues(new Dictionary { { "episode", "NEW_HOPE" }, })) .MatchSnapshotAsync(); } @@ -546,12 +589,13 @@ public async Task EnumValueIsCoercedToListValue() { Snapshot.FullName(); await ExpectValid( - @" + """ { heroes(episodes: EMPIRE) { name } - }") + } + """) .MatchSnapshotAsync(); } @@ -560,7 +604,7 @@ public async Task TypeNameFieldIsCorrectlyExecutedOnInterfaces() { Snapshot.FullName(); await ExpectValid( - @" + """ query foo { hero(episode: NEW_HOPE) { __typename @@ -588,7 +632,8 @@ ... on Droid { } } } - }") + } + """) .MatchSnapshotAsync(); } @@ -597,16 +642,17 @@ public async Task Execute_ListWithNullValues_ResultContainsNullElement() { Snapshot.FullName(); await ExpectValid( - @" + """ query { - human(id: ""1001"") { + human(id: "1001") { id name otherHuman { name } } - }") + } + """) .MatchSnapshotAsync(); } @@ -619,23 +665,29 @@ public async Task SubscribeToReview() // act var subscriptionResult = (IResponseStream)await executor.ExecuteAsync( - "subscription { onReview(episode: NEW_HOPE) " + - "{ stars } }"); + """ + subscription { + onReview(episode: NEW_HOPE) { + stars + } + } + """); var results = subscriptionResult.ReadResultsAsync(); // assert await executor.ExecuteAsync( - @" - mutation { - createReview(episode: NEW_HOPE, - review: { stars: 5 commentary: ""foo"" }) { - stars - commentary - } - }"); + """ + mutation { + createReview(episode: NEW_HOPE, + review: { stars: 5 commentary: "foo" }) { + stars + commentary + } + } + """); - IQueryResult eventResult = null; + IOperationResult eventResult = null; using (var cts = new CancellationTokenSource(2000)) { @@ -659,26 +711,29 @@ public async Task SubscribeToReview_WithInlineFragment() // act var subscriptionResult = (IResponseStream)await executor.ExecuteAsync( - @"subscription { - onReview(episode: NEW_HOPE) { - ... on Review { - stars - } + """ + subscription { + onReview(episode: NEW_HOPE) { + ... on Review { + stars } - }"); + } + } + """); // assert await executor.ExecuteAsync( - @" - mutation { - createReview(episode: NEW_HOPE, - review: { stars: 5 commentary: ""foo"" }) { - stars - commentary - } - }"); + """ + mutation { + createReview(episode: NEW_HOPE, + review: { stars: 5 commentary: "foo" }) { + stars + commentary + } + } + """); - IQueryResult eventResult = null; + IOperationResult eventResult = null; using (var cts = new CancellationTokenSource(2000)) { @@ -702,28 +757,31 @@ public async Task SubscribeToReview_FragmentDefinition() // act var subscriptionResult = (IResponseStream)await executor.ExecuteAsync( - @"subscription { - onReview(episode: NEW_HOPE) { - ... SomeFrag - } + """ + subscription { + onReview(episode: NEW_HOPE) { + ... SomeFrag } + } - fragment SomeFrag on Review { - stars - }"); + fragment SomeFrag on Review { + stars + } + """); // assert await executor.ExecuteAsync( - @" - mutation { - createReview(episode: NEW_HOPE, - review: { stars: 5 commentary: ""foo"" }) { - stars - commentary - } - }"); + """ + mutation { + createReview(episode: NEW_HOPE, + review: { stars: 5 commentary: "foo" }) { + stars + commentary + } + } + """); - IQueryResult eventResult = null; + IOperationResult eventResult = null; using (var cts = new CancellationTokenSource(2000)) { @@ -747,26 +805,29 @@ public async Task SubscribeToReview_With_Variables() // act var subscriptionResult = (IResponseStream)await executor.ExecuteAsync( - @"subscription ($ep: Episode!) { - onReview(episode: $ep) { - stars - } - }", + """ + subscription ($ep: Episode!) { + onReview(episode: $ep) { + stars + } + } + """, new Dictionary { { "ep", "NEW_HOPE" }, }, CancellationToken.None); // assert await executor.ExecuteAsync( - @" - mutation { - createReview(episode: NEW_HOPE, - review: { stars: 5 commentary: ""foo"" }) { - stars - commentary - } - }"); + """ + mutation { + createReview(episode: NEW_HOPE, + review: { stars: 5 commentary: "foo" }) { + stars + commentary + } + } + """); - IQueryResult eventResult = null; + IOperationResult eventResult = null; using (var cts = new CancellationTokenSource(2000)) { @@ -880,10 +941,7 @@ ... on Droid { } } }", - request: r => - { - r.SetMaximumAllowedExecutionDepth(100); - }, + request: r => { r.SetMaximumAllowedExecutionDepth(100); }, configure: c => { AddDefaultConfiguration(c); @@ -934,10 +992,7 @@ ... on Droid { } } }", - request: r => - { - r.SkipExecutionDepthAnalysis(); - }, + request: r => { r.SkipExecutionDepthAnalysis(); }, configure: c => { AddDefaultConfiguration(c); @@ -992,16 +1047,11 @@ ... on Droid { var configurationA = new TestConfiguration { - ConfigureRequest = r => - { - r.SkipExecutionDepthAnalysis(); - }, + ConfigureRequest = r => { r.SkipExecutionDepthAnalysis(); }, }; var configurationB = new TestConfiguration { - ConfigureRequest = _ => - { - }, + ConfigureRequest = _ => { }, }; var executor = await CreateExecutorAsync( c => @@ -1017,8 +1067,8 @@ ... on Droid { var resultB = await executor.ExecuteAsync(requestB); // assert - Assert.Null(Assert.IsType(resultA).Errors); - Assert.NotNull(Assert.IsType(resultB).Errors); + Assert.Null(Assert.IsType(resultA).Errors); + Assert.NotNull(Assert.IsType(resultB).Errors); } [Fact] @@ -1064,13 +1114,14 @@ public async Task Include_With_Literal(string ifValue) { Snapshot.FullName(new SnapshotNameExtension(ifValue)); await ExpectValid( - $@" - {{ - human(id: ""1000"") {{ - name @include(if: {ifValue}) - height - }} - }}") + $$""" + { + human(id: "1000") { + name @include(if: {{ifValue}}) + height + } + } + """) .MatchSnapshotAsync(); } @@ -1081,14 +1132,15 @@ public async Task Include_With_Variable(bool ifValue) { Snapshot.FullName(new SnapshotNameExtension(ifValue)); await ExpectValid( - $@" - query ($if: Boolean!) {{ - human(id: ""1000"") {{ + """ + query ($if: Boolean!) { + human(id: "1000") { name @include(if: $if) height - }} - }}", - request: r => r.SetVariableValue("if", ifValue)) + } + } + """, + request: r => r.SetVariableValues(new Dictionary { { "if", ifValue }, })) .MatchSnapshotAsync(); } @@ -1099,13 +1151,14 @@ public async Task Skip_With_Literal(string ifValue) { Snapshot.FullName(new SnapshotNameExtension(ifValue)); await ExpectValid( - $@" - {{ - human(id: ""1000"") {{ - name @skip(if: {ifValue}) - height - }} - }}") + $$""" + { + human(id: "1000") { + name @skip(if: {{ifValue}}) + height + } + } + """) .MatchSnapshotAsync(); } @@ -1116,14 +1169,15 @@ public async Task Skip_With_Variable(bool ifValue) { Snapshot.FullName(new SnapshotNameExtension(ifValue)); await ExpectValid( - @" + """ query ($if: Boolean!) { - human(id: ""1000"") { + human(id: "1000") { name @skip(if: $if) height } - }", - request: r => r.SetVariableValue("if", ifValue)) + } + """, + request: r => r.SetVariableValues(new Dictionary { { "if", ifValue }, })) .MatchSnapshotAsync(); } @@ -1133,14 +1187,15 @@ public async Task SkipAll() Snapshot.FullName(); await ExpectValid( - @" + """ query ($if: Boolean!) { - human(id: ""1000"") @skip(if: $if) { + human(id: "1000") @skip(if: $if) { name height } - }", - request: r => r.SetVariableValue("if", true)) + } + """, + request: r => r.SetVariableValues(new Dictionary { { "if", true }, })) .MatchSnapshotAsync(); } @@ -1150,13 +1205,14 @@ public async Task SkipAll_Default_False() Snapshot.FullName(); await ExpectValid( - @" + """ query ($if: Boolean! = false) { - human(id: ""1000"") @skip(if: $if) { + human(id: "1000") @skip(if: $if) { name height } - }") + } + """) .MatchSnapshotAsync(); } @@ -1166,13 +1222,14 @@ public async Task SkipAll_Default_True() Snapshot.FullName(); await ExpectValid( - @" + """ query ($if: Boolean! = true) { - human(id: ""1000"") @skip(if: $if) { + human(id: "1000") @skip(if: $if) { name height } - }") + } + """) .MatchSnapshotAsync(); } @@ -1182,13 +1239,14 @@ public async Task SkipAllSecondLevelFields() Snapshot.FullName(); await ExpectValid( - @" + """ query ($if: Boolean!) { - human(id: ""1000"") { + human(id: "1000") { name @skip(if: $if) } - }", - request: r => r.SetVariableValue("if", true)) + } + """, + request: r => r.SetVariableValues(new Dictionary { { "if", true }, })) .MatchSnapshotAsync(); } @@ -1197,15 +1255,16 @@ public async Task Ensure_Type_Introspection_Returns_Null_If_Type_Not_Found() { Snapshot.FullName(); await ExpectValid( - @" + """ query { - a: __type(name: ""Foo"") { + a: __type(name: "Foo") { name } - b: __type(name: ""Query"") { + b: __type(name: "Query") { name } - }") + } + """) .MatchSnapshotAsync(); } @@ -1247,48 +1306,50 @@ public async Task NestedFragmentsWithNestedObjectFieldsAndSkip() Snapshot.FullName(); await ExpectValid( - @"query ($if: Boolean!) { - human(id: ""1000"") { - ... Human1 @include(if: $if) - ... Human2 @skip(if: $if) - } - } - fragment Human1 on Human { - friends { - edges { - ... FriendEdge1 + """ + query ($if: Boolean!) { + human(id: "1000") { + ... Human1 @include(if: $if) + ... Human2 @skip(if: $if) } } - } - fragment FriendEdge1 on FriendsEdge { - node { - __typename + fragment Human1 on Human { friends { - nodes { - __typename - ... Human3 + edges { + ... FriendEdge1 } } } - } - fragment Human2 on Human { - friends { - edges { - node { - __typename - ... Human3 + fragment FriendEdge1 on FriendsEdge { + node { + __typename + friends { + nodes { + __typename + ... Human3 + } } } } - } - fragment Human3 on Human { - name - otherHuman { - __typename - name + fragment Human2 on Human { + friends { + edges { + node { + __typename + ... Human3 + } + } + } } - }", - request: r => r.SetVariableValue("if", true)) + fragment Human3 on Human { + name + otherHuman { + __typename + name + } + } + """, + request: r => r.SetVariableValues(new Dictionary { { "if", true }, })) .MatchSnapshotAsync(); } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/TypeConverter/TypeConverterTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/TypeConverter/TypeConverterTests.cs index f19712edcc8..cb5dbfe3a0e 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/TypeConverter/TypeConverterTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/TypeConverter/TypeConverterTests.cs @@ -22,13 +22,18 @@ query foo($a: FooInput) { number } }", - request: r => r.AddVariableValue( - "a", + request: r => r.SetVariableValues( new Dictionary { - { "id", "934b987bc0d842bbabfd8a3b3f8b476e" }, - { "time", "2018-05-29T01:00Z" }, - { "number", (byte)123 }, + { + "a", + new Dictionary + { + { "id", "934b987bc0d842bbabfd8a3b3f8b476e" }, + { "time", "2018-05-29T01:00Z" }, + { "number", (byte)123 }, + } + } }), configure: c => c.AddQueryType()) .MatchSnapshotAsync(); @@ -43,7 +48,7 @@ await ExpectValid( query foo($time: DateTime) { time(time: $time) }", - request: r => r.AddVariableValue("time", "2018-05-29T01:00Z"), + request: r => r.SetVariableValues(new Dictionary { { "time", "2018-05-29T01:00Z" }, }), configure: c => c.AddQueryType()) .MatchSnapshotAsync(); } @@ -58,7 +63,7 @@ await ExpectValid( query foo($time: DateTime) { time(time: $time) }", - request: r => r.AddVariableValue("time", time), + request: r => r.SetVariableValues(new Dictionary { { "time", time }, }), configure: c => c.AddQueryType()) .MatchSnapshotAsync(); } @@ -76,13 +81,18 @@ query foo($a: FooInput) { number } }", - request: r => r.AddVariableValue( - "a", + request: r => r.SetVariableValues( new Dictionary { - { "id", "934b987bc0d842bbabfd8a3b3f8b476e" }, - { "time", "2018-05-29T01:00Z" }, - { "number", (byte)123 }, + { + "a", + new Dictionary + { + { "id", "934b987bc0d842bbabfd8a3b3f8b476e" }, + { "time", "2018-05-29T01:00Z" }, + { "number", (byte)123 }, + } + }, }), configure: c => c.AddQueryType()) .MatchSnapshotAsync(); @@ -251,4 +261,4 @@ public bool TryCreateConverter( return false; } } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/MiddlewareContextTests.cs b/src/HotChocolate/Core/test/Execution.Tests/MiddlewareContextTests.cs index 1be2286e978..0f85044c642 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/MiddlewareContextTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/MiddlewareContextTests.cs @@ -24,10 +24,10 @@ public async Task AccessVariables() ctx.Variables.GetVariable("abc")) .Create(); - var request = QueryRequestBuilder.New() - .SetQuery("query abc($abc: String){ foo(bar: $abc) }") - .SetVariableValue("abc", "def") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("query abc($abc: String){ foo(bar: $abc) }") + .SetVariableValues(new Dictionary { {"abc", "def" }, }) + .Build(); // act var result = await schema.MakeExecutable().ExecuteAsync(request); @@ -50,10 +50,10 @@ public async Task AccessVariables_Fails_When_Variable_Not_Exists() ctx.Variables.GetVariable("abc")) .Create(); - var request = QueryRequestBuilder.New() - .SetQuery("query abc($def: String){ foo(bar: $def) }") - .SetVariableValue("def", "ghi") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("query abc($def: String){ foo(bar: $def) }") + .SetVariableValues(new Dictionary { {"def", "ghi" }, }) + .Build(); // act var result = @@ -71,18 +71,19 @@ public async Task CollectFields() var schema = SchemaBuilder.New() .AddDocumentFromString( - @" - type Query { - foo: Foo - } + """ + type Query { + foo: Foo + } - type Foo { - bar: Bar - } + type Foo { + bar: Bar + } - type Bar { - baz: String - }") + type Bar { + baz: String + } + """) .Use( _ => context => { diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/ComplexityAnalyzerTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/ComplexityAnalyzerTests.cs deleted file mode 100644 index 8e3a8352f80..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/ComplexityAnalyzerTests.cs +++ /dev/null @@ -1,593 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using CookieCrumble; -using HotChocolate.Execution.Instrumentation; -using HotChocolate.Execution.Options; -using HotChocolate.Types; -using static HotChocolate.WellKnownContextData; -using static HotChocolate.Tests.TestHelper; -using FileResource = ChilliCream.Testing.FileResource; - -namespace HotChocolate.Execution.Pipeline; - -public class ComplexityAnalyzerTests -{ - [Fact] - public async Task MaxComplexity_Not_Reached() - { - var complexity = 0; - - await ExpectValid( - @"{ - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }", - configure: b => b - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 9; - }) - .UseRequest(next => async context => - { - await next(context); - complexity = (int)context.ContextData[OperationComplexity]!; - }) - .UseDefaultPipeline()); - - Assert.Equal(9, complexity); - } - - [Fact] - public async Task MaxComplexity_Reached() - { - await ExpectError( - @"{ - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }", - configure: b => b - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 8; - }) - .UseDefaultPipeline()); - } - - [Fact] - public async Task Alias_Explosion_Does_Not_Kill_The_Analyzer_With_Defaults() - { - var executor = - await new ServiceCollection() - .AddGraphQL() - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseDefaultPipeline() - .BuildRequestExecutorAsync(); - - var result = await executor.ExecuteAsync(FileResource.Open("aliases.graphql")); - - result.MatchSnapshot(); - } - - [Fact] - public async Task Alias_Explosion_Does_Not_Kill_The_Analyzer_With_Defaults_2() - { - var executor = - await new ServiceCollection() - .AddGraphQL() - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseDefaultPipeline() - .BuildRequestExecutorAsync(); - - var result = await executor.ExecuteAsync(FileResource.Open("aliases_2048.graphql")); - - result.MatchSnapshot(); - } - - [Fact] - public async Task Alias_Explosion_Does_Not_Kill_The_Analyzer() - { - var executor = - await new ServiceCollection() - .AddGraphQL() - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .ModifyParserOptions( - o => - { - o.MaxAllowedFields = 40000; - }) - .UseDefaultPipeline() - .BuildRequestExecutorAsync(); - - var result = await executor.ExecuteAsync(FileResource.Open("aliases.graphql")); - - result.MatchSnapshot(); - } - - [Fact] - public async Task MaxComplexity_Analysis_Skipped() - { - await ExpectValid( - @"{ - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }", - request: b => b.SkipComplexityAnalysis(), - configure: b => b - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 8; - }) - .UseDefaultPipeline()); - } - - [Fact] - public async Task MaxComplexity_Analysis_Request_Maximum() - { - await ExpectValid( - @"{ - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }", - request: b => b.SetMaximumAllowedComplexity(1000), - configure: b => b - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 8; - }) - .UseDefaultPipeline()); - } - - [Fact] - public async Task MaxComplexity_Custom_Calculation() - { - var complexity = 0; - - await ExpectValid( - @"{ - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }", - configure: b => b - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - o.Complexity.Calculation = context => - ComplexityAnalyzerSettings.DefaultCalculation(context) * 2; - }) - .UseRequest(next => async context => - { - await next(context); - complexity = (int)context.ContextData[OperationComplexity]!; - }) - .UseDefaultPipeline()); - - Assert.Equal(50, complexity); - } - - [Fact] - public async Task Apply_Complexity_Defaults_For_Connections() - { - var complexity = 0; - - await ExpectValid( - @"{ - persons { - nodes { - name - } - } - }", - configure: b => b - .AddQueryType() - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseRequest(next => async context => - { - await next(context); - complexity = (int)context.ContextData[OperationComplexity]!; - }) - .UseDefaultPipeline()); - - Assert.Equal(70, complexity); - } - - [Fact] - public async Task Apply_Complexity_Defaults_For_Connections_And_Resolvers() - { - var complexity = 0; - - await ExpectValid( - @"{ - persons { - nodes { - name - } - } - person { - name - } - }", - configure: b => b - .AddQueryType() - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseRequest(next => async context => - { - await next(context); - complexity = (int)context.ContextData[OperationComplexity]!; - }) - .UseDefaultPipeline()); - - Assert.Equal(76, complexity); - } - - [Fact] - public async Task Apply_Complexity_Defaults_For_Connections_And_Resolvers_And_InMemField() - { - var complexity = 0; - - await ExpectValid( - @"{ - persons { - nodes { - name - } - } - person { - name - } - sayHello - }", - configure: b => b - .AddQueryType() - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseRequest(next => async context => - { - await next(context); - complexity = (int)context.ContextData[OperationComplexity]!; - }) - .UseDefaultPipeline()); - - Assert.Equal(77, complexity); - } - - [Fact] - public async Task Apply_Complexity_Defaults() - { - var schema = - await new ServiceCollection() - .AddGraphQL() - .AddQueryType() - .ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .BuildSchemaAsync(); - - schema.MatchSnapshot(); - } - - [Fact] - public async Task MaxComplexity_Not_With_Union() - { - var complexity = 0; - - await ExpectValid( - @"{ - bazOrBar { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - ... on Bar { - baz { - foo { - field - } - } - } - } - }", - configure: b => b - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseRequest(next => async context => - { - await next(context); - complexity = (int)context.ContextData[OperationComplexity]!; - }) - .UseDefaultPipeline()); - - Assert.Equal(16, complexity); - } - - [Fact] - public async Task Ensure_Cache_Is_Hit_When_Two_Ops_In_Request() - { - // arrange - const string requestDocument = - """ - query GetBazBar { - bazOrBar { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - ... on Bar { - baz { - foo { - field - } - } - } - } - } - - query FooBar { - bazOrBar { - __typename - } - } - """; - - var request = - QueryRequestBuilder.New() - .SetQuery(requestDocument); - - var diagnostics = new CacheHit(); - - var executor = - await new ServiceCollection() - .AddGraphQLServer() - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .AddDiagnosticEventListener(_ => diagnostics) - .UseDefaultPipeline() - .BuildRequestExecutorAsync(); - - // act - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("FooBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("FooBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("FooBar").Create()); - - // assert - Assert.Equal(2, diagnostics.Compiled); - } - - [Fact] - public async Task Ensure_Cache_Is_Hit_When_Single_Op() - { - // arrange - const string requestDocument = - """ - query GetBazBar { - bazOrBar { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - ... on Bar { - baz { - foo { - field - } - } - } - } - } - """; - - var request = - QueryRequestBuilder.New() - .SetQuery(requestDocument); - - var diagnostics = new CacheHit(); - - var executor = - await new ServiceCollection() - .AddGraphQLServer() - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions( - o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 1000; - }) - .UseDefaultPipeline() - .AddDiagnosticEventListener(_ => diagnostics) - .BuildRequestExecutorAsync(); - - // act - await executor.ExecuteAsync(request.Create()); - await executor.ExecuteAsync(request.Create()); - - // assert - Assert.Equal(1, diagnostics.Compiled); - } - - public class Query - { - [UsePaging] - public IQueryable GetPersons() - => new[] { new Person(), }.AsQueryable(); - - public Task GetPersonAsync() - => Task.FromResult(new Person()); - - public string SayHello() => "Hello"; - } - - public class Person - { - public string Name { get; set; } = "Luke"; - } - - public sealed class CacheHit : ExecutionDiagnosticEventListener - { - public int Compiled { get; private set; } - - public override void OperationComplexityAnalyzerCompiled(IRequestContext context) - { - Compiled++; - } - } -} diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentCacheMiddlewareTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentCacheMiddlewareTests.cs index 374c9821b11..2a04f92b75a 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentCacheMiddlewareTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentCacheMiddlewareTests.cs @@ -19,10 +19,10 @@ public async Task RetrieveItemFromCache_DocumentFoundOnCache() cache, hashProvider); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); cache.TryAddDocument("a", document); @@ -57,10 +57,10 @@ public async Task RetrieveItemFromCacheByHash_DocumentFoundOnCache() cache, hashProvider); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryHash("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentHash("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); cache.TryAddDocument("a", document); @@ -95,10 +95,10 @@ public async Task RetrieveItemFromCache_DocumentNotFoundOnCache() cache, hashProvider); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); cache.TryAddDocument("b", document); @@ -129,9 +129,9 @@ public async Task AddItemToCacheWithDocumentId() var cache = new Caching.DefaultDocumentCache(); var hashProvider = new MD5DocumentHashProvider(); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); @@ -169,9 +169,9 @@ public async Task AddItemToCacheWithDocumentHash() var cache = new Caching.DefaultDocumentCache(); var hashProvider = new MD5DocumentHashProvider(); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .Build(); var parserMiddleware = DocumentParserMiddleware.Create( _ => default, diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentParserMiddlewareTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentParserMiddlewareTests.cs index 164dba78694..75c59e4335d 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentParserMiddlewareTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentParserMiddlewareTests.cs @@ -20,10 +20,10 @@ public async Task DocumentExists_SkipParsing_DocumentIsUnchanged() hashProvider, new ParserOptions()); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); @@ -50,10 +50,10 @@ public async Task NoDocument_ParseQuery_DocumentParsedAndHashed() hashProvider, new ParserOptions()); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var requestContext = new Mock(); requestContext.SetupGet(t => t.Request).Returns(request); @@ -80,10 +80,10 @@ public async Task InvalidQuery_SyntaxError_ContextHasErrorResult() hashProvider, new ParserOptions()); - var request = QueryRequestBuilder.New() - .SetQuery("{") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{") + .SetDocumentId("a") + .Build(); var requestContext = new Mock(); requestContext.SetupGet(t => t.Request).Returns(request); diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentValidationMiddlewareTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentValidationMiddlewareTests.cs index f92f727b604..b5d6217f7cd 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentValidationMiddlewareTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/DocumentValidationMiddlewareTests.cs @@ -16,7 +16,7 @@ public async Task DocumentIsValidated_SkipValidation() validator.Setup(t => t.ValidateAsync( It.IsAny(), It.IsAny(), - It.IsAny(), + It.IsAny(), It.IsAny>(), It.Is(b => true), It.IsAny())) @@ -27,10 +27,10 @@ public async Task DocumentIsValidated_SkipValidation() new NoopExecutionDiagnosticEvents(), validator.Object); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); var validationResult = new DocumentValidatorResult(Array.Empty()); @@ -58,7 +58,7 @@ public async Task DocumentIsValidated_Dynamic() validator.Setup(t => t.ValidateAsync( It.IsAny(), It.IsAny(), - It.IsAny(), + It.IsAny(), It.IsAny>(), It.Is(b => true), It.IsAny())) @@ -69,10 +69,10 @@ public async Task DocumentIsValidated_Dynamic() new NoopExecutionDiagnosticEvents(), validator.Object); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); var validationResult = new DocumentValidatorResult(Array.Empty()); @@ -101,7 +101,7 @@ public async Task DocumentNeedsValidation_DocumentIsValid() validator.Setup(t => t.ValidateAsync( It.IsAny(), It.IsAny(), - It.IsAny(), + It.IsAny(), It.IsAny>(), It.Is(b => true), It.IsAny())) @@ -112,10 +112,10 @@ public async Task DocumentNeedsValidation_DocumentIsValid() new NoopExecutionDiagnosticEvents(), validator.Object); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); @@ -145,7 +145,7 @@ public async Task DocumentNeedsValidation_DocumentInvalid() validator.Setup(t => t.ValidateAsync( It.IsAny(), It.IsAny(), - It.IsAny(), + It.IsAny(), It.IsAny>(), It.Is(b => true), It.IsAny())) @@ -156,10 +156,10 @@ public async Task DocumentNeedsValidation_DocumentInvalid() new NoopExecutionDiagnosticEvents(), validator.Object); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var document = Utf8GraphQLParser.Parse("{ a }"); @@ -188,7 +188,7 @@ public async Task NoDocument_MiddlewareWillFail() validator.Setup(t => t.ValidateAsync( It.IsAny(), It.IsAny(), - It.IsAny(), + It.IsAny(), It.IsAny>(), It.Is(b => true), It.IsAny())) @@ -199,10 +199,10 @@ public async Task NoDocument_MiddlewareWillFail() new NoopExecutionDiagnosticEvents(), validator.Object); - var request = QueryRequestBuilder.New() - .SetQuery("{ a }") - .SetQueryId("a") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ a }") + .SetDocumentId("a") + .Build(); var requestContext = new Mock(); requestContext.SetupGet(t => t.Request).Returns(request); diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/OperationCacheMiddlewareTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/OperationCacheMiddlewareTests.cs index 43272d8bea7..25255b49862 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/OperationCacheMiddlewareTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/OperationCacheMiddlewareTests.cs @@ -43,9 +43,7 @@ query FooBar { } """; - var request = - QueryRequestBuilder.New() - .SetQuery(requestDocument); + var request = OperationRequest.FromSourceText(requestDocument); var diagnostics = new CacheHit(); @@ -54,20 +52,19 @@ query FooBar { .AddGraphQLServer() .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) .AddDiagnosticEventListener(_ => diagnostics) .UseDefaultPipeline() .BuildRequestExecutorAsync(); // act - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("FooBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("FooBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("GetBazBar").Create()); - await executor.ExecuteAsync(request.SetOperation("FooBar").Create()); + await executor.ExecuteAsync(request.WithOperationName("GetBazBar")); + await executor.ExecuteAsync(request.WithOperationName("FooBar")); + await executor.ExecuteAsync(request.WithOperationName("GetBazBar")); + await executor.ExecuteAsync(request.WithOperationName("FooBar")); + await executor.ExecuteAsync(request.WithOperationName("GetBazBar")); + await executor.ExecuteAsync(request.WithOperationName("GetBazBar")); + await executor.ExecuteAsync(request.WithOperationName("GetBazBar")); + await executor.ExecuteAsync(request.WithOperationName("FooBar")); // assert Assert.Equal(2, diagnostics.AddedToCache); @@ -106,9 +103,7 @@ ... on Bar { } """; - var request = - QueryRequestBuilder.New() - .SetQuery(requestDocument); + var request = OperationRequest.FromSourceText(requestDocument); var diagnostics = new CacheHit(); @@ -117,14 +112,13 @@ ... on Bar { .AddGraphQLServer() .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) .UseDefaultPipeline() .AddDiagnosticEventListener(_ => diagnostics) .BuildRequestExecutorAsync(); // act - await executor.ExecuteAsync(request.Create()); - await executor.ExecuteAsync(request.Create()); + await executor.ExecuteAsync(request); + await executor.ExecuteAsync(request); // assert Assert.Equal(1, diagnostics.AddedToCache); diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/RequestClassMiddlewareFactoryTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/RequestClassMiddlewareFactoryTests.cs index ddf2ab9b299..e40a1cc4a60 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/RequestClassMiddlewareFactoryTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/RequestClassMiddlewareFactoryTests.cs @@ -32,7 +32,7 @@ public async Task Create_CoreMiddleware_InjectOptimizers() new Mock().Object); context.Initialize( - new Mock().Object, + new Mock().Object, new Mock().Object); // act diff --git a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/TransactionScopeHandlerTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/TransactionScopeHandlerTests.cs index 07dfa97b25c..485e8db82f7 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Pipeline/TransactionScopeHandlerTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Pipeline/TransactionScopeHandlerTests.cs @@ -90,52 +90,22 @@ public bool FoundTransactionScope() => System.Transactions.Transaction.Current is not null; } - public class MockTransactionScopeHandler : ITransactionScopeHandler + public class MockTransactionScopeHandler(Action complete, Action dispose) : ITransactionScopeHandler { - private readonly Action _complete; - private readonly Action _dispose; - - public MockTransactionScopeHandler( - Action complete, - Action dispose) - { - _complete = complete; - _dispose = dispose; - } - public ITransactionScope Create(IRequestContext context) - { - return new MockTransactionScope(_complete, _dispose, context); - } + => new MockTransactionScope(complete, dispose, context); } - public class MockTransactionScope : ITransactionScope + public class MockTransactionScope(Action complete, Action dispose, IRequestContext context) : ITransactionScope { - private readonly Action _complete; - private readonly Action _dispose; - private readonly IRequestContext _context; - - public MockTransactionScope( - Action complete, - Action dispose, - IRequestContext context) - { - _complete = complete; - _dispose = dispose; - _context = context; - } - public void Complete() { - if(_context.Result is IQueryResult { Data: not null, Errors: null or { Count: 0, }, }) + if(context.Result is IOperationResult { Data: not null, Errors: null or { Count: 0, }, }) { - _complete(); + complete(); } } - public void Dispose() - { - _dispose(); - } + public void Dispose() => dispose(); } } \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs index 7e413a848c6..9d86f056ebb 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs @@ -283,8 +283,8 @@ public async Task Skip_True_Include_True_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query { person @skip(if: true) @include(if: true) { @@ -292,9 +292,8 @@ person @skip(if: true) @include(if: true) { } } """) - .SetVariableValue("skip", true) - .SetVariableValue("include", true) - .Create()); + .SetVariableValues(new Dictionary { { "skip", true }, { "include", true }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -303,7 +302,7 @@ person @skip(if: true) @include(if: true) { } """); } - + [Fact] public async Task Skip_Include_Merge_Issue_6550_True() { @@ -312,8 +311,8 @@ public async Task Skip_Include_Merge_Issue_6550_True() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($shouldSkip: Boolean! = true) { person @skip(if: $shouldSkip) { @@ -327,8 +326,8 @@ person @skip(if: $shouldSkip) { } } """) - .SetVariableValue("shouldSkip", true) - .Create()); + .SetVariableValues(new Dictionary { { "shouldSkip", true }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -337,7 +336,7 @@ person @skip(if: $shouldSkip) { } """); } - + [Fact] public async Task Skip_Include_Merge_Issue_6550_False() { @@ -346,8 +345,8 @@ public async Task Skip_Include_Merge_Issue_6550_False() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($shouldSkip: Boolean! = true) { person @skip(if: $shouldSkip) { @@ -361,8 +360,8 @@ person @skip(if: $shouldSkip) { } } """) - .SetVariableValue("shouldSkip", false) - .Create()); + .SetVariableValues(new Dictionary { { "shouldSkip", false }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -386,8 +385,8 @@ public async Task Variables_Skip_True_Include_True_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($skip: Boolean! $include: Boolean!) { person @skip(if: $skip) @include(if: $include) { @@ -395,9 +394,8 @@ person @skip(if: $skip) @include(if: $include) { } } """) - .SetVariableValue("skip", true) - .SetVariableValue("include", true) - .Create()); + .SetVariableValues(new Dictionary { { "skip", true }, { "include", true }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -415,8 +413,8 @@ public async Task Skip_True_Include_False_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query { person @skip(if: true) @include(if: false) { @@ -424,9 +422,8 @@ person @skip(if: true) @include(if: false) { } } """) - .SetVariableValue("skip", true) - .SetVariableValue("include", true) - .Create()); + .SetVariableValues(new Dictionary { { "skip", true }, { "include", true }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -444,8 +441,8 @@ public async Task Variables_Skip_True_Include_False_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($skip: Boolean! $include: Boolean!) { person @skip(if: $skip) @include(if: $include) { @@ -453,9 +450,8 @@ person @skip(if: $skip) @include(if: $include) { } } """) - .SetVariableValue("skip", true) - .SetVariableValue("include", false) - .Create()); + .SetVariableValues(new Dictionary { { "skip", true }, { "include", false }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -473,8 +469,8 @@ public async Task Skip_False_Include_False_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query { person @skip(if: false) @include(if: false) { @@ -482,7 +478,7 @@ person @skip(if: false) @include(if: false) { } } """) - .Create()); + .Build()); result.MatchInlineSnapshot( """ @@ -500,8 +496,8 @@ public async Task Variables_Skip_False_Include_False_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($skip: Boolean! $include: Boolean!) { person @skip(if: $skip) @include(if: $include) { @@ -509,9 +505,8 @@ person @skip(if: $skip) @include(if: $include) { } } """) - .SetVariableValue("skip", false) - .SetVariableValue("include", false) - .Create()); + .SetVariableValues(new Dictionary { { "skip", false }, { "include", false }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -529,8 +524,8 @@ public async Task Skip_False_Include_True_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query { person @skip(if: false) @include(if: true) { @@ -538,7 +533,7 @@ person @skip(if: false) @include(if: true) { } } """) - .Create()); + .Build()); result.MatchInlineSnapshot( """ @@ -560,8 +555,8 @@ public async Task Variables_Skip_False_Include_True_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($skip: Boolean! $include: Boolean!) { person @skip(if: $skip) @include(if: $include) { @@ -569,9 +564,8 @@ person @skip(if: $skip) @include(if: $include) { } } """) - .SetVariableValue("skip", false) - .SetVariableValue("include", true) - .Create()); + .SetVariableValues(new Dictionary { { "skip", false }, { "include", true }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -593,8 +587,8 @@ public async Task Skip_True_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query { person @skip(if: true) { @@ -602,7 +596,7 @@ person @skip(if: true) { } } """) - .Create()); + .Build()); result.MatchInlineSnapshot( """ @@ -620,8 +614,8 @@ public async Task Variables_Skip_True_Should_Be_Empty_Result() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($skip: Boolean!) { person @skip(if: $skip){ @@ -629,8 +623,8 @@ person @skip(if: $skip){ } } """) - .SetVariableValue("skip", true) - .Create()); + .SetVariableValues(new Dictionary { { "skip", true }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -648,8 +642,8 @@ public async Task Nested_Skips() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query { persons @skip(if: true) { @@ -659,7 +653,7 @@ nodes @include(if: true) @skip(if: false) { } } """) - .Create()); + .Build()); result.MatchInlineSnapshot( """ @@ -678,8 +672,8 @@ public async Task Issue_6050() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($permission: Boolean!) { person { @@ -699,8 +693,8 @@ fragment B on Person { __typename } """) - .SetVariableValue("permission", false) - .Create()); + .SetVariableValues(new Dictionary { { "permission", false }, }) + .Build()); result.MatchInlineSnapshot( """ @@ -729,4 +723,4 @@ public sealed class Person public string Address { get; } = "world"; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/RequestExecutorTests.cs b/src/HotChocolate/Core/test/Execution.Tests/RequestExecutorTests.cs index cc30e4a0a5e..5d4c381c814 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/RequestExecutorTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/RequestExecutorTests.cs @@ -72,16 +72,16 @@ public async Task CancellationToken_Is_Passed_Correctly() catch (OperationCanceledException) { tokenWasCorrectlyPassedToResolver = true; - throw new QueryException("CancellationRaised"); + throw new GraphQLException("CancellationRaised"); } })) .Create(); var executor = schema.MakeExecutable(); - var request = QueryRequestBuilder.New() - .SetQuery("{ foo }") - .Create(); + var request = OperationRequestBuilder.Create() + .SetDocument("{ foo }") + .Build(); // act var result = await executor.ExecuteAsync(request, cts.Token); @@ -141,4 +141,4 @@ public class Test public string Foo { get; set; } = "Foo"; public string Bar { get; set; } = "Bar"; } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/SchemaDirectiveTests.cs b/src/HotChocolate/Core/test/Execution.Tests/SchemaDirectiveTests.cs index 9c06b4ab01a..5b0ee6cad52 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/SchemaDirectiveTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/SchemaDirectiveTests.cs @@ -142,7 +142,7 @@ protected override void Configure( if (directive.Type.Name != "upper") { - throw new QueryException("Not the upper directive."); + throw new GraphQLException("Not the upper directive."); } if (context.Result is string s) @@ -166,7 +166,7 @@ protected override void Configure(IDirectiveTypeDescriptor descriptor) if (directive.Type.Name != "lower") { - throw new QueryException("Not the lower directive."); + throw new GraphQLException("Not the lower directive."); } if (context.Result is string s) diff --git a/src/HotChocolate/Core/test/Execution.Tests/SchemaFirstTests.cs b/src/HotChocolate/Core/test/Execution.Tests/SchemaFirstTests.cs index 9839abe9e4e..bdac713659a 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/SchemaFirstTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/SchemaFirstTests.cs @@ -26,7 +26,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ test testProp }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -58,7 +58,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ foo(bar: { baz: \"hello\"}) }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -85,7 +85,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ enumValue }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -112,7 +112,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ setEnumValue(value:BAZ_BAR) }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } @@ -146,7 +146,7 @@ await schema.MakeExecutable().ExecuteAsync( "{ enumInInputObject(payload: { value:BAZ } ) }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); result.MatchSnapshot(); } diff --git a/src/HotChocolate/Core/test/Execution.Tests/SourceObjectConversionTests.cs b/src/HotChocolate/Core/test/Execution.Tests/SourceObjectConversionTests.cs index 1abd49047ab..64e36647b3b 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/SourceObjectConversionTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/SourceObjectConversionTests.cs @@ -31,7 +31,7 @@ public async Task ConvertSourceObject() // assert Assert.True( - Assert.IsType(result).Errors is null, + Assert.IsType(result).Errors is null, "There should be no errors."); Assert.True( conversionTriggered, @@ -50,9 +50,9 @@ public async Task NoConverter_Specified() // act var request = - QueryRequestBuilder.New() - .SetQuery("{ foo { qux } }") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ foo { qux } }") + .Build(); var result = await schema.MakeExecutable().ExecuteAsync(request); @@ -88,4 +88,4 @@ public class Baz public class BazType : ObjectType { } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/StreamTests.cs b/src/HotChocolate/Core/test/Execution.Tests/StreamTests.cs index b54c434a9ef..d00213c43f5 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/StreamTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/StreamTests.cs @@ -116,7 +116,7 @@ persons @stream(if: false) { } """); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } [LocalFact] @@ -127,9 +127,9 @@ public async Task Stream_If_Variable_Set_To_false() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery( + OperationRequestBuilder + .Create() + .SetDocument( """ query ($stream: Boolean!) { persons @stream(if: $stream) { @@ -137,10 +137,10 @@ persons @stream(if: $stream) { } } """) - .SetVariableValue("stream", false) - .Create()); + .SetVariableValues(new Dictionary { {"stream", false},}) + .Build()); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } [LocalFact] @@ -151,9 +151,9 @@ public async Task AsyncEnumerable_Result() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery( + OperationRequestBuilder + .Create() + .SetDocument( """ { persons { @@ -161,8 +161,8 @@ public async Task AsyncEnumerable_Result() } } """) - .Create()); + .Build()); - Assert.IsType(result).MatchSnapshot(); + Assert.IsType(result).MatchSnapshot(); } } diff --git a/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs b/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs index 512ce55b61d..4283fbb21ac 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs @@ -15,10 +15,10 @@ public async Task Schema_Without_TrueNullability() .AddQueryType() .ModifyOptions(o => o.EnableTrueNullability = false) .BuildSchemaAsync(); - + schema.MatchSnapshot(); } - + [Fact] public async Task Schema_With_TrueNullability() { @@ -28,10 +28,10 @@ public async Task Schema_With_TrueNullability() .AddQueryType() .ModifyOptions(o => o.EnableTrueNullability = true) .BuildSchemaAsync(); - + schema.MatchSnapshot(); } - + [Fact] public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled_By_Default() { @@ -51,30 +51,7 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled_By_D } } """); - - response.MatchSnapshot(); - } - - [Fact] - public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled() - { - var response = - await new ServiceCollection() - .AddGraphQLServer() - .AddQueryType() - .ModifyOptions(o => o.EnableTrueNullability = true) - .ExecuteRequestAsync( - """ - query @nullBubbling { - book { - name - author { - name - } - } - } - """); - + response.MatchSnapshot(); } @@ -87,61 +64,38 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled() .AddQueryType() .ModifyOptions(o => o.EnableTrueNullability = true) .ExecuteRequestAsync( - """ - query @nullBubbling(enable: false) { - book { - name - author { - name - } - } - } - """); - - response.MatchSnapshot(); - } - - [Fact] - public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable() - { - var response = - await new ServiceCollection() - .AddGraphQLServer() - .AddQueryType() - .ModifyOptions(o => o.EnableTrueNullability = true) - .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query($enable: Boolean!) @nullBubbling(enable: $enable) { - book { - name - author { + OperationRequestBuilder.Create() + .SetDocument( + """ + query { + book { name + author { + name + } } } - } - """) - .SetVariableValue("enable", false) - .Create()); - + """) + .SetGlobalState(WellKnownContextData.EnableTrueNullability, null) + .Build()); + response.MatchSnapshot(); } - + public class Query { public Book? GetBook() => new(); } - + public class Book { public string Name => "Some book!"; public Author Author => new(); } - + public class Author { public string Name => throw new Exception(); - } -} \ No newline at end of file + } +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/__resources__/CostSchema.graphql b/src/HotChocolate/Core/test/Execution.Tests/__resources__/CostSchema.graphql index a44b31d9dd0..20cb36960ed 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/__resources__/CostSchema.graphql +++ b/src/HotChocolate/Core/test/Execution.Tests/__resources__/CostSchema.graphql @@ -18,3 +18,5 @@ type Baz { } union BazOrBar = Baz | Bar + +directive @cost(complexity: Int!) on FIELD_DEFINITION diff --git a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/ScopedContextDataTests.ScopedContextDataIsPassedAlongCorrectly.snap b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/ScopedContextDataTests.ScopedContextDataIsPassedAlongCorrectly.snap index c7909f4f144..db70542da0c 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/ScopedContextDataTests.ScopedContextDataIsPassedAlongCorrectly.snap +++ b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/ScopedContextDataTests.ScopedContextDataIsPassedAlongCorrectly.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/SourceObjectConversionTests.ConvertSourceObject.snap b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/SourceObjectConversionTests.ConvertSourceObject.snap index de364a66e3a..de56f5dc191 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/SourceObjectConversionTests.ConvertSourceObject.snap +++ b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/SourceObjectConversionTests.ConvertSourceObject.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable.snap b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable.snap deleted file mode 100644 index 5f1271ea8b6..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable.snap +++ /dev/null @@ -1,26 +0,0 @@ -{ - "errors": [ - { - "message": "Unexpected Execution Error", - "locations": [ - { - "line": 5, - "column": 13 - } - ], - "path": [ - "book", - "author", - "name" - ] - } - ], - "data": { - "book": { - "name": "Some book!", - "author": { - "name": null - } - } - } -} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Enabled.snap b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Enabled.snap deleted file mode 100644 index 4bb9b286d1b..00000000000 --- a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_TrueNullability_And_NullBubbling_Enabled.snap +++ /dev/null @@ -1,37 +0,0 @@ -{ - "errors": [ - { - "message": "Cannot return null for non-nullable field.", - "locations": [ - { - "line": 4, - "column": 9 - } - ], - "path": [ - "book", - "author" - ], - "extensions": { - "code": "HC0018" - } - }, - { - "message": "Unexpected Execution Error", - "locations": [ - { - "line": 5, - "column": 13 - } - ], - "path": [ - "book", - "author", - "name" - ] - } - ], - "data": { - "book": null - } -} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Schema_With_TrueNullability.graphql b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Schema_With_TrueNullability.graphql index b202b0bbeab..ae51fdf5769 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Schema_With_TrueNullability.graphql +++ b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Schema_With_TrueNullability.graphql @@ -13,6 +13,4 @@ type Book { type Query { book: Book -} - -directive @nullBubbling(enable: Boolean! = true) on QUERY | MUTATION | SUBSCRIPTION \ No newline at end of file +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/SomeRequestMiddleware.cs b/src/HotChocolate/Core/test/Types.Analyzers.Tests/SomeRequestMiddleware.cs index c4ce21877e9..c96cc7203df 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/SomeRequestMiddleware.cs +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/SomeRequestMiddleware.cs @@ -11,7 +11,7 @@ public async ValueTask InvokeAsync(IRequestContext context, Service3 service3) await next(context); context.Result = - QueryResultBuilder.New() + OperationResultBuilder.New() .SetData( new Dictionary { @@ -19,7 +19,7 @@ public async ValueTask InvokeAsync(IRequestContext context, Service3 service3) $"{service1.Say()} {service3.Hello()} {service2.World()}", true }, }) - .Create(); + .Build(); } } diff --git a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/CustomCursorHandlerTests.cs b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/CustomCursorHandlerTests.cs index 9f2e63162ca..289cd340001 100644 --- a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/CustomCursorHandlerTests.cs +++ b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/CustomCursorHandlerTests.cs @@ -26,9 +26,9 @@ public async Task Use_Resolver_Result_If_It_Is_A_Page() Snapshot.FullName(); var request = - QueryRequestBuilder.New() - .SetQuery("{ items { nodes } }") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ items { nodes } }") + .Build(); // act // assert @@ -55,4 +55,4 @@ public Connection GetItems( 2000); } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Types.Mutations.Tests/AnnotationBasedMutations.cs b/src/HotChocolate/Core/test/Types.Mutations.Tests/AnnotationBasedMutations.cs index 59cd16756e2..85a8ca60449 100644 --- a/src/HotChocolate/Core/test/Types.Mutations.Tests/AnnotationBasedMutations.cs +++ b/src/HotChocolate/Core/test/Types.Mutations.Tests/AnnotationBasedMutations.cs @@ -516,8 +516,9 @@ public async Task Allow_Id_Middleware() .ModifyOptions(o => o.StrictValidation = false) .AddGlobalObjectIdentification() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder + .Create() + .SetDocument( """ mutation($id: ID!) { doSomething(input: { @@ -527,8 +528,8 @@ public async Task Allow_Id_Middleware() } } """) - .AddVariableValue("id", id) - .Create()); + .SetVariableValues(new Dictionary { { "id", id } }) + .Build()); SnapshotExtensions.MatchSnapshot(result); } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DateTimeZoneTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DateTimeZoneTypeTests.cs index 955e1900a8e..7ccfefc26f3 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DateTimeZoneTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DateTimeZoneTypeTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using HotChocolate.Execution; using NodaTime; @@ -24,85 +25,80 @@ public string Test(DateTimeZone arg) } } - private readonly IRequestExecutor testExecutor; - - public DateTimeZoneTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime() - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime() + .Create() + .MakeExecutable(); [Fact] public void QueryReturnsUtc() { - var result = testExecutor.Execute("query { test: utc }"); - Assert.Equal("UTC", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: utc }"); + Assert.Equal("UTC", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsRome() { - var result = testExecutor.Execute("query { test: rome }"); - Assert.Equal("Europe/Rome", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: rome }"); + Assert.Equal("Europe/Rome", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsChihuahua() { - var result = testExecutor.Execute("query { test: chihuahua }"); - Assert.Equal("America/Chihuahua", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: chihuahua }"); + Assert.Equal("America/Chihuahua", Assert.IsType(result).Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: DateTimeZone!) { test(arg: $arg) }") - .SetVariableValue("arg", "Europe/Amsterdam") - .Create()); - Assert.Equal("Europe/Amsterdam", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: DateTimeZone!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "Europe/Amsterdam" }, }) + .Build()); + Assert.Equal("Europe/Amsterdam", Assert.IsType(result).Data!["test"]); } [Fact] public void DoesntParseIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: DateTimeZone!) { test(arg: $arg) }") - .SetVariableValue("arg", "Europe/Hamster") - .Create()); - Assert.Null(Assert.IsType(result).Data); - Assert.Equal(1, Assert.IsType(result).Errors!.Count); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: DateTimeZone!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "Europe/Hamster" }, }) + .Build()); + Assert.Null(Assert.IsType(result).Data); + Assert.Equal(1, Assert.IsType(result).Errors!.Count); } [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"Europe/Amsterdam\") }") - .Create()); - Assert.Equal("Europe/Amsterdam", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"Europe/Amsterdam\") }") + .Build()); + Assert.Equal("Europe/Amsterdam", Assert.IsType(result).Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"Europe/Hamster\") }") - .Create()); - Assert.Null(Assert.IsType(result).Data); - Assert.Equal(1, Assert.IsType(result).Errors!.Count); - Assert.Null(Assert.IsType(result).Errors!.First().Code); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"Europe/Hamster\") }") + .Build()); + Assert.Null(Assert.IsType(result).Data); + Assert.Equal(1, Assert.IsType(result).Errors!.Count); + Assert.Null(Assert.IsType(result).Errors!.First().Code); Assert.Equal( "Unable to deserialize string to DateTimeZone", - Assert.IsType(result).Errors!.First().Message); + Assert.IsType(result).Errors!.First().Message); } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeJsonRoundtripIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeJsonRoundtripIntegrationTests.cs index edbd4ba755d..6c1ab89d6fa 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeJsonRoundtripIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeJsonRoundtripIntegrationTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -37,165 +38,160 @@ public Duration Test(Duration arg) } } - private readonly IRequestExecutor testExecutor; - - public DurationTypeJsonRoundtripIntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime(excludeTypes: typeof(DurationType)) - .AddType(new DurationType(DurationPattern.JsonRoundtrip)) - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime(excludeTypes: typeof(DurationType)) + .AddType(new DurationType(DurationPattern.JsonRoundtrip)) + .Create() + .MakeExecutable(); [Fact] public void QueryReturnsSerializedDataWithDecimals() { - var result = testExecutor.Execute("query { test: positiveWithDecimals }"); - Assert.Equal("2959:53:10.019", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: positiveWithDecimals }"); + Assert.Equal("2959:53:10.019", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsSerializedDataWithNegativeValue() { - var result = testExecutor.Execute("query { test: negativeWithDecimals }"); - Assert.Equal("-2959:53:10.019", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: negativeWithDecimals }"); + Assert.Equal("-2959:53:10.019", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsSerializedDataWithoutDecimals() { - var result = testExecutor.Execute("query { test: positiveWithoutDecimals }"); - Assert.Equal("2959:53:10", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: positiveWithoutDecimals }"); + Assert.Equal("2959:53:10", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsSerializedDataWithoutSeconds() { - var result = testExecutor.Execute("query { test: positiveWithoutSeconds }"); - Assert.Equal("2959:53:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: positiveWithoutSeconds }"); + Assert.Equal("2959:53:00", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsSerializedDataWithoutMinutes() { - var result = testExecutor.Execute("query { test: positiveWithoutMinutes }"); - Assert.Equal("2959:00:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: positiveWithoutMinutes }"); + Assert.Equal("2959:00:00", Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsSerializedDataWithRoundtrip() { - var result = testExecutor.Execute("query { test: positiveWithRoundtrip }"); - Assert.Equal("2978:01:10", Assert.IsType(result).Data!["test"]); + var result = _testExecutor.Execute("query { test: positiveWithRoundtrip }"); + Assert.Equal("2978:01:10", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesInputWithDecimals() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "238:01:00.019") - .Create()); - Assert.Equal("238:11:00.019", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "238:01:00.019" }, }) + .Build()); + Assert.Equal("238:11:00.019", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesInputWithoutDecimals() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "238:01:00") - .Create()); - Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "238:01:00" }, }) + .Build()); + Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesInputWithoutLeadingZero() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "238:01:00") - .Create()); - Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "238:01:00" }, }) + .Build()); + Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesInputWithNegativeValue() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "-238:01:00") - .Create()); - Assert.Equal("-237:51:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "-238:01:00" }, }) + .Build()); + Assert.Equal("-237:51:00", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationDoesntParseInputWithPlusSign() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "+09:22:01:00") - .Create()); - Assert.Null(Assert.IsType(result).Data); - Assert.Equal(1, Assert.IsType(result).Errors!.Count); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "+09:22:01:00" }, }) + .Build()); + Assert.Null(Assert.IsType(result).Data); + Assert.Equal(1, Assert.IsType(result).Errors!.Count); } [Fact] public void MutationParsesLiteralWithDecimals() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"238:01:00.019\") }") - .Create()); - Assert.Equal("238:11:00.019", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"238:01:00.019\") }") + .Build()); + Assert.Equal("238:11:00.019", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesLiteralWithoutDecimals() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"238:01:00\") }") - .Create()); - Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"238:01:00\") }") + .Build()); + Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesLiteralWithoutLeadingZero() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"238:01:00\") }") - .Create()); - Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"238:01:00\") }") + .Build()); + Assert.Equal("238:11:00", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationParsesLiteralWithNegativeValue() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"-238:01:00\") }") - .Create()); - Assert.Equal("-237:51:00", Assert.IsType(result).Data!["test"]); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"-238:01:00\") }") + .Build()); + Assert.Equal("-237:51:00", Assert.IsType(result).Data!["test"]); } [Fact] public void MutationDoesntParseLiteralWithPlusSign() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+238:01:00\") }") - .Create()); - Assert.Null(Assert.IsType(result).Data); - Assert.Equal(1, Assert.IsType(result).Errors!.Count); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+238:01:00\") }") + .Build()); + Assert.Null(Assert.IsType(result).Data); + Assert.Equal(1, Assert.IsType(result).Errors!.Count); } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs index fe8c288738d..2bcabf03ee3 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -32,17 +33,12 @@ public Duration Test(Duration arg) } } - private readonly IRequestExecutor _testExecutor; - - public DurationTypeIntegrationTests() - { - _testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime() - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime() + .Create() + .MakeExecutable(); [Fact] public void QueryReturnsSerializedDataWithDecimals() @@ -90,10 +86,10 @@ public void QueryReturnsSerializedDataWithRoundtrip() public void MutationParsesInputWithDecimals() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "09:22:01:00.019") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "09:22:01:00.019" }, }) + .Build()); Assert.Equal("9:22:11:00.019", result.ExpectQueryResult().Data!["test"]); } @@ -101,10 +97,10 @@ public void MutationParsesInputWithDecimals() public void MutationParsesInputWithoutDecimals() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "09:22:01:00") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "09:22:01:00" }, }) + .Build()); Assert.Equal("9:22:11:00", result.ExpectQueryResult().Data!["test"]); } @@ -112,10 +108,10 @@ public void MutationParsesInputWithoutDecimals() public void MutationParsesInputWithoutLeadingZero() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "9:22:01:00") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "9:22:01:00" }, }) + .Build()); Assert.Equal("9:22:11:00", result.ExpectQueryResult().Data!["test"]); } @@ -123,10 +119,10 @@ public void MutationParsesInputWithoutLeadingZero() public void MutationParsesInputWithNegativeValue() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "-9:22:01:00") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "-9:22:01:00" }, }) + .Build()); Assert.Equal("-9:21:51:00", result.ExpectQueryResult().Data!["test"]); } @@ -134,10 +130,10 @@ public void MutationParsesInputWithNegativeValue() public void MutationDoesntParseInputWithPlusSign() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "+09:22:01:00") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "+09:22:01:00" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -146,10 +142,10 @@ public void MutationDoesntParseInputWithPlusSign() public void MutationDoesntParseInputWithOverflownHours() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValue("arg", "9:26:01:00") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "9:26:01:00" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -158,9 +154,9 @@ public void MutationDoesntParseInputWithOverflownHours() public void MutationParsesLiteralWithDecimals() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"09:22:01:00.019\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"09:22:01:00.019\") }") + .Build()); Assert.Equal("9:22:11:00.019", result.ExpectQueryResult().Data!["test"]); } @@ -169,9 +165,9 @@ public void MutationParsesLiteralWithDecimals() public void MutationParsesLiteralWithoutDecimals() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"09:22:01:00\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"09:22:01:00\") }") + .Build()); Assert.Equal("9:22:11:00", result.ExpectQueryResult().Data!["test"]); } @@ -180,9 +176,9 @@ public void MutationParsesLiteralWithoutDecimals() public void MutationParsesLiteralWithoutLeadingZero() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"09:22:01:00\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"09:22:01:00\") }") + .Build()); Assert.Equal("9:22:11:00", result.ExpectQueryResult().Data!["test"]); } @@ -191,9 +187,9 @@ public void MutationParsesLiteralWithoutLeadingZero() public void MutationParsesLiteralWithNegativeValue() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"-9:22:01:00\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"-9:22:01:00\") }") + .Build()); Assert.Equal("-9:21:51:00", result.ExpectQueryResult().Data!["test"]); } @@ -202,9 +198,9 @@ public void MutationParsesLiteralWithNegativeValue() public void MutationDoesntParseLiteralWithPlusSign() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+09:22:01:00\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+09:22:01:00\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -214,9 +210,9 @@ public void MutationDoesntParseLiteralWithPlusSign() public void MutationDoesntParseLiteralWithOverflownHours() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"9:26:01:00\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"9:26:01:00\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeDateTimeOffsetIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeDateTimeOffsetIntegrationTests.cs index b05460e6936..fce97f869ee 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeDateTimeOffsetIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeDateTimeOffsetIntegrationTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Text; using HotChocolate.Execution; @@ -35,24 +36,19 @@ public StringBuilder AppendFormat(Instant value, StringBuilder builder) } } - private readonly IRequestExecutor testExecutor; - - public InstantTypeDateTimeOffsetIntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime(typeof(InstantType)) - .AddType( - new InstantType(InstantPattern.ExtendedIso, new InstantDateTimeOffsetPattern())) - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime(typeof(InstantType)) + .AddType( + new InstantType(InstantPattern.ExtendedIso, new InstantDateTimeOffsetPattern())) + .Create() + .MakeExecutable(); [Fact] public void QueryReturnsUtc() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal( "2020-02-20T17:42:59.000001234Z", @@ -62,11 +58,11 @@ public void QueryReturnsUtc() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21T17:42:59.000001234Z") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-21T17:42:59.000001234Z" }, }) + .Build()); Assert.Equal( "2020-02-21T17:52:59.000001234Z", @@ -76,11 +72,11 @@ public void ParsesVariable() [Fact] public void DoesParseAnIncorrectExtendedVariableAsDateTimeOffset() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59" }, }) + .Build()); Assert.Equal("2020-02-20T17:52:59Z", result.ExpectQueryResult().Data!["test"]); } @@ -88,10 +84,10 @@ public void DoesParseAnIncorrectExtendedVariableAsDateTimeOffset() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") + .Build()); Assert.Equal( "2020-02-20T17:52:59.000001234Z", @@ -101,10 +97,10 @@ public void ParsesLiteral() [Fact] public void DoesParseIncorrectExtendedLiteralAsDateTimeOffset() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Equal("2020-02-20T17:52:59Z", result.ExpectQueryResult().Data!["test"]); } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeGeneralIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeGeneralIntegrationTests.cs index 6f82496b625..a6b052067e1 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeGeneralIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeGeneralIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using HotChocolate.Execution; using NodaTime.Text; @@ -6,23 +7,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class InstantTypeGeneralIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public InstantTypeGeneralIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(InstantType)) .AddType(new InstantType(InstantPattern.General)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturnsUtc() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal("2020-02-20T17:42:59Z", result.ExpectQueryResult().Data!["test"]); } @@ -30,11 +27,11 @@ public void QueryReturnsUtc() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21T17:42:59Z") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-21T17:42:59Z" }, }) + .Build()); Assert.Equal("2020-02-21T17:52:59Z", result.ExpectQueryResult().Data!["test"]); } @@ -42,11 +39,11 @@ public void ParsesVariable() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -55,10 +52,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59Z\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59Z\") }") + .Build()); Assert.Equal("2020-02-20T17:52:59Z", result.ExpectQueryResult().Data!["test"]); } @@ -66,10 +63,10 @@ public void ParsesLiteral() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs index 2d6a0ef80e2..8773058ba1f 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -11,7 +12,7 @@ public static class Schema { public class Query { - public Instant One + public Instant One => Instant.FromUtc(2020, 02, 20, 17, 42, 59).PlusNanoseconds(1234); } @@ -24,50 +25,45 @@ public Instant Test(Instant arg) } } - private readonly IRequestExecutor testExecutor; - - public InstantTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime() - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime() + .Create() + .MakeExecutable(); [Fact] public void QueryReturnsUtc() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal( - "2020-02-20T17:42:59.000001234Z", + "2020-02-20T17:42:59.000001234Z", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21T17:42:59.000001234Z") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-21T17:42:59.000001234Z" }, }) + .Build()); Assert.Equal( - "2020-02-21T17:52:59.000001234Z", + "2020-02-21T17:52:59.000001234Z", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -76,23 +72,23 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") + .Build()); Assert.Equal( - "2020-02-20T17:52:59.000001234Z", + "2020-02-20T17:52:59.000001234Z", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/IsoDayOfWeekTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/IsoDayOfWeekTypeTests.cs index 6b5bc30371e..e2018e8291d 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/IsoDayOfWeekTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/IsoDayOfWeekTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; @@ -27,47 +28,43 @@ public IsoDayOfWeek Test(IsoDayOfWeek arg) } } - private readonly IRequestExecutor testExecutor; - - public IsoDayOfWeekTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturnsMonday() { - var result = testExecutor.Execute("query { test: monday }"); - + var result = _testExecutor.Execute("query { test: monday }"); + Assert.Equal(1, result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryReturnsSunday() { - var result = testExecutor.Execute("query { test: sunday }"); - + var result = _testExecutor.Execute("query { test: sunday }"); + Assert.Equal(7, result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryReturnsFriday() { - var result = testExecutor.Execute("query { test: friday }"); - + var result = _testExecutor.Execute("query { test: friday }"); + Assert.Equal(5, result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryDoesntReturnNone() { - var result = testExecutor.Execute("query { test: none }"); - + var result = _testExecutor.Execute("query { test: none }"); + Assert.Null(result.ExpectQueryResult().Data); Assert.NotEmpty(result.ExpectQueryResult().Errors); } @@ -75,36 +72,36 @@ public void QueryDoesntReturnNone() [Fact] public void MutationParsesMonday() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") - .SetVariableValue("arg", 1) - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", 1 }, }) + .Build()); + Assert.Equal(2, result.ExpectQueryResult().Data!["test"]); } [Fact] public void MutationParsesSunday() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") - .SetVariableValue("arg", 7) - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", 7 }, }) + .Build()); + Assert.Equal(1, result.ExpectQueryResult().Data!["test"]); } [Fact] public void MutationDoesntParseZero() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") - .SetVariableValue("arg", 0) - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", 0 }, }) + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -112,12 +109,12 @@ public void MutationDoesntParseZero() [Fact] public void MutationDoesntParseEight() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") - .SetVariableValue("arg", 8) - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", 8 }, }) + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -125,12 +122,12 @@ public void MutationDoesntParseEight() [Fact] public void MutationDoesntParseNegativeNumbers() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") - .SetVariableValue("arg", -2) - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: IsoDayOfWeek!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", -2 }, }) + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeFullRoundtripIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeFullRoundtripIntegrationTests.cs index 0ab1f0f3a60..7b0ed905a0e 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeFullRoundtripIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeFullRoundtripIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,23 +6,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class LocalDateTimeTypeFullRoundtripIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public LocalDateTimeTypeFullRoundtripIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(LocalDateTimeType)) .AddType(new LocalDateTimeType(LocalDateTimePattern.FullRoundtrip)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal( "2020-02-07T17:42:59.000001234 (Julian)", @@ -31,11 +28,11 @@ public void QueryReturns() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21T17:42:59.000001234 (Julian)") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-21T17:42:59.000001234 (Julian)" }, }) + .Build()); Assert.Equal( "2020-02-21T17:52:59.000001234 (Julian)", @@ -45,11 +42,11 @@ public void ParsesVariable() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59Z") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59Z" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -58,10 +55,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59.000001234 (Julian)\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234 (Julian)\") }") + .Build()); Assert.Equal( "2020-02-20T17:52:59.000001234 (Julian)", @@ -71,10 +68,10 @@ public void ParsesLiteral() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59Z\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59Z\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeGeneralIsoIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeGeneralIsoIntegrationTests.cs index 35b64c2f063..cb768681a34 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeGeneralIsoIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeGeneralIsoIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,23 +6,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class LocalDateTimeTypeGeneralIsoIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public LocalDateTimeTypeGeneralIsoIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(LocalDateTimeType)) .AddType(new LocalDateTimeType(LocalDateTimePattern.GeneralIso)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal("2020-02-07T17:42:59", result.ExpectQueryResult().Data!["test"]); } @@ -29,11 +26,11 @@ public void QueryReturns() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21T17:42:59") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-21T17:42:59" }, }) + .Build()); Assert.Equal("2020-02-21T17:52:59", result.ExpectQueryResult().Data!["test"]); } @@ -41,11 +38,11 @@ public void ParsesVariable() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59Z") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59Z" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -54,10 +51,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Equal("2020-02-20T17:52:59", result.ExpectQueryResult().Data!["test"]); } @@ -65,10 +62,10 @@ public void ParsesLiteral() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59Z\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59Z\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs index e5c1615126e..aee9c21abb3 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs @@ -1,5 +1,5 @@ - using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -14,9 +14,9 @@ public class Query { public LocalDateTime One => LocalDateTime.FromDateTime( - new DateTime(2020, 02, 20, 17, 42, 59)) - .PlusNanoseconds(1234) - .WithCalendar(CalendarSystem.Julian); + new DateTime(2020, 02, 20, 17, 42, 59)) + .PlusNanoseconds(1234) + .WithCalendar(CalendarSystem.Julian); } public class Mutation @@ -28,17 +28,13 @@ public LocalDateTime Test(LocalDateTime arg) } } - private readonly IRequestExecutor _testExecutor; - - public LocalDateTimeTypeIntegrationTests() - { - _testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() @@ -52,10 +48,12 @@ public void QueryReturns() public void ParsesVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21T17:42:59.000001234") - .Create()); + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary { { "arg", "2020-02-21T17:42:59.000001234" }, }) + .Build()); Assert.Equal("2020-02-21T17:52:59.000001234", result.ExpectQueryResult().Data!["test"]); } @@ -64,10 +62,12 @@ public void ParsesVariable() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59.000001234Z") - .Create()); + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary { { "arg", "2020-02-20T17:42:59.000001234Z" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -77,9 +77,10 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59.000001234\") }") - .Create()); + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234\") }") + .Build()); Assert.Equal("2020-02-20T17:52:59.000001234", result.ExpectQueryResult().Data!["test"]); } @@ -88,9 +89,10 @@ public void ParsesLiteral() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") - .Create()); + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeFullRoundtripIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeFullRoundtripIntegrationTests.cs index e13d8f69c33..685d57e4081 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeFullRoundtripIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeFullRoundtripIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,48 +6,47 @@ namespace HotChocolate.Types.NodaTime.Tests { public class LocalDateTypeFullRoundtripIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public LocalDateTypeFullRoundtripIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(LocalDateType)) .AddType(new LocalDateType(LocalDatePattern.FullRoundtrip)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); - + var result = _testExecutor.Execute("query { test: one }"); + Assert.Equal("5780-05-25 (Hebrew Civil)", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21 (Hebrew Civil)") - .Create()); - + IExecutionResult? result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-02-21 (Hebrew Civil)" }, }) + .Build()); + Assert.Equal("2020-02-24 (Hebrew Civil)", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59 (Hebrew Civil)") - .Create()); - + IExecutionResult? result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary { { "arg", "2020-02-20T17:42:59 (Hebrew Civil)" }, }) + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -54,22 +54,24 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20 (Hebrew Civil)\") }") - .Create()); - + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20 (Hebrew Civil)\") }") + .Build()); + Assert.Equal("2020-02-23 (Hebrew Civil)", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59 (Hebrew Civil)\") }") - .Create()); - + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59 (Hebrew Civil)\") }") + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs index a5902927d73..59e785211d9 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -25,22 +26,18 @@ public LocalDate Test(LocalDate arg) } } - private readonly IRequestExecutor testExecutor; - - public LocalDateTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal("5780-05-25", result.ExpectQueryResult().Data!["test"]); } @@ -48,11 +45,11 @@ public void QueryReturns() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-21") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-21" }, }) + .Build()); Assert.Equal("2020-02-24", result.ExpectQueryResult().Data!["test"]); } @@ -60,11 +57,11 @@ public void ParsesVariable() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-02-20T17:42:59") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -73,10 +70,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20\") }") + .Build()); Assert.Equal("2020-02-23", result.ExpectQueryResult().Data!["test"]); } @@ -84,10 +81,10 @@ public void ParsesLiteral() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeGeneralIsoIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeGeneralIsoIntegrationTests.cs index bbeeff8d36a..a93ea5d8a41 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeGeneralIsoIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeGeneralIsoIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,47 +6,44 @@ namespace HotChocolate.Types.NodaTime.Tests { public class LocalTimeTypeGeneralIsoIntegrationTests { - private readonly IRequestExecutor testExecutor; - public LocalTimeTypeGeneralIsoIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(LocalTimeType)) .AddType(new LocalTimeType(LocalTimePattern.GeneralIso)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); - + var result = _testExecutor.Execute("query { test: one }"); + Assert.Equal("12:42:13", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "12:42:13") - .Create()); - + IExecutionResult? result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "12:42:13" }, }) + .Build()); + Assert.Equal("12:52:13", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "12:42") - .Create()); - + IExecutionResult? result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "12:42" }, }) + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -53,22 +51,22 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"12:42:13\") }") - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"12:42:13\") }") + .Build()); + Assert.Equal("12:52:13", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"12:42\") }") - .Create()); - + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"12:42\") }") + .Build()); + Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs index d7a9d505501..ffd71eda0f3 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -25,22 +26,18 @@ public LocalTime Test(LocalTime arg) } } - private readonly IRequestExecutor testExecutor; - - public LocalTimeTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal("12:42:13.031011234", result.ExpectQueryResult().Data!["test"]); } @@ -48,11 +45,12 @@ public void QueryReturns() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "12:42:13.031011234") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "12:42:13.031011234" }, }) + .Build()); Assert.Equal("12:52:13.031011234", result.ExpectQueryResult().Data!["test"]); } @@ -60,11 +58,12 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithoutTicks() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "12:42:13") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "12:42:13" }, }) + .Build()); Assert.Equal("12:52:13", result.ExpectQueryResult().Data!["test"]); } @@ -72,11 +71,12 @@ public void ParsesVariableWithoutTicks() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "12:42") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "12:42" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -85,10 +85,11 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"12:42:13.031011234\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"12:42:13.031011234\") }") + .Build()); Assert.Equal("12:52:13.031011234", result.ExpectQueryResult().Data!["test"]); } @@ -96,10 +97,11 @@ public void ParsesLiteral() [Fact] public void ParsesLiteralWithoutTick() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"12:42:13\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"12:42:13\") }") + .Build()); Assert.Equal("12:52:13", result.ExpectQueryResult().Data!["test"]); } @@ -107,10 +109,11 @@ public void ParsesLiteralWithoutTick() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"12:42\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"12:42\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -121,7 +124,7 @@ public void DoesntParseIncorrectLiteral() } [Fact] - public void PatternEmpty_ThrowSchemaException() + public void PatternEmptyThrowSchemaException() { static object Call() => new LocalTimeType(Array.Empty>()); Assert.Throws(Call); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/NodaTimeRequestExecutorBuilderExtensions.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/NodaTimeRequestExecutorBuilderExtensions.cs index 84cff437e2c..377f91c3544 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/NodaTimeRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/NodaTimeRequestExecutorBuilderExtensions.cs @@ -10,7 +10,7 @@ public static ISchemaBuilder AddNodaTime( this ISchemaBuilder schemaBuilder, params Type[] excludeTypes) { - foreach (var type in nodaTimeTypes.Except(excludeTypes)) + foreach (var type in _nodaTimeTypes.Except(excludeTypes)) { schemaBuilder = schemaBuilder.AddType(type); } @@ -18,7 +18,7 @@ public static ISchemaBuilder AddNodaTime( return schemaBuilder; } - private static readonly IReadOnlyList nodaTimeTypes = new[] + private static readonly IReadOnlyList _nodaTimeTypes = new[] { typeof(DateTimeZoneType), typeof(DurationType), typeof(InstantType), typeof(IsoDayOfWeekType), typeof(LocalDateTimeType), typeof(LocalDateType), diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeExtendedIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeExtendedIntegrationTests.cs index 810ca8e3636..9a528cd77f5 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeExtendedIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeExtendedIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,23 +6,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetDateTimeTypeExtendedIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public OffsetDateTimeTypeExtendedIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(OffsetDateTimeType)) .AddType(new OffsetDateTimeType(OffsetDateTimePattern.ExtendedIso)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("2020-12-31T18:30:13.000001234+02", result.ExpectQueryResult().Data!["test"]); } @@ -29,7 +26,7 @@ public void QueryReturns() [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("2020-12-31T18:30:13.000001234+02:30", result.ExpectQueryResult().Data!["test"]); } @@ -37,11 +34,12 @@ public void QueryReturnsWithMinutes() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13+02" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -49,11 +47,12 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02:35") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13+02:35" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -61,11 +60,12 @@ public void ParsesVariableWithMinutes() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -74,10 +74,11 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -85,10 +86,11 @@ public void ParsesLiteral() [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -96,10 +98,11 @@ public void ParsesLiteralWithMinutes() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeGeneralIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeGeneralIntegrationTests.cs index e7dc5dd385f..1531e1588c6 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeGeneralIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeGeneralIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,63 +6,59 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetDateTimeTypeGeneralIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public OffsetDateTimeTypeGeneralIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(OffsetDateTimeType)) .AddType(new OffsetDateTimeType(OffsetDateTimePattern.GeneralIso)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("2020-12-31T18:30:13+02", result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("2020-12-31T18:30:13+02:30", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T18:30:13+02" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02:35") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T18:30:13+02:35" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T18:30:13" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -69,30 +66,30 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeRfc3339IntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeRfc3339IntegrationTests.cs index 70c23628d54..dd985cb0206 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeRfc3339IntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeRfc3339IntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,23 +6,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetDateTimeTypeRfc3339IntegrationTests { - private readonly IRequestExecutor testExecutor; - - public OffsetDateTimeTypeRfc3339IntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(OffsetDateTimeType)) .AddType(new OffsetDateTimeType(OffsetDateTimePattern.Rfc3339)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal( "2020-12-31T18:30:13.000001234+02:00", @@ -31,7 +28,7 @@ public void QueryReturns() [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal( "2020-12-31T18:30:13.000001234+02:30", @@ -41,11 +38,11 @@ public void QueryReturnsWithMinutes() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13.000001234+02:00") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T18:30:13.000001234+02:00" }, }) + .Build()); Assert.Equal( "2020-12-31T18:40:13.000001234+02:00", @@ -55,11 +52,11 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02:35") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T18:30:13+02:35" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -67,11 +64,11 @@ public void ParsesVariableWithMinutes() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T18:30:13" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -80,10 +77,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13.000001234+02:00\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13.000001234+02:00\") }") + .Build()); Assert.Equal( "2020-12-31T18:40:13.000001234+02:00", @@ -93,10 +90,10 @@ public void ParsesLiteral() [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -104,10 +101,10 @@ public void ParsesLiteralWithMinutes() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs index 967f00355f0..d64c2e592e3 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -47,22 +48,18 @@ public OffsetDateTime Test(OffsetDateTime arg) } } - private readonly IRequestExecutor testExecutor; - - public OffsetDateTimeTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("2020-12-31T18:30:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -70,7 +67,7 @@ public void QueryReturns() [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("2020-12-31T18:30:13+02:30", result.ExpectQueryResult().Data!["test"]); } @@ -78,11 +75,12 @@ public void QueryReturnsWithMinutes() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13+02" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -90,11 +88,12 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13+02:35") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13+02:35" }, }) + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -102,11 +101,12 @@ public void ParsesVariableWithMinutes() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T18:30:13") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -115,10 +115,11 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -126,10 +127,11 @@ public void ParsesLiteral() [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13+02:35\") }") + .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -137,21 +139,22 @@ public void ParsesLiteralWithMinutes() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T18:30:13\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T18:30:13\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); Assert.Equal( - "Unable to deserialize string to OffsetDateTime", + "Unable to deserialize string to OffsetDateTime", result.ExpectQueryResult().Errors![0].Message); } [Fact] - public void PatternEmpty_ThrowSchemaException() + public void PatternEmptyThrowSchemaException() { static object Call() => new OffsetDateTimeType(Array.Empty>()); Assert.Throws(Call); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeFullRoundtripIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeFullRoundtripIntegrationTests.cs index e6a92ad6ad6..36c5e7bbf22 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeFullRoundtripIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeFullRoundtripIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,23 +6,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetDateTypeFullRoundtripIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public OffsetDateTypeFullRoundtripIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(OffsetDateType)) .AddType(new OffsetDateType(OffsetDatePattern.FullRoundtrip)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("2020-12-31+02 (Gregorian)", result.ExpectQueryResult()!.Data!["test"]); } @@ -29,7 +26,7 @@ public void QueryReturns() [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("2020-12-31+02:35 (Gregorian)", result.ExpectQueryResult()!.Data!["test"]); } @@ -37,11 +34,11 @@ public void QueryReturnsWithMinutes() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31+02 (Gregorian)") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31+02 (Gregorian)" }, }) + .Build()); Assert.Equal("2020-12-31+02 (Gregorian)", result.ExpectQueryResult()!.Data!["test"]); } @@ -49,11 +46,11 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31+02:35 (Gregorian)") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31+02:35 (Gregorian)" }, }) + .Build()); Assert.Equal("2020-12-31+02:35 (Gregorian)", result.ExpectQueryResult()!.Data!["test"]); } @@ -61,11 +58,11 @@ public void ParsesVariableWithMinutes() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31 (Gregorian)") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31 (Gregorian)" }, }) + .Build()); Assert.Null(result.ExpectQueryResult()!.Data); Assert.Equal(1, result.ExpectQueryResult()!.Errors!.Count); @@ -74,10 +71,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31+02 (Gregorian)\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31+02 (Gregorian)\") }") + .Build()); Assert.Equal("2020-12-31+02 (Gregorian)", result.ExpectQueryResult()!.Data!["test"]); } @@ -85,10 +82,10 @@ public void ParsesLiteral() [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31+02:35 (Gregorian)\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31+02:35 (Gregorian)\") }") + .Build()); Assert.Equal("2020-12-31+02:35 (Gregorian)", result.ExpectQueryResult()!.Data!["test"]); } @@ -96,10 +93,10 @@ public void ParsesLiteralWithMinutes() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31 (Gregorian)\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31 (Gregorian)\") }") + .Build()); Assert.Null(result.ExpectQueryResult()!.Data); Assert.Equal(1, result.ExpectQueryResult()!.Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs index 9f3d061b401..d208d317472 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -11,7 +12,7 @@ public static class Schema { public class Query { - public OffsetDate Hours + public OffsetDate Hours => new OffsetDate( LocalDate.FromDateTime(new DateTime(2020, 12, 31, 18, 30, 13)), Offset.FromHours(2)).WithCalendar(CalendarSystem.Gregorian); @@ -28,17 +29,13 @@ public class Mutation } } - private readonly IRequestExecutor _testExecutor; - - public OffsetDateTypeIntegrationTests() - { - _testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() @@ -58,10 +55,10 @@ public void QueryReturnsWithMinutes() public void ParsesVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31+02") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31+02" }, }) + .Build()); Assert.Equal("2020-12-31+02", result.ExpectQueryResult().Data!["test"]); } @@ -69,10 +66,10 @@ public void ParsesVariable() public void ParsesVariableWithMinutes() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31+02:35") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31+02:35" }, }) + .Build()); Assert.Equal("2020-12-31+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -80,10 +77,10 @@ public void ParsesVariableWithMinutes() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -92,9 +89,9 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31+02\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31+02\") }") + .Build()); Assert.Equal("2020-12-31+02", result.ExpectQueryResult().Data!["test"]); } @@ -102,9 +99,9 @@ public void ParsesLiteral() public void ParsesLiteralWithMinutes() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31+02:35\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31+02:35\") }") + .Build()); Assert.Equal("2020-12-31+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -112,9 +109,9 @@ public void ParsesLiteralWithMinutes() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); @@ -124,7 +121,7 @@ public void DoesntParseIncorrectLiteral() } [Fact] - public void PatternEmpty_ThrowSchemaException() + public void PatternEmptyThrowSchemaException() { static object Call() => new OffsetDateType(Array.Empty>()); Assert.Throws(Call); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeExtendedIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeExtendedIntegrationTests.cs index cd6c307c82a..ebc97c19ff9 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeExtendedIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeExtendedIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,23 +6,19 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetTimeTypeExtendedIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public OffsetTimeTypeExtendedIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(OffsetTimeType)) .AddType(new OffsetTimeType(OffsetTimePattern.ExtendedIso)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("18:30:13.010011234+02", result.ExpectQueryResult().Data!["test"]); } @@ -29,7 +26,7 @@ public void QueryReturns() [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("18:30:13.010011234+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -37,11 +34,11 @@ public void QueryReturnsWithMinutes() [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13.010011234+02") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13.010011234+02" }, }) + .Build()); Assert.Equal("18:30:13.010011234+02", result.ExpectQueryResult().Data!["test"]); } @@ -49,11 +46,11 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13.010011234+02:35") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13.010011234+02:35" }, }) + .Build()); Assert.Equal("18:30:13.010011234+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -61,11 +58,11 @@ public void ParsesVariableWithMinutes() [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13.010011234") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13.010011234" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -74,10 +71,10 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13.010011234+02\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13.010011234+02\") }") + .Build()); Assert.Equal("18:30:13.010011234+02", result.ExpectQueryResult().Data!["test"]); } @@ -85,10 +82,10 @@ public void ParsesLiteral() [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13.010011234+02:35\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13.010011234+02:35\") }") + .Build()); Assert.Equal("18:30:13.010011234+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -96,10 +93,10 @@ public void ParsesLiteralWithMinutes() [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13.010011234\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13.010011234\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeRfc3339IntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeRfc3339IntegrationTests.cs index cd187a6a068..0da09b28956 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeRfc3339IntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeRfc3339IntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,41 +6,36 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetTimeTypeRfc3339IntegrationTests { - private readonly IRequestExecutor testExecutor; - - public OffsetTimeTypeRfc3339IntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime(typeof(OffsetTimeType)) - .AddType(new OffsetTimeType(OffsetTimePattern.Rfc3339)) - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime(typeof(OffsetTimeType)) + .AddType(new OffsetTimeType(OffsetTimePattern.Rfc3339)) + .Create() + .MakeExecutable(); [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("18:30:13.010011234+02:00", result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("18:30:13.010011234+02:35", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13.010011234+02:00") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13.010011234+02:00" }, }) + .Build()); Assert.Equal("18:30:13.010011234+02:00", result.ExpectQueryResult().Data!["test"]); } @@ -47,22 +43,22 @@ public void ParsesVariable() [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13.010011234+02:35") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13.010011234+02:35" }, }) + .Build()); Assert.Equal("18:30:13.010011234+02:35", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13.010011234+02") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13.010011234+02" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -70,30 +66,30 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13.010011234+02:00\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13.010011234+02:00\") }") + .Build()); Assert.Equal("18:30:13.010011234+02:00", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13.010011234+02:35\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13.010011234+02:35\") }") + .Build()); Assert.Equal("18:30:13.010011234+02:35", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13.010011234+02\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13.010011234+02\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs index f1666015973..3c3e42a0487 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -32,17 +33,13 @@ public class Mutation } } - private readonly IRequestExecutor _testExecutor; - - public OffsetTimeTypeIntegrationTests() - { - _testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() @@ -62,10 +59,10 @@ public void QueryReturnsWithMinutes() public void ParsesVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13+02") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13+02" }, }) + .Build()); Assert.Equal("18:30:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -73,10 +70,10 @@ public void ParsesVariable() public void ParsesVariableWithMinutes() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13+02:35") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13+02:35" }, }) + .Build()); Assert.Equal("18:30:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -84,10 +81,10 @@ public void ParsesVariableWithMinutes() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -96,9 +93,9 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13+02\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13+02\") }") + .Build()); Assert.Equal("18:30:13+02", result.ExpectQueryResult().Data!["test"]); } @@ -106,9 +103,9 @@ public void ParsesLiteral() public void ParsesLiteralWithMinutes() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13+02:35\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13+02:35\") }") + .Build()); Assert.Equal("18:30:13+02:35", result.ExpectQueryResult().Data!["test"]); } @@ -116,9 +113,9 @@ public void ParsesLiteralWithMinutes() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -129,7 +126,7 @@ public void DoesntParseIncorrectLiteral() } [Fact] - public void PatternEmpty_ThrowSchemaException() + public void PatternEmptyThrowSchemaException() { static object Call() => new OffsetTimeType(Array.Empty>()); Assert.Throws(Call); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeGeneralInvariantWithoutZIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeGeneralInvariantWithoutZIntegrationTests.cs index 35091db71be..371d00bc47b 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeGeneralInvariantWithoutZIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeGeneralInvariantWithoutZIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,18 +6,14 @@ namespace HotChocolate.Types.NodaTime.Tests { public class OffsetTypeGeneralInvariantWithoutZIntegrationTests { - private readonly IRequestExecutor _testExecutor; - - public OffsetTypeGeneralInvariantWithoutZIntegrationTests() - { - _testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime(typeof(OffsetType)) .AddType(new OffsetType(OffsetPattern.GeneralInvariant)) .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() @@ -43,10 +40,10 @@ public void QueryReturnsWithZ() public void ParsesVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValue("arg", "+02") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "+02" }, }) + .Build()); Assert.Equal("+03:05", result.ExpectQueryResult().Data!["test"]); } @@ -54,10 +51,10 @@ public void ParsesVariable() public void ParsesVariableWithMinutes() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValue("arg", "+02:35") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "+02:35" }, }) + .Build()); Assert.Equal("+03:40", result.ExpectQueryResult().Data!["test"]); } @@ -65,10 +62,10 @@ public void ParsesVariableWithMinutes() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13+02") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13+02" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -77,9 +74,9 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+02\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+02\") }") + .Build()); Assert.Equal("+03:05", result.ExpectQueryResult().Data!["test"]); } @@ -88,9 +85,9 @@ public void ParsesLiteral() public void ParsesLiteralWithMinutes() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+02:35\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+02:35\") }") + .Build()); Assert.Equal("+03:40", result.ExpectQueryResult().Data!["test"]); } @@ -98,9 +95,9 @@ public void ParsesLiteralWithMinutes() public void ParsesLiteralWithZero() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+00\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+00\") }") + .Build()); Assert.Equal("+01:05", result.ExpectQueryResult().Data!["test"]); } @@ -108,9 +105,9 @@ public void ParsesLiteralWithZero() public void DoesntParseLiteralWithZ() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"Z\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"Z\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); @@ -123,9 +120,9 @@ public void DoesntParseLiteralWithZ() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13+02\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13+02\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs index 55118b0874b..f7d80857d3e 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -23,69 +24,64 @@ public Offset Test(Offset arg) } } - private readonly IRequestExecutor testExecutor; - - public OffsetTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime() - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime() + .Create() + .MakeExecutable(); [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: hours }"); + var result = _testExecutor.Execute("query { test: hours }"); Assert.Equal("+02", result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryReturnsWithMinutes() { - var result = testExecutor.Execute("query { test: hoursAndMinutes }"); + var result = _testExecutor.Execute("query { test: hoursAndMinutes }"); Assert.Equal("+02:35", result.ExpectQueryResult().Data!["test"]); } [Fact] public void QueryReturnsWithZ() { - var result = testExecutor.Execute("query { test: zOffset }"); + var result = _testExecutor.Execute("query { test: zOffset }"); Assert.Equal("Z", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValue("arg", "+02") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "+02" }, }) + .Build()); Assert.Equal("+03:05", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariableWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValue("arg", "+02:35") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "+02:35" }, }) + .Build()); Assert.Equal("+03:40", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValue("arg", "18:30:13+02") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "18:30:13+02" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -93,50 +89,50 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+02\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+02\") }") + .Build()); Assert.Equal("+03:05", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesLiteralWithMinutes() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"+02:35\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"+02:35\") }") + .Build()); Assert.Equal("+03:40", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesLiteralWithZ() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"Z\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"Z\") }") + .Build()); Assert.Equal("+01:05", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"18:30:13+02\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"18:30:13+02\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); Assert.Equal( - "Unable to deserialize string to Offset", + "Unable to deserialize string to Offset", result.ExpectQueryResult().Errors![0].Message); } [Fact] - public void PatternEmpty_ThrowSchemaException() + public void PatternEmptyThrowSchemaException() { static object Call() => new OffsetType(Array.Empty>()); Assert.Throws(Call); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeNormalizingIsoIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeNormalizingIsoIntegrationTests.cs index f20e9ab6e03..5e58e221a03 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeNormalizingIsoIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeNormalizingIsoIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime.Text; @@ -5,45 +6,40 @@ namespace HotChocolate.Types.NodaTime.Tests { public class PeriodTypeNormalizingIsoIntegrationTests { - private readonly IRequestExecutor testExecutor; - - public PeriodTypeNormalizingIsoIntegrationTests() - { - testExecutor = SchemaBuilder.New() - .AddQueryType() - .AddMutationType() - .AddNodaTime(typeof(PeriodType)) - .AddType(new PeriodType(PeriodPattern.NormalizingIso)) - .Create() - .MakeExecutable(); - } + private readonly IRequestExecutor _testExecutor = SchemaBuilder.New() + .AddQueryType() + .AddMutationType() + .AddNodaTime(typeof(PeriodType)) + .AddType(new PeriodType(PeriodPattern.NormalizingIso)) + .Create() + .MakeExecutable(); [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal("P-17DT-23H-59M-59.9999861S", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Period!) { test(arg: $arg) }") - .SetVariableValue("arg", "P-17DT-23H-59M-59.9999861S") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Period!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "P-17DT-23H-59M-59.9999861S" }, }) + .Build()); Assert.Equal("P-18DT-9M-59.9999861S", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Period!) { test(arg: $arg) }") - .SetVariableValue("arg", "-P-17DT-23H-59M-59.9999861S") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Period!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "-P-17DT-23H-59M-59.9999861S" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -51,20 +47,20 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"P-17DT-23H-59M-59.9999861S\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"P-17DT-23H-59M-59.9999861S\") }") + .Build()); Assert.Equal("P-18DT-9M-59.9999861S", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"-P-17DT-23H-59M-59.9999861S\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"-P-17DT-23H-59M-59.9999861S\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeTests.cs index 1c3dfdaec42..609f8216068 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/PeriodTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -22,44 +23,40 @@ public Period Test(Period arg) } } - private readonly IRequestExecutor testExecutor; - - public PeriodTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: one }"); + var result = _testExecutor.Execute("query { test: one }"); Assert.Equal("P-3W3DT139t", result.ExpectQueryResult().Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Period!) { test(arg: $arg) }") - .SetVariableValue("arg", "P-3W15DT139t") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Period!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "P-3W15DT139t" }, }) + .Build()); Assert.Equal("P-3W15DT-10M139t", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: Period!) { test(arg: $arg) }") - .SetVariableValue("arg", "-3W3DT-10M139t") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: Period!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "-3W3DT-10M139t" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -67,20 +64,20 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"P-3W15DT139t\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"P-3W15DT139t\") }") + .Build()); Assert.Equal("P-3W15DT-10M139t", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"-3W3DT-10M139t\") }") - .Create()); + var result = _testExecutor + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"-3W3DT-10M139t\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); @@ -90,7 +87,7 @@ public void DoesntParseIncorrectLiteral() } [Fact] - public void PatternEmpty_ThrowSchemaException() + public void PatternEmptyThrowSchemaException() { static object Call() => new PeriodType(Array.Empty>()); Assert.Throws(Call); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeCustomIntegrationTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeCustomIntegrationTests.cs index f1041005df7..9c7e683c936 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeCustomIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeCustomIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -28,7 +29,7 @@ public void QueryReturns() { var result = _testExecutor.Execute("query { test: rome }"); Assert.Equal( - "2020-12-31T18:30:13 Asia/Kathmandu (+05:45)", + "2020-12-31T18:30:13 Asia/Kathmandu (+05:45)", result.ExpectQueryResult().Data!["test"]); } @@ -43,10 +44,10 @@ public void QueryReturnsUtc() public void ParsesVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T19:30:13 Asia/Kathmandu (+05:45)") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T19:30:13 Asia/Kathmandu (+05:45)" }, }) + .Build()); Assert.Equal( "2020-12-31T19:40:13 Asia/Kathmandu (+05:45)", @@ -57,10 +58,10 @@ public void ParsesVariable() public void ParsesVariableWithUTC() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T19:30:13 UTC (+00)") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T19:30:13 UTC (+00)" }, }) + .Build()); Assert.Equal("2020-12-31T19:40:13 UTC (+00)", result.ExpectQueryResult().Data!["test"]); } @@ -69,10 +70,10 @@ public void ParsesVariableWithUTC() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T19:30:13 (UTC)") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") + .SetVariableValues(new Dictionary { {"arg", "2020-12-31T19:30:13 (UTC)" }, }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); @@ -82,13 +83,13 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery( + .Execute(OperationRequestBuilder.Create() + .SetDocument( @"mutation { - test(arg: ""2020-12-31T19:30:13 Asia/Kathmandu (+05:45)"") + test(arg: ""2020-12-31T19:30:13 Asia/Kathmandu (+05:45)"") }") - .Create()); + .Build()); Assert.Equal( "2020-12-31T19:40:13 Asia/Kathmandu (+05:45)", @@ -96,12 +97,12 @@ public void ParsesLiteral() } [Fact] - public void ParsesLiteralWithUTC() + public void ParsesLiteralWithUtc() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T19:30:13 UTC (+00)\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T19:30:13 UTC (+00)\") }") + .Build()); Assert.Equal("2020-12-31T19:40:13 UTC (+00)", result.ExpectQueryResult().Data!["test"]); } @@ -110,9 +111,9 @@ public void ParsesLiteralWithUTC() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T19:30:13 (UTC)\") }") - .Create()); + .Execute(OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T19:30:13 (UTC)\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs index 3d4178f0501..6446d3a91da 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using HotChocolate.Execution; using NodaTime; using NodaTime.Text; @@ -33,70 +34,81 @@ public ZonedDateTime Test(ZonedDateTime arg) } } - private readonly IRequestExecutor testExecutor; - - public ZonedDateTimeTypeIntegrationTests() - { - testExecutor = SchemaBuilder.New() + private readonly IRequestExecutor _testExecutor = + SchemaBuilder.New() .AddQueryType() .AddMutationType() .AddNodaTime() .Create() .MakeExecutable(); - } [Fact] public void QueryReturns() { - var result = testExecutor.Execute("query { test: rome }"); + var result = _testExecutor.Execute("query { test: rome }"); Assert.Equal( "2020-12-31T18:30:13 Asia/Kathmandu +05:45", - Assert.IsType(result).Data!["test"]); + Assert.IsType(result).Data!["test"]); } [Fact] public void QueryReturnsUtc() { - var result = testExecutor.Execute("query { test: utc }"); + var result = _testExecutor.Execute("query { test: utc }"); Assert.Equal( "2020-12-31T18:30:13 UTC +00", - Assert.IsType(result).Data!["test"]); + Assert.IsType(result).Data!["test"]); } [Fact] public void ParsesVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T19:30:13 Asia/Kathmandu +05:45") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31T19:30:13 Asia/Kathmandu +05:45" }, + }) + .Build()); Assert.Equal( "2020-12-31T19:40:13 Asia/Kathmandu +05:45", - Assert.IsType(result).Data!["test"]); + Assert.IsType(result).Data!["test"]); } [Fact] - public void ParsesVariableWithUTC() + public void ParsesVariableWithUtc() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T19:30:13 UTC +00") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31T19:30:13 UTC +00" } + }) + .Build()); Assert.Equal( "2020-12-31T19:40:13 UTC +00", - Assert.IsType(result).Data!["test"]); + Assert.IsType(result).Data!["test"]); } [Fact] public void DoesntParseAnIncorrectVariable() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") - .SetVariableValue("arg", "2020-12-31T19:30:13 UTC") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31T19:30:13 UTC" }, + }) + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); } @@ -104,32 +116,35 @@ public void DoesntParseAnIncorrectVariable() [Fact] public void ParsesLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation{test(arg:\"2020-12-31T19:30:13 Asia/Kathmandu +05:45\")}") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation{test(arg:\"2020-12-31T19:30:13 Asia/Kathmandu +05:45\")}") + .Build()); Assert.Equal( "2020-12-31T19:40:13 Asia/Kathmandu +05:45", result.ExpectQueryResult().Data!["test"]); } [Fact] - public void ParsesLiteralWithUTC() + public void ParsesLiteralWithUtc() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T19:30:13 UTC +00\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T19:30:13 UTC +00\") }") + .Build()); Assert.Equal("2020-12-31T19:40:13 UTC +00", result.ExpectQueryResult().Data!["test"]); } [Fact] public void DoesntParseIncorrectLiteral() { - var result = testExecutor - .Execute(QueryRequestBuilder.New() - .SetQuery("mutation { test(arg: \"2020-12-31T19:30:13 UTC\") }") - .Create()); + var result = _testExecutor + .Execute( + OperationRequestBuilder.Create() + .SetDocument("mutation { test(arg: \"2020-12-31T19:30:13 UTC\") }") + .Build()); Assert.Null(result.ExpectQueryResult().Data); Assert.Equal(1, result.ExpectQueryResult().Errors!.Count); Assert.Null(result.ExpectQueryResult().Errors![0].Code); diff --git a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CustomCollectionSegmentHandlerTests.cs b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CustomCollectionSegmentHandlerTests.cs index 791297846e2..82532269bad 100644 --- a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CustomCollectionSegmentHandlerTests.cs +++ b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CustomCollectionSegmentHandlerTests.cs @@ -25,9 +25,9 @@ public async Task Use_Resolver_Result_If_It_Is_A_Page() Snapshot.FullName(); var request = - QueryRequestBuilder.New() - .SetQuery("{ items { items } }") - .Create(); + OperationRequestBuilder.Create() + .SetDocument("{ items { items } }") + .Build(); // act // assert diff --git a/src/HotChocolate/Core/test/Types.Tests/ResolverContextStateExtensionTests.cs b/src/HotChocolate/Core/test/Types.Tests/ResolverContextStateExtensionTests.cs index b99d0322c76..817b3fc2cea 100644 --- a/src/HotChocolate/Core/test/Types.Tests/ResolverContextStateExtensionTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/ResolverContextStateExtensionTests.cs @@ -36,10 +36,10 @@ public async Task GetUserClaims() d.Field("foo").Resolve(ctx => ctx.GetUser()?.Identity?.Name); }) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("{ foo }") + OperationRequestBuilder.Create() + .SetDocument("{ foo }") .SetUser(user) - .Create()) + .Build()) .MatchSnapshotAsync(); } diff --git a/src/HotChocolate/Core/test/Types.Tests/Resolvers/CustomResolverCompilerTests.cs b/src/HotChocolate/Core/test/Types.Tests/Resolvers/CustomResolverCompilerTests.cs index 9d06a31cd1d..9b953ab91bb 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Resolvers/CustomResolverCompilerTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Resolvers/CustomResolverCompilerTests.cs @@ -23,10 +23,10 @@ public async Task AddWellKnownState_New() .AddQueryType() .AddParameterExpressionBuilder(ctx => (SayHelloState)ctx.ContextData["someState"]!) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("{ sayHello }") + OperationRequestBuilder.Create() + .SetDocument("{ sayHello }") .AddGlobalState("someState", new SayHelloState("Hello")) - .Create()) + .Build()) .MatchSnapshotAsync(); } diff --git a/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverServiceTests.cs b/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverServiceTests.cs index c024542d5f3..9396b6e7a53 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverServiceTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverServiceTests.cs @@ -22,24 +22,24 @@ public async Task Resolver_Service_Attribute_Default_Scope() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ sayHelloAttribute }") + OperationRequestBuilder + .Create() + .SetDocument("{ sayHelloAttribute }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Resolver_Service_Attribute_Default_Request_Scope() { @@ -54,24 +54,24 @@ public async Task Resolver_Service_Attribute_Default_Request_Scope() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ sayHelloAttribute }") + OperationRequestBuilder + .Create() + .SetDocument("{ sayHelloAttribute }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Resolver_Service_Inferred_Default_Scope() { @@ -85,24 +85,24 @@ public async Task Resolver_Service_Inferred_Default_Scope() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ sayHelloInferred }") + OperationRequestBuilder + .Create() + .SetDocument("{ sayHelloInferred }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Resolver_Service_Inferred_Scope_Overriden_On_Resolver() { @@ -116,24 +116,24 @@ public async Task Resolver_Service_Inferred_Scope_Overriden_On_Resolver() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ sayHelloRequest }") + OperationRequestBuilder + .Create() + .SetDocument("{ sayHelloRequest }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Resolver_Service_Attribute_Copy_State() { @@ -152,24 +152,24 @@ public async Task Resolver_Service_Attribute_Copy_State() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ sayHelloAttribute }") + OperationRequestBuilder + .Create() + .SetDocument("{ sayHelloAttribute }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Mutation_Resolver_Service_Attribute_Default_Scope() { @@ -184,24 +184,24 @@ public async Task Mutation_Resolver_Service_Attribute_Default_Scope() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("mutation { doSomethingAttribute }") + OperationRequestBuilder + .Create() + .SetDocument("mutation { doSomethingAttribute }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Mutation_Resolver_Service_Attribute_Default_Resolver_Scope() { @@ -217,24 +217,24 @@ public async Task Mutation_Resolver_Service_Attribute_Default_Resolver_Scope() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("mutation { doSomethingAttribute }") + OperationRequestBuilder + .Create() + .SetDocument("mutation { doSomethingAttribute }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } - + [Fact] public async Task Mutation_Resolver_Service_Inferred_Default_Scope() { @@ -249,21 +249,21 @@ public async Task Mutation_Resolver_Service_Inferred_Default_Scope() .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("mutation { doSomethingInferred }") + OperationRequestBuilder + .Create() + .SetDocument("mutation { doSomethingInferred }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } @@ -281,21 +281,21 @@ public async Task Mutation_Resolver_Service_Inferred_Scope_Overriden_On_Resolver .BuildServiceProvider(); var executor = await services.GetRequestExecutorAsync(); - + // act IExecutionResult result; using (var requestScope = services.CreateScope()) { requestScope.ServiceProvider.GetRequiredService().Scope = "Request"; - + result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("mutation { doSomethingResolver }") + OperationRequestBuilder + .Create() + .SetDocument("mutation { doSomethingResolver }") .SetServices(requestScope.ServiceProvider) - .Create()); + .Build()); } - + result.MatchMarkdownSnapshot(); } @@ -313,15 +313,15 @@ public async Task Resolver_KeyedService() .BuildRequestExecutorAsync(); var result = await executor.ExecuteAsync("{ foo }"); - + result.MatchMarkdownSnapshot(); } #endif - + public sealed class SayHelloService { public string Scope = "Resolver"; - + public string SayHello() => $"Hello {Scope}"; } @@ -329,10 +329,10 @@ public class QueryService { public string SayHelloAttribute([Service] SayHelloService service) => service.SayHello(); - + public string SayHelloInferred(SayHelloService service) => service.SayHello(); - + [UseRequestScope] public string SayHelloRequest(SayHelloService service) => service.SayHello(); @@ -342,15 +342,15 @@ public class MutationService { public string DoSomethingAttribute([Service] SayHelloService service) => service.SayHello(); - + public string DoSomethingInferred(SayHelloService service) => service.SayHello(); - + [UseResolverScope] public string DoSomethingResolver(SayHelloService service) => service.SayHello(); } - + public class SayHelloServicePool : ObjectPool { public bool GetService { get; private set; } @@ -380,7 +380,7 @@ public class KeyedService(string key) { public string Key => key; } - + public class AbcService() : ServiceAttribute("abc"); #endif } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/ArgumentTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/ArgumentTests.cs index ce427e0e0f0..7c6d50d4ed5 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/ArgumentTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/ArgumentTests.cs @@ -25,9 +25,9 @@ public async Task Integration_Collection_EnsureCorrectRuntimeType() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(@"{ + OperationRequestBuilder + .Create() + .SetDocument(@"{ arrayOfScalarsA: arrayOfScalars(values: 1) arrayOfScalarsB: arrayOfScalars(values: [1, 2]) arrayOfObjectsA: arrayOfObjects(values: { bar: 1 }) { bar } @@ -37,7 +37,7 @@ public async Task Integration_Collection_EnsureCorrectRuntimeType() listOfObjectsA: listOfObjects(values: { bar: 1 }) { bar } listOfObjectsB: listOfObjects(values: [{ bar: 1 }, { bar: 2 }]) { bar } }") - .Create()); + .Build()); // assert result.ToJson().MatchSnapshot(); diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTests.cs deleted file mode 100644 index 1d4cb03aab7..00000000000 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTests.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; - -namespace HotChocolate.Types.Directives; - -public class CostDirectiveTests -{ - [Fact] - public void ComplexitySmallerThanZero() - { - // arrange - // act - void Action() => new CostDirective(-1); - void Action1() => new CostDirective(-1, "a"); - - // assert - Assert.Throws(Action); - Assert.Throws(Action1); - } - - [Fact] - public void InvalidMultipliers() - { - // arrange - // act - void Action() => new CostDirective(1, " "); - void Action1() => new CostDirective(1, null); - - // assert - Assert.Throws(Action); - Assert.Throws(Action1); - } - - [Fact] - public void ValidMultipliers() - { - // arrange - // act - var cost = new CostDirective(6, "", "b", "c", null); - - // assert - Assert.Equal(6, cost.Complexity); - Assert.Collection(cost.Multipliers, - s => Assert.Equal("b", s), - s => Assert.Equal("c", s)); - } - - [Fact] - public void NoMultipliers() - { - // arrange - // act - var cost = new CostDirective(5); - - // assert - Assert.Equal(5, cost.Complexity); - Assert.Empty(cost.Multipliers); - } -} diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTypeTests.cs deleted file mode 100644 index a2a027b75a3..00000000000 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Directives/CostDirectiveTypeTests.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System.Linq; - -namespace HotChocolate.Types.Directives; - -public class CostDirectiveTypeTests : TypeTestBase -{ - [Fact] - public void AnnotateCostToObjectFieldCodeFirst() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("field") - .Argument("a", a => a.Type()) - .Type() - .Cost(5)) - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var query = schema.GetType("Query"); - var directive = query.Fields["field"].Directives.Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - } - - [Fact] - public void AnnotateCostToObjectFieldCodeFirstOneMultiplier() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("field") - .Argument("a", a => a.Type()) - .Type() - .Cost(5, "a")) - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var query = schema.GetType("Query"); - var directive = query.Fields["field"].Directives.Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - Assert.Collection(obj.Multipliers, t => Assert.Equal("a", t)); - } - - [Fact] - public void AnnotateCostToObjectFieldCodeFirstTwoMultiplier() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("field") - .Argument("a", a => a.Type()) - .Type() - .Cost(5, "a", "b")) - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var query = schema.GetType("Query"); - var directive = query.Fields["field"].Directives - .Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - Assert.Collection(obj.Multipliers, - t => Assert.Equal("a", t), - t => Assert.Equal("b", t)); - } - - [Fact] - public void AnnotateCostToInterfaceFieldCodeFirst() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("field") - .Argument("a", a => a.Type()) - .Type()) - .AddInterfaceType(d => d - .Name("IQuery") - .Field("field") - .Argument("a", a => a.Type()) - .Type() - .Cost(5)) - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var queryInterface = schema.GetType("IQuery"); - var directive = queryInterface.Fields["field"].Directives - .Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - } - - [Fact] - public void AnnotateCostToInterfaceFieldCodeFirstOneMultiplier() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("field") - .Argument("a", a => a.Type()) - .Type()) - .AddInterfaceType(d => d - .Name("IQuery") - .Field("field") - .Argument("a", a => a.Type()) - .Type() - .Cost(5, "a")) - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var queryInterface = schema.GetType("IQuery"); - var directive = queryInterface.Fields["field"].Directives - .Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - Assert.Collection(obj.Multipliers, t => Assert.Equal("a", t)); - } - - [Fact] - public void AnnotateCostToInterfaceFieldCodeFirstTwoMultiplier() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("field") - .Argument("a", a => a.Type()) - .Type()) - .AddInterfaceType(d => d - .Name("IQuery") - .Field("field") - .Argument("a", a => a.Type()) - .Type() - .Cost(5, "a", "b")) - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var queryInterface = schema.GetType("IQuery"); - var directive = queryInterface.Fields["field"].Directives - .Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - Assert.Collection(obj.Multipliers, - t => Assert.Equal("a", t), - t => Assert.Equal("b", t)); - } - - [Fact] - public void AnnotateCostToObjectFieldSchemaFirst() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddDocumentFromString( - @"type Query { - field(a: Int): String - @cost(complexity: 5 multipliers: [""a""]) - }") - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var query = schema.GetType("Query"); - var directive = query.Fields["field"].Directives - .Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - Assert.Collection(obj.Multipliers, - t => Assert.Equal("a", t)); - } - - [Fact] - public void AnnotateCostToInterfaceFieldSchemaFirst() - { - // arrange - // act - var schema = SchemaBuilder.New() - .AddDocumentFromString( - @" - type Query { - field(a: Int): String - @cost(complexity: 5 multipliers: [""a""]) - } - - interface IQuery { - field(a: Int): String - @cost(complexity: 5 multipliers: [""a""]) - } - ") - .AddDirectiveType() - .Use(_ => _) - .Create(); - - var queryInterface = schema.GetType("IQuery"); - var directive = - queryInterface.Fields["field"].Directives.Single(t => t.Type.Name == "cost"); - var obj = directive.AsValue(); - Assert.Equal(5, obj.Complexity); - Assert.Collection(obj.Multipliers, t => Assert.Equal("a", t)); - } - - [Fact] - public void CreateCostDirective() - { - // arrange - // act - var schema = CreateSchema(b => b - .AddDirectiveType() - .ModifyOptions(o => o.RemoveUnusedTypeSystemDirectives = false)); - var directive = schema.DirectiveTypes.OfType().FirstOrDefault(); - - // assert - Assert.NotNull(directive); - Assert.IsType(directive); - Assert.Equal("cost", directive.Name); - Assert.Collection(directive.Arguments, - t => - { - Assert.Equal("complexity", t.Name); - Assert.IsType( - Assert.IsType(t.Type).Type); - }, - t => - { - Assert.Equal("multipliers", t.Name); - Assert.IsType( - Assert.IsType( - Assert.IsType(t.Type).ElementType).Type); - }, - t => - { - Assert.Equal("defaultMultiplier", t.Name); - Assert.IsType(t.Type); - }); - Assert.Collection(directive.Locations.AsEnumerable(), - t => Assert.Equal(DirectiveLocation.FieldDefinition, t)); - } -} diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Directives/MultiplierPathStringTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Directives/MultiplierPathStringTests.cs deleted file mode 100644 index 0ebddf55d64..00000000000 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Directives/MultiplierPathStringTests.cs +++ /dev/null @@ -1,375 +0,0 @@ -using System; - -namespace HotChocolate.Types.Directives; - -public class MultiplierPathStringTests -{ - [Fact] - public void Create_DefaultConstructor_IsEmpty() - { - // arrange - // act - var nameString = new MultiplierPathString(); - - // assert - Assert.True(nameString.IsEmpty); - Assert.False(nameString.HasValue); - Assert.Null(nameString.Value); - } - - [InlineData("_")] - [InlineData("_Test")] - [InlineData("_1Test")] - [InlineData("Test")] - [InlineData("Test_Test")] - [InlineData("Test_Test.Test")] - [Theory] - public void Create_WithValidName_HasValue(string value) - { - // arrange - // act - var nameString = new MultiplierPathString(value); - - // assert - Assert.Equal(nameString.Value, value); - Assert.True(nameString.HasValue); - Assert.False(nameString.IsEmpty); - } - - [InlineData("1Test")] - [InlineData("Test-Test")] - [InlineData(".Test-Test")] - [Theory] - public void Create_WithInvalidName_ArgumentException(string value) - { - // arrange - // act - Action a = () => new MultiplierPathString(value); - - // assert - Assert.Throws(a); - } - - [InlineData("_")] - [InlineData("_Test")] - [InlineData("_1Test")] - [InlineData("Test")] - [InlineData("Test_Test")] - [InlineData("Test_Test.Test")] - [Theory] - public void ImplicitCast_ValidName_MultiplierPathString(string name) - { - // arrange - // act - MultiplierPathString nameString = name; - - // assert - Assert.Equal(name, nameString.Value); - } - - [InlineData("1Test")] - [InlineData("Test-Test")] - [InlineData("Täst")] - [InlineData(".Test-Test")] - [Theory] - public void ImplicitCast_InvalidName_MultiplierPathString(string name) - { - // arrange - // act - var a = () => { MultiplierPathString nameString = name; }; - - // assert - Assert.Throws(a); - } - - [Fact] - public void ImplicitCast_MultiplierPathString_String() - { - // arrange - var nameString = new MultiplierPathString("Foo"); - - // act - string name = nameString; - - // assert - Assert.Equal(nameString.Value, name); - } - - [Fact] - public void ToString_ReturnsValue() - { - // arrange - var nameString = new MultiplierPathString("Foo"); - - // act - var value = nameString.ToString(); ; - - // assert - Assert.Equal(nameString.Value, value); - } - - [Fact] - public void Append_MultiplierPathString_CombinedMultiplierPathString() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Bar"); - - // act - var combined = a.Add(b); - - // assert - Assert.Equal("FooBar", combined.ToString()); - } - - [Fact] - public void AddOp_MultiplierPathString_CombinedMultiplierPathString() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Bar"); - - // act - var combined = a + b; - - // assert - Assert.Equal("FooBar", combined.ToString()); - } - - [Fact] - public void AddOp_String_CombinedMultiplierPathString() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Bar"; - - // act - MultiplierPathString combined = a + b; - - // assert - Assert.Equal("FooBar", combined.ToString()); - } - - [Fact] - public void Equals_MultiplierPathStringWithSameValue_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Foo"); - - // act - var result = a.Equals(b); - - // assert - Assert.True(result); - } - - [Fact] - public void Equals_SameInstance_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - - // act - var result = a.Equals(a); - - // assert - Assert.True(result); - } - - [Fact] - public void EqualsIgnoreCasing_MultiplierPathStringWithDifferentCasing_True() - { - // arrange - var a = new MultiplierPathString("FOO"); - var b = new MultiplierPathString("foo"); - - // act - var result = a.Equals(b, StringComparison.OrdinalIgnoreCase); - - // assert - Assert.True(result); - } - - [Fact] - public void Equals_MultiplierPathStringDifferentValue_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Bar"); - - // act - var result = a.Equals(b); - - // assert - Assert.False(result); - } - - [Fact] - public void Equals_StringWithSameValue_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Foo"; - - // act - var result = a.Equals(b); - - // assert - Assert.True(result); - } - - [Fact] - public void Equals_StringDifferentValue_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Bar"; - - // act - var result = a.Equals(b); - - // assert - Assert.False(result); - } - - [Fact] - public void EqualsOp_MultiplierPathStringWithSameValue_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Foo"); - - // act - var result = a == b; - - // assert - Assert.True(result); - } - - [Fact] - public void EqualsOp_SameInstance_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = a; - - // act - var result = a == b; - - // assert - Assert.True(result); - } - - [Fact] - public void EqualsOp_MultiplierPathStringDifferentValue_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Bar"); - - // act - var result = a == b; - - // assert - Assert.False(result); - } - - [Fact] - public void EqualsOp_StringWithSameValue_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Foo"; - - // act - var result = a == b; - - // assert - Assert.True(result); - } - - [Fact] - public void EqualsOp_StringDifferentValue_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Bar"; - - // act - var result = a == b; - - // assert - Assert.False(result); - } - - [Fact] - public void NotEqualsOp_MultiplierPathStringWithSameValue_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Foo"); - - // act - var result = a != b; - - // assert - Assert.False(result); - } - - [Fact] - public void NotEqualsOp_SameInstance_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = a; - - // act - var result = a != b; - - // assert - Assert.False(result); - } - - [Fact] - public void NotEqualsOp_MultiplierPathStringDifferentValue_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = new MultiplierPathString("Bar"); - - // act - var result = a != b; - - // assert - Assert.True(result); - } - - [Fact] - public void NotEqualsOp_StringWithSameValue_False() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Foo"; - - // act - var result = a != b; - - // assert - Assert.False(result); - } - - [Fact] - public void NotEqualsOp_StringDifferentValue_True() - { - // arrange - var a = new MultiplierPathString("Foo"); - var b = "Bar"; - - // act - var result = a != b; - - // assert - Assert.True(result); - } -} diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/InputObjectTypeAttributeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/InputObjectTypeAttributeTests.cs index 258bf93c0a3..e19a9069229 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/InputObjectTypeAttributeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/InputObjectTypeAttributeTests.cs @@ -5,7 +5,7 @@ using HotChocolate.Tests; using HotChocolate.Types.Descriptors; using Snapshooter.Xunit; -using QueryRequestBuilder = HotChocolate.Execution.QueryRequestBuilder; +using OperationRequestBuilder = HotChocolate.Execution.OperationRequestBuilder; namespace HotChocolate.Types; @@ -87,9 +87,9 @@ await SchemaBuilder.New() .Create() .MakeExecutable() .ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ foo(a: { }) { foo bar baz qux quux } }") - .Create()) + OperationRequestBuilder.Create() + .SetDocument("{ foo(a: { }) { foo bar baz qux quux } }") + .Build()) .MatchSnapshotAsync(); } @@ -111,15 +111,15 @@ await SchemaBuilder.New() .Create() .MakeExecutable() .ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(@" + OperationRequestBuilder.Create() + .SetDocument(@" query($q: InputWithDefaultsInput) { foo(a: $q) { foo bar baz qux quux } }") - .SetVariableValue("q", new Dictionary()) - .Create()) + .SetVariableValues(new Dictionary { {"q", new Dictionary() }, }) + .Build()) .MatchSnapshotAsync(); } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/InputParserTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/InputParserTests.cs index c013f45594a..528fd27076e 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/InputParserTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/InputParserTests.cs @@ -380,13 +380,16 @@ public async Task Integration_InputObjectDefaultValue_ValueIsInitialized() .BuildRequestExecutorAsync(); // act - var query = QueryRequestBuilder.Create(@" - { - loopback(input: {field2: 1}) { - field1 - field2 + var query = + OperationRequest.FromSourceText( + """ + { + loopback(input: {field2: 1}) { + field1 + field2 + } } - }"); + """); var result = await executor.ExecuteAsync(query, CancellationToken.None); // assert diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/JsonTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/JsonTypeTests.cs index e4a3890bf32..cfb4e0b22db 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/JsonTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/JsonTypeTests.cs @@ -24,14 +24,14 @@ public async Task Json_Schema() schema { query: Query } - + type Query { someJson: JSON! manyJson: [JSON!] inputJson(input: JSON!): JSON! jsonFromString: JSON! } - + scalar JSON """); } @@ -275,15 +275,15 @@ public async Task Input_Json_Object_Variables() .AddGraphQLServer() .AddQueryType() .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ query($input: JSON!) { inputJson(input: $input) } """) - .SetVariableValue("input", input) - .Create()); + .SetVariableValues(new Dictionary { {"input", input }, }) + .Build()); result.MatchInlineSnapshot( """ diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/ListTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/ListTypeTests.cs index 61cd1749e74..958a9bc99f5 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/ListTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/ListTypeTests.cs @@ -60,10 +60,10 @@ public async Task Integration_List_ListValues_Scalars() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ scalars(values: [1,2]) }") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ scalars(values: [1,2]) }") + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -80,10 +80,10 @@ public async Task Integration_List_ScalarValue_Scalars() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ scalars(values: 1) }") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ scalars(values: 1) }") + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -100,10 +100,10 @@ public async Task Integration_List_ListValues_Object() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ objects(values: [{ bar: 1 }, { bar: 2 }]) { bar } }") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ objects(values: [{ bar: 1 }, { bar: 2 }]) { bar } }") + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -120,10 +120,10 @@ public async Task Integration_List_ScalarValue_Object() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ objects(values: { bar: 1 }) { bar } }") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ objects(values: { bar: 1 }) { bar } }") + .Build()); // assert result.ToJson().MatchSnapshot(); diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs index 03323d1182f..163d835e968 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs @@ -1170,10 +1170,10 @@ public async Task ObjectType_SourceTypeObject_BindsResolverCorrectly() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ desc }") + OperationRequestBuilder.Create() + .SetDocument("{ desc }") .SetGlobalState(InitialValue, new Foo()) - .Create()); + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -1481,12 +1481,12 @@ public async Task Execute_With_Query_As_Struct() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ bar baz }") + OperationRequestBuilder.Create() + .SetDocument("{ bar baz }") .SetGlobalState( InitialValue, new FooStruct { Qux = "Qux_Value", Baz = "Baz_Value", }) - .Create()); + .Build()); // assert result.ToJson().MatchSnapshot(); diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/OneOfIntegrationTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/OneOfIntegrationTests.cs index 64d13ab6d82..4989ea29ba9 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/OneOfIntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/OneOfIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Threading.Tasks; using HotChocolate.Configuration.Validation; using HotChocolate.Execution; @@ -64,10 +65,10 @@ public async Task A_is_variable_and_B_is_set_Error() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: String!) { example(input: { a: $var, b: 123 }) }") - .SetVariableValue("var", null) - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: String!) { example(input: { a: $var, b: 123 }) }") + .SetVariableValues(new Dictionary { { "var", null }, }) + .Build()) .MatchSnapshotAsync(); } @@ -81,10 +82,10 @@ public async Task B_is_variable_and_var_is_123_Valid() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: Int!) { example(input: { b: $var }) }") - .SetVariableValue("var", 123) - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: Int!) { example(input: { b: $var }) }") + .SetVariableValues(new Dictionary { { "var", 123 }, }) + .Build()) .MatchSnapshotAsync(); } @@ -98,10 +99,12 @@ public async Task Var_is_object_with_field_b_set_to_123_Valid() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: ExampleInput!) { example(input: $var) }") - .SetVariableValue("var", new ObjectValueNode(new ObjectFieldNode("b", 123))) - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: ExampleInput!) { example(input: $var) }") + .SetVariableValues( + new Dictionary + { { "var", new ObjectValueNode(new ObjectFieldNode("b", 123)) }, }) + .Build()) .MatchSnapshotAsync(); } @@ -117,9 +120,9 @@ public async Task Input_is_set_to_string_abc123_Error() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("{ example(input: \"abc123\") }") - .Create()) + OperationRequestBuilder.Create() + .SetDocument("{ example(input: \"abc123\") }") + .Build()) .MatchSnapshotAsync(); } @@ -135,10 +138,10 @@ public async Task Var_is_string_abc123_and_passed_to_input_Error() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: String!) { example(input: $var) }") - .SetVariableValue("var", "abc123") - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: String!) { example(input: $var) }") + .SetVariableValues(new Dictionary { { "var", "abc123" }, }) + .Build()) .MatchSnapshotAsync(); } @@ -195,9 +198,9 @@ public async Task B_is_variable_and_var_not_set_Error() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: Int!) { example(input: { b: $var }) }") - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: Int!) { example(input: { b: $var }) }") + .Build()) .MatchSnapshotAsync(); } @@ -211,10 +214,12 @@ public async Task Var_is_object_with_field_a_set_to_abc_Valid() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: ExampleInput!) { example(input: $var) }") - .SetVariableValue("var", new ObjectValueNode(new ObjectFieldNode("a", "abc"))) - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: ExampleInput!) { example(input: $var) }") + .SetVariableValues( + new Dictionary + { { "var", new ObjectValueNode(new ObjectFieldNode("a", "abc")) }, }) + .Build()) .MatchSnapshotAsync(); } @@ -242,10 +247,10 @@ public async Task B_is_variable_and_var_is_null_Valid() .AddQueryType() .ModifyOptions(o => o.EnableOneOf = true) .ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("query($var: Int) { example(input: { b: $var }) }") - .SetVariableValue("var", null) - .Create()) + OperationRequestBuilder.Create() + .SetDocument("query($var: Int) { example(input: { b: $var }) }") + .SetVariableValues(new Dictionary { { "var", null }, }) + .Build()) .MatchSnapshotAsync(); } @@ -341,26 +346,27 @@ public async Task Oneof_introspection() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .ModifyOptions(o => - { - o.EnableOneOf = true; - o.StrictValidation = true; - }) + .ModifyOptions( + o => + { + o.EnableOneOf = true; + o.StrictValidation = true; + }) .ExecuteRequestAsync( - @"{ - oneof_input: __type(name: ""ExampleInput"") { + @"{ + oneof_input: __type(name: ""ExampleInput"") { # should be true - oneOf + oneOf } - input: __type(name: ""StandardInput"") { + input: __type(name: ""StandardInput"") { # should be false - oneOf + oneOf } - object: __type(name: ""Query"") { + object: __type(name: ""Query"") { # should be null - oneOf + oneOf } }") .MatchSnapshotAsync(); @@ -378,7 +384,7 @@ public string Example(ExampleInput input) return "b: " + input.B; } - public string Standard(StandardInput input) + public string Standard(StandardInput input) => "abc"; } @@ -386,6 +392,7 @@ public string Standard(StandardInput input) public class ExampleInput { public string? A { get; set; } + public int? B { get; set; } } @@ -418,6 +425,7 @@ protected override void Configure(IInputObjectTypeDescriptor desc public class Example2Input { public string? A { get; set; } + public int? B { get; set; } } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdAttributeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdAttributeTests.cs index c3905e19a01..2f2e424d18f 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdAttributeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdAttributeTests.cs @@ -36,38 +36,47 @@ public async Task Id_On_Arguments() Combine("Query:"u8, new Guid("26a2dc8f-4dab-408c-88c6-523a0a89a2b5").ToByteArray())); // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query foo ( - $intId: ID! - $nullIntId: ID = null - $stringId: ID! - $nullStringId: ID = null - $guidId: ID! - $nullGuidId: ID = null) { - intId(id: $intId) - nullableIntId(id: $intId) - nullableIntIdGivenNull: nullableIntId(id: $nullIntId) - intIdList(id: [$intId]) - nullableIntIdList(id: [$intId, $nullIntId]) - stringId(id: $stringId) - nullableStringId(id: $stringId) - nullableStringIdGivenNull: nullableStringId(id: $nullStringId) - stringIdList(id: [$stringId]) - nullableStringIdList(id: [$stringId, $nullStringId]) - guidId(id: $guidId) - nullableGuidId(id: $guidId) - nullableGuidIdGivenNull: nullableGuidId(id: $nullGuidId) - guidIdList(id: [$guidId $guidId]) - nullableGuidIdList(id: [$guidId $nullGuidId $guidId]) - } - """) - .SetVariableValue("intId", intId) - .SetVariableValue("stringId", stringId) - .SetVariableValue("guidId", guidId) - .Create()); + var result = + await SchemaBuilder.New() + .AddQueryType() + .AddType() + .AddGlobalObjectIdentification(false) + .Create() + .MakeExecutable() + .ExecuteAsync( + OperationRequestBuilder.Create() + .SetDocument(@"query foo ( + $intId: ID! + $nullIntId: ID = null + $stringId: ID! + $nullStringId: ID = null + $guidId: ID! + $nullGuidId: ID = null) + { + intId(id: $intId) + nullableIntId(id: $intId) + nullableIntIdGivenNull: nullableIntId(id: $nullIntId) + intIdList(id: [$intId]) + nullableIntIdList(id: [$intId, $nullIntId]) + stringId(id: $stringId) + nullableStringId(id: $stringId) + nullableStringIdGivenNull: nullableStringId(id: $nullStringId) + stringIdList(id: [$stringId]) + nullableStringIdList(id: [$stringId, $nullStringId]) + guidId(id: $guidId) + nullableGuidId(id: $guidId) + nullableGuidIdGivenNull: nullableGuidId(id: $nullGuidId) + guidIdList(id: [$guidId $guidId]) + nullableGuidIdList(id: [$guidId $nullGuidId $guidId]) + }") + .SetVariableValues( + new Dictionary + { + {"intId", intId }, + {"stringId", stringId }, + {"guidId", guidId }, + }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -86,15 +95,12 @@ await SchemaBuilder.New() .Create() .MakeExecutable() .ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query foo { - interceptedId(id: 1) - interceptedIds(id: [1, 2]) - } - """) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(@"query foo { + interceptedId(id: 1) + interceptedIds(id: [1, 2]) + }") + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -115,27 +121,38 @@ public async Task Id_On_Objects() var someIntId = Convert.ToBase64String("Some:1"u8); // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @"query foo ($someId: ID! $someIntId: ID!) { - foo(input: { - someId: $someId someIds: [$someIntId] - someNullableId: $someId someNullableIds: [$someIntId] }) - { - someId - someNullableId - ... on FooPayload { - someIds - someNullableIds - } - } - }") - .SetVariableValue("someId", someId) - .SetVariableValue("someNullableId", null) - .SetVariableValue("someIntId", someIntId) - .SetVariableValue("someNullableIntId", null) - .Create()); + var result = + await SchemaBuilder.New() + .AddQueryType() + .AddType() + .AddGlobalObjectIdentification(false) + .Create() + .MakeExecutable() + .ExecuteAsync( + OperationRequestBuilder.Create() + .SetDocument( + @"query foo ($someId: ID! $someIntId: ID!) { + foo(input: { + someId: $someId someIds: [$someIntId] + someNullableId: $someId someNullableIds: [$someIntId] }) + { + someId + someNullableId + ... on FooPayload { + someIds + someNullableIds + } + } + }") + .SetVariableValues( + new Dictionary + { + {"someId", someId }, + {"someNullableId", null}, + {"someIntId", someIntId}, + {"someNullableIntId", null}, + }) + .Build()); // assert new @@ -161,31 +178,42 @@ public async Task Id_On_Objects_Given_Nulls() var someIntId = Convert.ToBase64String("Some:1"u8); // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @"query foo ( - $someId: ID! $someIntId: ID! - $someNullableId: ID - $someNullableIntId: ID) { - foo(input: { - someId: $someId someIds: [$someIntId] - someNullableId: $someNullableId - someNullableIds: [$someNullableIntId, $someIntId] }) - { - someId - someNullableId - ... on FooPayload { - someIds - someNullableIds - } - } - }") - .SetVariableValue("someId", someId) - .SetVariableValue("someNullableId", null) - .SetVariableValue("someIntId", someIntId) - .SetVariableValue("someNullableIntId", null) - .Create()); + var result = + await SchemaBuilder.New() + .AddQueryType() + .AddType() + .AddGlobalObjectIdentification(false) + .Create() + .MakeExecutable() + .ExecuteAsync( + OperationRequestBuilder.Create() + .SetDocument( + @"query foo ( + $someId: ID! $someIntId: ID! + $someNullableId: ID + $someNullableIntId: ID) { + foo(input: { + someId: $someId someIds: [$someIntId] + someNullableId: $someNullableId + someNullableIds: [$someNullableIntId, $someIntId] }) + { + someId + someNullableId + ... on FooPayload { + someIds + someNullableIds + } + } + }") + .SetVariableValues( + new Dictionary + { + {"someId", someId}, + {"someNullableId", null}, + {"someIntId", someIntId}, + {"someNullableIntId", null}, + }) + .Build()); // assert new @@ -213,26 +241,28 @@ public async Task InterceptedId_On_Objects() // act var result = await executor .ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query foo($someId: ID! $someIntId: ID!) { - foo(input: { - someId: $someId - someIds: [$someIntId] - interceptedId: 1 - interceptedIds: [1, 2] }) - { - someId - someIds - interceptedId - interceptedIds - } - } - """) - .SetVariableValue("someId", someId) - .SetVariableValue("someIntId", someIntId) - .Create()); + OperationRequestBuilder.Create() + .SetDocument( + @"query foo($someId: ID! $someIntId: ID!) { + foo(input: { + someId: $someId + someIds: [$someIntId] + interceptedId: 1 + interceptedIds: [1, 2] }) + { + someId + someIds + interceptedId + interceptedIds + } + }") + .SetVariableValues( + new Dictionary + { + {"someId", someId }, + {"someIntId", someIntId}, + }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -252,21 +282,26 @@ public async Task Id_On_Objects_InvalidType() var someId = Convert.ToBase64String(Combine("Query:"u8, Guid.Empty.ToByteArray())); // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query foo ($someId: ID!) { - foo(input: { someId: $someId someIds: [$someId] }) { - someId - ... on FooPayload { - someIds - } - } - } - """) - .SetVariableValue("someId", someId) - .Create()); + var result = + await SchemaBuilder.New() + .AddQueryType() + .AddType() + .AddGlobalObjectIdentification(false) + .Create() + .MakeExecutable() + .ExecuteAsync( + OperationRequestBuilder.Create() + .SetDocument( + @"query foo ($someId: ID!) { + foo(input: { someId: $someId someIds: [$someId] }) { + someId + ... on FooPayload { + someIds + } + } + }") + .SetVariableValues(new Dictionary { {"someId", someId }, }) + .Build()); // assert new @@ -291,8 +326,8 @@ await SchemaBuilder.New() .Create() .MakeExecutable() .ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"query foo ($someId: ID!) { foo(input: { someId: $someId someIds: [$someId] }) { someId @@ -301,8 +336,8 @@ ... on FooPayload { } } }") - .SetVariableValue("someId", someId) - .Create()); + .SetVariableValues(new Dictionary { {"someId", someId}, }) + .Build()); // assert new diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdDescriptorTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdDescriptorTests.cs index dee2bfc30dd..44f50505ca3 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdDescriptorTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/IdDescriptorTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using HotChocolate.Execution; using Microsoft.Extensions.DependencyInjection; @@ -24,20 +25,29 @@ public async Task Id_On_Arguments() var guidId = Convert.ToBase64String(Combine("Query:"u8, Guid.Empty.ToByteArray())); // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query foo ($intId: ID! $stringId: ID! $guidId: ID!) { - intId(id: $intId) - stringId(id: $stringId) - guidId(id: $guidId) - } - """) - .SetVariableValue("intId", intId) - .SetVariableValue("stringId", stringId) - .SetVariableValue("guidId", guidId) - .Create()); + var result = + await SchemaBuilder.New() + .AddQueryType() + .AddType() + .AddGlobalObjectIdentification(false) + .Create() + .MakeExecutable() + .ExecuteAsync( + OperationRequestBuilder.Create() + .SetDocument( + @"query foo ($intId: ID! $stringId: ID! $guidId: ID!) { + intId(id: $intId) + stringId(id: $stringId) + guidId(id: $guidId) + }") + .SetVariableValues( + new Dictionary + { + { "intId", intId }, + { "stringId", stringId }, + { "guidId", guidId }, + }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -57,16 +67,23 @@ public async Task Id_On_Objects() var someId = Convert.ToBase64String("Some:1"u8); // act - var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @"query foo ($someId: ID!) { - foo(input: { someId: $someId }) { - someId - } - }") - .SetVariableValue("someId", someId) - .Create()); + var result = + await SchemaBuilder.New() + .AddQueryType() + .AddType() + .AddGlobalObjectIdentification(false) + .Create() + .MakeExecutable() + .ExecuteAsync( + OperationRequestBuilder.Create() + .SetDocument( + @"query foo ($someId: ID!) { + foo(input: { someId: $someId }) { + someId + } + }") + .SetVariableValues(new Dictionary { { "someId", someId }, }) + .Build()); // assert new diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeTypeTests.cs index 9ab32121e02..776862d359f 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeTypeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using HotChocolate.Execution; using HotChocolate.Tests; @@ -29,7 +30,8 @@ public void InitializeExplicitFieldWithImplicitResolver() "a global unique identifier.", nodeInterface.Description); - Assert.Collection(nodeInterface.Fields, + Assert.Collection( + nodeInterface.Fields, t => { Assert.Equal("id", t.Name); @@ -150,7 +152,6 @@ public async Task Infer_Node_From_Query_Field_With_Abc_Argument_Resolve_Nodes_Tw [Fact] public async Task Infer_Node_From_Query_Field_Resolve_Node_With_Int_Id() { - var executor = await new ServiceCollection() .AddGraphQL() .AddQueryType() @@ -161,21 +162,19 @@ public async Task Infer_Node_From_Query_Field_Resolve_Node_With_Int_Id() var id = serializer.Format("Bar", 123); await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query ($id: ID!) { - node(id: $id) { - id - __typename - ... on Bar { - clearTextId + OperationRequestBuilder.Create() + .SetDocument( + @"query ($id: ID!) { + node(id: $id) { + id + __typename + ... on Bar { + clearTextId + } } - } - } - """) - .SetVariableValue("id", id) - .Create()) + }") + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()) .MatchSnapshotAsync(); } @@ -219,21 +218,19 @@ public async Task Node_Attribute_Does_Not_Throw_Execute_Query() var id = serializer.Format("Foo1", "123"); await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - query ($id: ID!) { - node(id: $id) { - id - __typename - ... on Foo1 { - clearTextId + OperationRequestBuilder.Create() + .SetDocument( + @"query ($id: ID!) { + node(id: $id) { + id + __typename + ... on Foo1 { + clearTextId + } } - } - } - """) - .SetVariableValue("id", id) - .Create()) + }") + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()) .MatchSnapshotAsync(); } @@ -255,22 +252,19 @@ public async Task NodeResolver_Is_Missing() public class Query { [NodeResolver] - public Foo GetFooById(string id) - => new Foo(id); + public Foo GetFooById(string id) => new(id); } public class Query2 { [NodeResolver] - public Foo GetFooById(string abc) - => new Foo(abc); + public Foo GetFooById(string abc) => new(abc); } public class Query3 { [NodeResolver] - public Bar GetBarById(int id) - => new Bar(id); + public Bar GetBarById(int id) => new(id); } public class Query4 @@ -289,42 +283,26 @@ public class Query5 public class Query6 { [NodeResolver] - public Baz GetBarById(int id) - => new Baz(id); + public Baz GetBarById(int id) => new(id); } - public class Foo + public class Foo(string id) { - public Foo(string id) - { - Id = id; - } - - public string Id { get; } + public string Id { get; } = id; public string ClearTextId => Id; } - public class Bar + public class Bar(int id) { - public Bar(int id) - { - Id = id; - } - - public int Id { get; } + public int Id { get; } = id; public int ClearTextId => Id; } - public class Baz + public class Baz(int id) { - public Baz(int id) - { - Id1 = id; - } - - public int Id1 { get; } + public int Id1 { get; } = id; public int ClearTextId => Id1; } @@ -332,19 +310,13 @@ public Baz(int id) public class Query7 { [NodeResolver] - public Qux GetBarById(string id) - => new Qux(id); + public Qux GetBarById(string id) => new(id); } [Node] - public class Qux + public class Qux(string id) { - public Qux(string id) - { - Id = id; - } - - public string Id { get; } + public string Id { get; } = id; public string ClearTextId => Id; } @@ -352,32 +324,22 @@ public Qux(string id) public class Query8 { [NodeResolver] - public Foo1 GetBarById(string id) - => new Foo1(id); + public Foo1 GetBarById(string id) => new(id); } - public class Foo1 + public class Foo1(string id) { - public Foo1(string id) - { - Id = id; - } - - public string Id { get; } + public string Id { get; } = id; public string ClearTextId => Id; } [Node] [ExtendObjectType(typeof(Foo1))] - public class Foo2 - { - - } + public class Foo2; public class Query9 { - public Qux GetBarById(string id) - => new Qux(id); + public Qux GetBarById(string id) => new(id); } } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/__snapshots__/IdAttributeTests.Id_On_Objects_InvalidType.snap b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/__snapshots__/IdAttributeTests.Id_On_Objects_InvalidType.snap index 2d934586dae..fe2bc63cda6 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/__snapshots__/IdAttributeTests.Id_On_Objects_InvalidType.snap +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/__snapshots__/IdAttributeTests.Id_On_Objects_InvalidType.snap @@ -1,4 +1,4 @@ { - "result": "{\n \"errors\": [\n {\n \"message\": \"The ID `UXVlcnk6AAAAAAAAAAAAAAAAAAAAAA==` is not an ID of `Some`.\",\n \"locations\": [\n {\n \"line\": 2,\n \"column\": 5\n }\n ],\n \"path\": [\n \"foo\"\n ]\n }\n ],\n \"data\": null\n}", + "result": "{\n \"errors\": [\n {\n \"message\": \"The ID `UXVlcnk6AAAAAAAAAAAAAAAAAAAAAA==` is not an ID of `Some`.\",\n \"locations\": [\n {\n \"line\": 2,\n \"column\": 37\n }\n ],\n \"path\": [\n \"foo\"\n ]\n }\n ],\n \"data\": null\n}", "someId": "UXVlcnk6AAAAAAAAAAAAAAAAAAAAAA==" } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/AnyTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/AnyTypeTests.cs index c8eba2d2e82..09cad312476 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/AnyTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/AnyTypeTests.cs @@ -19,11 +19,12 @@ public async Task Output_Return_Object() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => new Foo())) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => new Foo())) .Create(); var executor = schema.MakeExecutable(); @@ -40,11 +41,12 @@ public async Task Output_Return_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => new List { new(), })) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => new List { new(), })) .Create(); var executor = schema.MakeExecutable(); @@ -61,13 +63,15 @@ public async Task Output_Return_DateTime() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => new DateTimeOffset( - new DateTime(2016, 01, 01), - TimeSpan.Zero))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve( + _ => new DateTimeOffset( + new DateTime(2016, 01, 01), + TimeSpan.Zero))) .Create(); var executor = schema.MakeExecutable(); @@ -84,11 +88,12 @@ public async Task Output_Return_String() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => "abc")) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => "abc")) .Create(); var executor = schema.MakeExecutable(); @@ -105,11 +110,12 @@ public async Task Output_Return_Int() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => 123)) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => 123)) .Create(); var executor = schema.MakeExecutable(); @@ -126,11 +132,12 @@ public async Task Output_Return_Float() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => 1.2)) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => 1.2)) .Create(); var executor = schema.MakeExecutable(); @@ -147,11 +154,12 @@ public async Task Output_Return_Boolean() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => true)) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => true)) .Create(); var executor = schema.MakeExecutable(); @@ -168,12 +176,13 @@ public async Task Input_Object() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -191,12 +200,13 @@ public async Task Input_Value_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -214,12 +224,13 @@ public async Task Input_Object_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -237,12 +248,13 @@ public async Task Input_Value_Object_To_Foo() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -260,12 +272,13 @@ public async Task Input_Value_String() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -283,12 +296,13 @@ public async Task Input_Value_Int() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -306,12 +320,13 @@ public async Task Input_Value_Float() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -329,12 +344,13 @@ public async Task Input_Value_Boolean() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -352,12 +368,13 @@ public async Task Input_Value_Null() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -375,22 +392,23 @@ public async Task Input_Value_List_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", new List { "abc", }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", new List { "abc", } }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -401,28 +419,35 @@ public async Task Input_Object_List_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", new List - { + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues( new Dictionary { - { "abc", "def" }, - }, - }) - .Create()); + { + "foo", new List + { + new Dictionary + { + { "abc", "def" }, + }, + } + }, + }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -433,22 +458,23 @@ public async Task Input_Value_String_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", "bar") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", "bar" }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -459,22 +485,23 @@ public async Task Input_Value_Int_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", 123) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", 123 }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -485,22 +512,23 @@ public async Task Input_Value_Float_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", 1.2) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", 1.2 }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -511,22 +539,23 @@ public async Task Input_Value_Object_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentLiteral("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentLiteral("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", new { a = "b", }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", new { a = "b", } }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -537,22 +566,27 @@ public async Task Input_Value_ObjectDict_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentLiteral("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentLiteral("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", new Dictionary { { "a", "b" }, }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues( + new Dictionary + { + { "foo", new Dictionary { { "a", "b" }, } }, + }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -563,22 +597,27 @@ public async Task Input_Value_ArgumentKind() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentKind("input").ToString())) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentKind("input").ToString())) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", new Dictionary { { "a", "b" }, }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues( + new Dictionary + { + { "foo", new Dictionary { { "a", "b" }, } }, + }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -589,22 +628,23 @@ public async Task Input_Value_Boolean_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", false) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", false }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -615,22 +655,23 @@ public async Task Input_Value_Null_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Any) { foo(input: $foo) }") - .SetVariableValue("foo", null) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Any) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", null }, }) + .Build()); // assert result.ToJson().MatchSnapshot(); @@ -641,12 +682,13 @@ public void IsInstanceOfType_EnumValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -663,12 +705,13 @@ public void IsInstanceOfType_ObjectValue_True() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -685,12 +728,13 @@ public void IsInstanceOfType_ListValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -707,12 +751,13 @@ public void IsInstanceOfType_StringValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -729,12 +774,13 @@ public void IsInstanceOfType_IntValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -751,12 +797,13 @@ public void IsInstanceOfType_FloatValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -773,12 +820,13 @@ public void IsInstanceOfType_BooleanValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -795,12 +843,13 @@ public void IsInstanceOfType_NullValue_True() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -817,12 +866,13 @@ public void IsInstanceOfType_Null_ArgumentNullException() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -847,12 +897,13 @@ public void ParseValue_ScalarValues(object value, Type expectedType) { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -869,12 +920,13 @@ public void ParseValue_Decimal() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -891,12 +943,13 @@ public void ParseValue_List_Of_Object() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -913,12 +966,13 @@ public void ParseValue_List_Of_String() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -935,12 +989,13 @@ public void ParseValue_List_Of_Foo() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -957,12 +1012,13 @@ public void ParseValue_Foo() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -979,12 +1035,13 @@ public void ParseValue_Dictionary() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -1002,12 +1059,13 @@ public void Deserialize_ValueNode() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -1024,19 +1082,20 @@ public void Deserialize_Dictionary() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); var toDeserialize = new Dictionary { - {"Foo", new StringValueNode("Bar")}, + { "Foo", new StringValueNode("Bar") }, }; // act @@ -1051,19 +1110,20 @@ public void Deserialize_NestedDictionary() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); var toDeserialize = new Dictionary { - {"Foo",new Dictionary{{"Bar",new StringValueNode("Baz")}, }}, + { "Foo", new Dictionary { { "Bar", new StringValueNode("Baz") }, } }, }; // act @@ -1079,12 +1139,13 @@ public void Deserialize_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Any"); @@ -1164,4 +1225,4 @@ public class QueryWithDictionary public IDictionary SomeObject => new Dictionary { { "a", "b" }, }; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/MultiplierPathTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/MultiplierPathTypeTests.cs deleted file mode 100644 index 67594feaac5..00000000000 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Scalars/MultiplierPathTypeTests.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using HotChocolate.Language; - -namespace HotChocolate.Types; - -public class MultiplierPathTypeTests -{ - [Fact] - public void EnsureStringTypeKindIsCorret() - { - // arrange - var type = new MultiplierPathType(); - - // act - var kind = type.Kind; - - // assert - Assert.Equal(TypeKind.Scalar, kind); - } - - [Fact] - public void IsInstanceOfType_ValueNode() - { - // arrange - var type = new MultiplierPathType(); - var input = new StringValueNode("_123.456"); - - // act - var result = type.IsInstanceOfType(input); - - // assert - Assert.True(result); - } - - [Fact] - public void IsInstanceOfType_NullValueNode() - { - // arrange - var type = new MultiplierPathType(); - var input = NullValueNode.Default; - - // act - var result = type.IsInstanceOfType(input); - - // assert - Assert.True(result); - } - - [Fact] - public void IsInstanceOfType_Wrong_ValueNode() - { - // arrange - var type = new MultiplierPathType(); - var input = new IntValueNode(123456); - - // act - var result = type.IsInstanceOfType(input); - - // assert - Assert.False(result); - } - - [InlineData("1234")] - [InlineData(" ")] - [Theory] - public void IsInstanceOfType_Wrong_StringValue(string s) - { - // arrange - var type = new MultiplierPathType(); - var input = new StringValueNode(s); - - // act - var result = type.IsInstanceOfType(input); - - // assert - Assert.False(result); - } - - [Fact] - public void IsInstanceOfType_Null_Throws() - { - // arrange - var type = new MultiplierPathType(); - - // act - // assert - Assert.Throws( - () => type.IsInstanceOfType(null!)); - } - - [Fact] - public void Serialize_Type() - { - // arrange - var type = new MultiplierPathType(); - MultiplierPathString input = "_123456"; - - // act - var serializedValue = type.Serialize(input); - - // assert - Assert.IsType(serializedValue); - Assert.Equal("_123456", serializedValue); - } - - [Fact] - public void Serialize_Null() - { - // arrange - var type = new MultiplierPathType(); - - // act - var serializedValue = type.Serialize(null); - - // assert - Assert.Null(serializedValue); - } - - [Fact] - public void Serialize_Wrong_Type_Throws() - { - // arrange - var type = new MultiplierPathType(); - object input = 123456; - - // act - // assert - Assert.Throws( - () => type.Serialize(input)); - } - - [Fact] - public void ParseLiteral_ValueNode() - { - // arrange - var type = new MultiplierPathType(); - var input = new StringValueNode("__123456"); - - // act - var output = type.ParseLiteral(input); - - // assert - Assert.IsType(output); - Assert.Equal(new MultiplierPathString("__123456"), output); - } - - [Fact] - public void ParseLiteral_NullValueNode() - { - // arrange - var type = new MultiplierPathType(); - var input = NullValueNode.Default; - - // act - var output = type.ParseLiteral(input); - - // assert - Assert.Null(output); - } - - [Fact] - public void ParseLiteral_Wrong_ValueNode_Throws() - { - // arrange - var type = new MultiplierPathType(); - var input = new IntValueNode(123456); - - // act - // assert - Assert.Throws( - () => type.ParseLiteral(input)); - } - - [Fact] - public void ParseLiteral_Null_Throws() - { - // arrange - var type = new MultiplierPathType(); - - // act - // assert - Assert.Throws(() => type.ParseLiteral(null!)); - } - - [Fact] - public void ParseValue_Wrong_Value_Throws() - { - // arrange - var type = new MultiplierPathType(); - object input = 123456; - - // act - // assert - Assert.Throws( - () => type.ParseValue(input)); - } - - [Fact] - public void ParseValue_Null() - { - // arrange - var type = new MultiplierPathType(); - - // act - object output = type.ParseValue(null!); - - // assert - Assert.IsType(output); - } -} diff --git a/src/HotChocolate/Core/test/Utilities/SnapshotExtensions.cs b/src/HotChocolate/Core/test/Utilities/SnapshotExtensions.cs index eec2add6df4..5d71cbeeb6f 100644 --- a/src/HotChocolate/Core/test/Utilities/SnapshotExtensions.cs +++ b/src/HotChocolate/Core/test/Utilities/SnapshotExtensions.cs @@ -23,7 +23,7 @@ public static async Task MatchSnapshotAsync( this IExecutionResult result, CancellationToken cancellationToken = default) { - if (result is IQueryResult q) + if (result is IOperationResult q) { q.ToJson().MatchSnapshot(); return result; @@ -157,6 +157,6 @@ public static async Task ToJsonAsync(this Task task) public static void MatchSnapshot(this GraphQLException ex) { - QueryResultBuilder.CreateError(ex.Errors).MatchSnapshot(); + OperationResultBuilder.CreateError(ex.Errors).MatchSnapshot(); } } diff --git a/src/HotChocolate/Core/test/Utilities/TestConfiguration.cs b/src/HotChocolate/Core/test/Utilities/TestConfiguration.cs index 0a00e4d9f27..664c98dac94 100644 --- a/src/HotChocolate/Core/test/Utilities/TestConfiguration.cs +++ b/src/HotChocolate/Core/test/Utilities/TestConfiguration.cs @@ -8,7 +8,7 @@ public class TestConfiguration { public Action? Configure { get; set; } - public Action? ConfigureRequest { get; set; } + public Action? ConfigureRequest { get; set; } public IServiceProvider? Services { get; set; } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Utilities/TestHelper.cs b/src/HotChocolate/Core/test/Utilities/TestHelper.cs index 0687085c0b9..0b786a272ff 100644 --- a/src/HotChocolate/Core/test/Utilities/TestHelper.cs +++ b/src/HotChocolate/Core/test/Utilities/TestHelper.cs @@ -28,7 +28,7 @@ public static string EncodeId(string typeName, Guid id) public static Task ExpectValid( string query, Action? configure = null, - Action? request = null, + Action? request = null, IServiceProvider? requestServices = null) { return ExpectValid( @@ -54,7 +54,7 @@ public static async Task ExpectValid( var result = await executor.ExecuteAsync(request, cancellationToken); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); return result; } @@ -62,7 +62,7 @@ public static Task ExpectError( string sdl, string query, Action? configure = null, - Action? request = null, + Action? request = null, IServiceProvider? requestServices = null, params Action[] elementInspectors) => ExpectError( @@ -79,7 +79,7 @@ public static Task ExpectError( public static Task ExpectError( string query, Action? configure = null, - Action? request = null, + Action? request = null, IServiceProvider? requestServices = null, params Action[] elementInspectors) { @@ -107,15 +107,15 @@ public static async Task ExpectError( var result = await executor.ExecuteAsync(request); // assert - IQueryResult queryResult = Assert.IsType(result); - Assert.NotNull(queryResult.Errors); + IOperationResult operationResult = Assert.IsType(result); + Assert.NotNull(operationResult.Errors); if (elementInspectors.Length > 0) { - Assert.Collection(queryResult.Errors!, elementInspectors); + Assert.Collection(operationResult.Errors!, elementInspectors); } - await queryResult.MatchSnapshotAsync(); + await operationResult.MatchSnapshotAsync(); } public static async Task CreateTypeAsync() @@ -189,13 +189,13 @@ private static async ValueTask CreateExecutorAsync( .GetRequestExecutorAsync(); } - public static IQueryRequest CreateRequest( + public static IOperationRequest CreateRequest( TestConfiguration? configuration, string query) { configuration ??= new TestConfiguration(); - var builder = QueryRequestBuilder.New().SetQuery(query); + var builder = OperationRequestBuilder.Create().SetDocument(query); if (configuration.Services is { } services) { @@ -207,7 +207,7 @@ public static IQueryRequest CreateRequest( configure(builder); } - return builder.Create(); + return builder.Build(); } public static void AddDefaultConfiguration( diff --git a/src/HotChocolate/Core/test/Validation.Tests/DocumentValidatorTests.cs b/src/HotChocolate/Core/test/Validation.Tests/DocumentValidatorTests.cs index 1a8f26156ba..d74c58e966b 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/DocumentValidatorTests.cs +++ b/src/HotChocolate/Core/test/Validation.Tests/DocumentValidatorTests.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using CookieCrumble; +using HotChocolate.Execution; using Microsoft.Extensions.DependencyInjection; using HotChocolate.Language; using HotChocolate.StarWars; @@ -23,7 +24,7 @@ async Task Error() => await queryValidator.ValidateAsync( schema, null!, - "", + new OperationDocumentId("abc"), new Dictionary(), false); @@ -42,7 +43,7 @@ async Task Error() => await queryValidator.ValidateAsync( null!, new DocumentNode(null, new List()), - "", + new OperationDocumentId("abc"), new Dictionary(), false); @@ -54,18 +55,18 @@ await queryValidator.ValidateAsync( public async Task QueryWithTypeSystemDefinitions() { await ExpectErrors( - @" - query getDogName { - dog { - name - color - } + """ + query getDogName { + dog { + name + color } + } - extend type Dog { - color: String - } - ", + extend type Dog { + color: String + } + """, t => Assert.Equal( "A document containing TypeSystemDefinition " + "is invalid for execution.", @@ -80,21 +81,21 @@ extend type Dog { public async Task QueryWithOneAnonymousAndOneNamedOperation() { await ExpectErrors( - @" - { - dog { - name - } + """ + { + dog { + name } + } - query getName { - dog { - owner { - name - } + query getName { + dog { + owner { + name } } - ", + } + """, t => { Assert.Equal( @@ -109,23 +110,23 @@ query getName { public async Task TwoQueryOperationsWithTheSameName() { await ExpectErrors( - @" - query getName { - dog { - name - } + """ + query getName { + dog { + name } + } - query getName { - dog { - owner { - name - } + query getName { + dog { + owner { + name } } - ", + } + """, t => Assert.Equal( - $"The operation name `getName` is not unique.", + "The operation name `getName` is not unique.", t.Message)); } @@ -745,7 +746,7 @@ public async Task DuplicatesWillBeIgnoredOnFieldMerging() var result = await validator.ValidateAsync( schema, document, - "", + new OperationDocumentId("abc"), new Dictionary(), false); @@ -878,7 +879,7 @@ private async Task ExpectValid(ISchema schema, IDocumentValidator validator, str var result = await validator.ValidateAsync( schema, query, - "", + new OperationDocumentId("abc"), new Dictionary(), false); @@ -904,7 +905,7 @@ private async Task ExpectErrors( var result = await validator.ValidateAsync( schema, query, - "", + new OperationDocumentId("abc"), new Dictionary(), false); diff --git a/src/HotChocolate/Core/test/Validation.Tests/IntrospectionRuleTests.cs b/src/HotChocolate/Core/test/Validation.Tests/IntrospectionRuleTests.cs index a8cc0173501..718010b6f70 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/IntrospectionRuleTests.cs +++ b/src/HotChocolate/Core/test/Validation.Tests/IntrospectionRuleTests.cs @@ -114,7 +114,6 @@ private ISchema CreateSchema() { return SchemaBuilder.New() .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .AddCostDirectiveType() .Use(_ => _ => default) .Create(); } diff --git a/src/HotChocolate/Core/test/Validation.Tests/__resources__/CostSchema.graphql b/src/HotChocolate/Core/test/Validation.Tests/__resources__/CostSchema.graphql index a44b31d9dd0..20cb36960ed 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/__resources__/CostSchema.graphql +++ b/src/HotChocolate/Core/test/Validation.Tests/__resources__/CostSchema.graphql @@ -18,3 +18,5 @@ type Baz { } union BazOrBar = Baz | Bar + +directive @cost(complexity: Int!) on FIELD_DEFINITION diff --git a/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithOneAnonymousAndOneNamedOperation.snap b/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithOneAnonymousAndOneNamedOperation.snap index 93036d525ef..8be670ff65f 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithOneAnonymousAndOneNamedOperation.snap +++ b/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithOneAnonymousAndOneNamedOperation.snap @@ -5,8 +5,8 @@ "Path": null, "Locations": [ { - "Line": 2, - "Column": 17 + "Line": 1, + "Column": 1 } ], "Extensions": { diff --git a/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithTypeSystemDefinitions.snap b/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithTypeSystemDefinitions.snap index b9e5ac16431..dd5dd0fdff8 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithTypeSystemDefinitions.snap +++ b/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.QueryWithTypeSystemDefinitions.snap @@ -5,8 +5,8 @@ "Path": null, "Locations": [ { - "Line": 9, - "Column": 17 + "Line": 8, + "Column": 1 } ], "Extensions": { @@ -29,8 +29,8 @@ }, "Locations": [ { - "Line": 5, - "Column": 25 + "Line": 4, + "Column": 9 } ], "Extensions": { diff --git a/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.TwoQueryOperationsWithTheSameName.snap b/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.TwoQueryOperationsWithTheSameName.snap index d3598a3d6fc..33d486ce0f4 100644 --- a/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.TwoQueryOperationsWithTheSameName.snap +++ b/src/HotChocolate/Core/test/Validation.Tests/__snapshots__/DocumentValidatorTests.TwoQueryOperationsWithTheSameName.snap @@ -5,8 +5,8 @@ "Path": null, "Locations": [ { - "Line": 8, - "Column": 17 + "Line": 7, + "Column": 1 } ], "Extensions": { diff --git a/src/HotChocolate/Data/test/Data.AutoMapper.Tests/ProjectToTests.cs b/src/HotChocolate/Data/test/Data.AutoMapper.Tests/ProjectToTests.cs index 286e89a5256..de0eb91d4e8 100644 --- a/src/HotChocolate/Data/test/Data.AutoMapper.Tests/ProjectToTests.cs +++ b/src/HotChocolate/Data/test/Data.AutoMapper.Tests/ProjectToTests.cs @@ -96,8 +96,8 @@ public async Task Execute_ManyToOne() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { posts { @@ -108,7 +108,7 @@ public async Task Execute_ManyToOne() } } }") - .Create()); + .Build()); var snapshot = new Snapshot(); snapshot.AddSqlFrom(res1); @@ -124,8 +124,8 @@ public async Task Execute_ManyToOne_Deep() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query Test { posts { @@ -145,7 +145,7 @@ query Test { } } }") - .Create()); + .Build()); var snapshot = new Snapshot(); snapshot.AddSqlFrom(res1); @@ -160,8 +160,8 @@ public async Task Execute_OneToOne() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { blogs { @@ -171,7 +171,7 @@ public async Task Execute_OneToOne() } } }") - .Create()); + .Build()); // assert var snapshot = new Snapshot(); @@ -188,8 +188,8 @@ public async Task Execute_OneToOne_Deep() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query Test { posts { @@ -203,7 +203,7 @@ query Test { } } }") - .Create()); + .Build()); var snapshot = new Snapshot(); snapshot.AddSqlFrom(res1); @@ -218,8 +218,8 @@ public async Task Execute_Derived_CompleteSelectionSet() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query Test { members { @@ -228,7 +228,7 @@ ... on PremiumMemberDto { premium } ... on StandardMemberDto { standard } } }") - .Create()); + .Build()); // assert var snapshot = new Snapshot(); @@ -245,8 +245,8 @@ public async Task Execute_Derived_PartialSelectionSet() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query Test { members { @@ -254,7 +254,7 @@ query Test { ... on PremiumMemberDto { premium } } }") - .Create()); + .Build()); var snapshot = new Snapshot(); snapshot.AddSqlFrom(res1); diff --git a/src/HotChocolate/Data/test/Data.AutoMapper.Tests/RequestExecutorBuilderExtensions.cs b/src/HotChocolate/Data/test/Data.AutoMapper.Tests/RequestExecutorBuilderExtensions.cs index 515c420b34d..3ed12e0661a 100644 --- a/src/HotChocolate/Data/test/Data.AutoMapper.Tests/RequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/Data/test/Data.AutoMapper.Tests/RequestExecutorBuilderExtensions.cs @@ -43,11 +43,11 @@ public static IRequestExecutorBuilder UseSqlLogging(this IRequestExecutorBuilder context.ContextData.TryGetValue("expression", out var expression)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) .SetContextData("expression", expression) - .Create(); + .Build(); } }) .UseDefaultPipeline(); diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs index f56f706c641..90a641f5c06 100644 --- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs +++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs @@ -1,13 +1,79 @@ using CookieCrumble; using HotChocolate.Execution; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; +using Moq; namespace HotChocolate.Data; public class EntityFrameworkResolverCompilerIntegrationTests { [Fact] - public async Task DBContext_On_Queries_Is_Scoped() + public async Task Resolver_Pipeline_With_DbContext_Is_Created() + { + using AuthorFixture authorFixture = new(); + + var contextFactory = new Mock>(); + + contextFactory + .Setup(t => t.CreateDbContextAsync(It.IsAny())) + .Returns(Task.FromResult(authorFixture.Context)); + + var result = await new ServiceCollection() + .AddSingleton(contextFactory.Object) + .AddGraphQL() + .AddQueryType() + .ExecuteRequestAsync("{ books { title } }"); + + result.MatchSnapshot(); + } + + [Fact] + public async Task Resolver_Pipeline_With_Request_DbContext_Is_Created() + { + using AuthorFixture authorFixture = new(); + + using var scope = new ServiceCollection() + .AddScoped(_ => authorFixture.Context) + .AddGraphQL() + .AddQueryType() + .ModifyRequestOptions(o => o.IncludeExceptionDetails = true) + .Services + .BuildServiceProvider() + .CreateScope(); + + var result = await scope.ServiceProvider.ExecuteRequestAsync( + OperationRequestBuilder.Create() + .SetDocument("{ books { title } }") + .SetServices(scope.ServiceProvider) + .Build()); + + result.MatchSnapshot(); + } + + [Fact] + public async Task Resolver_Pipeline_With_Field_DbContext_Is_Created() + { + using AuthorFixture authorFixture = new(); + + await using var service = new ServiceCollection() + .AddScoped(_ => authorFixture.Context) + .AddGraphQL() + .AddQueryType() + .Services + .BuildServiceProvider(); + + var result = await service.ExecuteRequestAsync( + OperationRequestBuilder.Create() + .SetDocument("{ books { title } }") + .SetServices(service) + .Build()); + + result.MatchSnapshot(); + } + + [Fact] + public async Task Resolver_Pipeline_With_Field_AutoRegistered_DbContext_Is_Created() { using AuthorFixture authorFixture = new(); @@ -19,10 +85,10 @@ public async Task DBContext_On_Queries_Is_Scoped() .BuildServiceProvider(); var result = await service.ExecuteRequestAsync( - QueryRequestBuilder.New() - .SetQuery("{ books { title } }") + OperationRequestBuilder.Create() + .SetDocument("{ books { title } }") .SetServices(service) - .Create()); + .Build()); result.MatchSnapshot(); } diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/FilteringAndPaging.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/FilteringAndPaging.cs index 7197f8d5673..ea6c2f402e0 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/FilteringAndPaging.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/FilteringAndPaging.cs @@ -22,15 +22,15 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") + .Build()); snapshot.Add(res1, "true"); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") + .Build()); snapshot.Add(res2, "true"); // assert diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorBooleanTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorBooleanTests.cs index d32a059026a..fb957f83007 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorBooleanTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorBooleanTests.cs @@ -34,15 +34,15 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); snapshot.Add(res1, "true"); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); snapshot.Add(res2, "false"); // assert @@ -58,15 +58,15 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); snapshot.Add(res1, "true"); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); snapshot.Add(res2, "false"); // assert @@ -82,21 +82,21 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); snapshot.Add(res1, "true"); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); snapshot.Add(res2, "false"); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); snapshot.Add(res3, "null"); // assert @@ -112,21 +112,21 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); snapshot.Add(res1, "true"); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); snapshot.Add(res2, "false"); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); snapshot.Add(res3, "null"); // assert diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorComparableTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorComparableTests.cs index 072199b4f64..0adecaad350 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorComparableTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorComparableTests.cs @@ -35,19 +35,19 @@ public async Task Create_ShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -65,19 +65,19 @@ public async Task Create_ShortNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -95,24 +95,24 @@ public async Task Create_ShortGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -131,24 +131,24 @@ public async Task Create_ShortNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -167,24 +167,24 @@ public async Task Create_ShortGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -202,24 +202,24 @@ public async Task Create_ShortNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -238,24 +238,24 @@ public async Task Create_ShortLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -273,24 +273,24 @@ public async Task Create_ShortNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -310,24 +310,24 @@ public async Task Create_ShortLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -346,24 +346,24 @@ public async Task Create_ShortNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -382,19 +382,19 @@ public async Task Create_ShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -412,19 +412,19 @@ public async Task Create_ShortNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -442,19 +442,19 @@ public async Task Create_ShortNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -472,19 +472,19 @@ public async Task Create_ShortNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert // assert @@ -503,24 +503,24 @@ public async Task Create_ShortNullableGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -539,24 +539,24 @@ public async Task Create_ShortNullableNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -575,24 +575,24 @@ public async Task Create_ShortNullableGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -611,24 +611,24 @@ public async Task Create_ShortNullableNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -647,24 +647,24 @@ public async Task Create_ShortNullableLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -683,24 +683,24 @@ public async Task Create_ShortNullableNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -720,24 +720,24 @@ public async Task Create_ShortNullableLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -756,24 +756,24 @@ public async Task Create_ShortNullableNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -792,19 +792,19 @@ public async Task Create_ShortNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); @@ -822,19 +822,19 @@ public async Task Create_ShortNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") + .Build()); // assert var snapshot = new Snapshot(); diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorEnumTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorEnumTests.cs index 79760c91b27..1ed5063aa6f 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorEnumTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorEnumTests.cs @@ -38,19 +38,19 @@ public async Task Create_EnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -69,19 +69,19 @@ public async Task Create_EnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -100,19 +100,19 @@ public async Task Create_EnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -131,19 +131,19 @@ public async Task Create_EnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -162,19 +162,19 @@ public async Task Create_NullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -193,19 +193,19 @@ public async Task Create_NullableEnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -224,19 +224,19 @@ public async Task Create_NullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -255,19 +255,19 @@ public async Task Create_NullableEnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExecutableTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExecutableTests.cs index 6d8e63981b1..ee2c9d43e3d 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExecutableTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExecutableTests.cs @@ -33,14 +33,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -58,14 +58,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -85,19 +85,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -117,19 +117,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExpressionTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExpressionTests.cs index 13c8d06dee3..01d8b9987fc 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExpressionTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorExpressionTests.cs @@ -28,19 +28,19 @@ public async Task Create_StringConcatExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { displayName: { eq: \"Sam Sampleman\"}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { displayName: { eq: \"Sam Sampleman\"}}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { displayName: { eq: \"NoMatch\"}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { displayName: { eq: \"NoMatch\"}}){ name lastName}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { displayName: { eq: null}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { displayName: { eq: null}}){ name lastName}}") + .Build()); // assert await Snapshot @@ -84,19 +84,19 @@ public async Task Create_CollectionLengthExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barLength: { eq: 1}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barLength: { eq: 1}}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barLength: { eq: 0}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barLength: { eq: 0}}){ name lastName}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barLength: { eq: null}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barLength: { eq: null}}){ name lastName}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorIdTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorIdTests.cs index 45bca30cdc5..102e11b59bd 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorIdTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorIdTests.cs @@ -51,19 +51,19 @@ public async Task Create_StringIdEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -84,19 +84,19 @@ public async Task Create_StringIdNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -117,8 +117,8 @@ public async Task Create_StringIdIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(@"{ + OperationRequestBuilder.Create() + .SetDocument(@"{ root(where: { bar: { in: [ ""Rm86dGVzdGF0ZXN0"" ""Rm86dGVzdGJ0ZXN0"" ] @@ -127,18 +127,18 @@ public async Task Create_StringIdIn_Expression() bar } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [\"Rm86dGVzdGJ0ZXN0\" null]}}){ bar}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -160,31 +160,28 @@ public async Task Create_StringIdNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - """ - { - root(where: { - bar: { - nin: [ "Rm86dGVzdGF0ZXN0" "Rm86dGVzdGJ0ZXN0" ] - } - }){ - bar - } - } - """) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(@"{ + root(where: { + bar: { + nin: [ ""Rm86dGVzdGF0ZXN0"" ""Rm86dGVzdGJ0ZXN0"" ] + } + }){ + bar + } + }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [\"Rm86dGVzdGJ0ZXN0\" null]}}){ bar}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -205,19 +202,19 @@ public async Task Create_NullableStringIdEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -238,19 +235,19 @@ public async Task Create_NullableStringIdNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"Rm86dGVzdGF0ZXN0\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"Rm86dGVzdGJ0ZXN0\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -272,8 +269,8 @@ public async Task Create_NullableStringIdIn_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(@"{ + OperationRequestBuilder.Create() + .SetDocument(@"{ root(where: { bar: { in: [ ""Rm86dGVzdGF0ZXN0"" ""Rm86dGVzdGJ0ZXN0"" ] @@ -282,18 +279,18 @@ public async Task Create_NullableStringIdIn_Expression() bar } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [\"Rm86dGVzdGJ0ZXN0\" null]}}){ bar}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -315,8 +312,8 @@ public async Task Create_NullableStringIdNotIn_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ { root(where: { @@ -328,17 +325,17 @@ public async Task Create_NullableStringIdNotIn_Expression() } } """) - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"Rm86dGVzdGJ0ZXN0\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"Rm86dGVzdGJ0ZXN0\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"Rm86dGVzdGF0ZXN0\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -359,19 +356,19 @@ public async Task Create_ShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: \"Rm9vOjEy\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: \"Rm9vOjEy\"}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: \"Rm9vOjEz\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: \"Rm9vOjEz\"}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -392,19 +389,19 @@ public async Task Create_ShortNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: \"Rm9vOjEy\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: \"Rm9vOjEy\"}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: \"Rm9vOjEz\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: \"Rm9vOjEz\"}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -426,19 +423,19 @@ public async Task Create_ShortNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: \"Rm9vOjEy\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: \"Rm9vOjEy\"}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: \"Rm9vOjEz\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: \"Rm9vOjEz\"}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -460,19 +457,19 @@ public async Task Create_ShortNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: \"Rm9vOjEy\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: \"Rm9vOjEy==\"}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: \"Rm9vOjEz\"}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: \"Rm9vOjEz==\"}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -493,8 +490,8 @@ public async Task Create_ShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -504,11 +501,11 @@ public async Task Create_ShortIn_Expression() barShort } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -518,13 +515,12 @@ public async Task Create_ShortIn_Expression() barShort } }") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - "{ root(where: { barShort: { in: [ null, \"Rm9vOjE0\"]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ null, \"Rm9vOjE0\"]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -545,8 +541,8 @@ public async Task Create_ShortNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -556,20 +552,20 @@ public async Task Create_ShortNotIn_Expression() barShort } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { barShort: { nin: " + "[ \"Rm9vOjEy\", \"Rm9vOjE0\"]}}){ barShort}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { barShort: { nin: [ null, \"Rm9vOjE0\"]}}){ barShort}}") - .Create()); + .Build()); // assert await Snapshot @@ -591,8 +587,8 @@ public async Task Create_ShortNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -602,11 +598,11 @@ public async Task Create_ShortNullableIn_Expression() barShort } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { in: [ ""Rm9vOjEz"", ""Rm9vOjE0""] @@ -615,13 +611,13 @@ public async Task Create_ShortNullableIn_Expression() barShort } }") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { barShort: { in: [ \"Rm9vOjEz\", null ]}}){ barShort}}") - .Create()); + .Build()); // assert await Snapshot @@ -643,8 +639,8 @@ public async Task Create_ShortNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -654,11 +650,11 @@ public async Task Create_ShortNullableNotIn_Expression() barShort } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -668,11 +664,11 @@ public async Task Create_ShortNullableNotIn_Expression() barShort } }") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { barShort: { @@ -682,7 +678,7 @@ public async Task Create_ShortNullableNotIn_Expression() barShort } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs index d342e8dd39f..a8dbc824424 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs @@ -30,25 +30,25 @@ public async Task Create_InterfaceStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"a\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"b\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: null}}}) " + "{ test{ prop}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorListTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorListTests.cs index ff0b65f502d..c35066605af 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorListTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorListTests.cs @@ -70,22 +70,22 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -104,22 +104,22 @@ public async Task Create_ArrayNoneObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -138,19 +138,19 @@ public async Task Create_ArrayAllObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { all: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { all: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { all: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { all: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { all: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { all: {bar: { eq: null}}}}){ fooNested {bar}}}") + .Build()); // assert await Snapshot @@ -169,19 +169,19 @@ public async Task Create_ArrayAnyObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { all: null}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { all: null}}){ fooNested {bar}}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorObjectTests.cs index ca909c3c6b4..d21df5e2d7d 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorObjectTests.cs @@ -156,25 +156,25 @@ public async Task Create_ObjectShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -193,25 +193,25 @@ public async Task Create_ObjectShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -230,25 +230,25 @@ public async Task Create_ObjectNullableShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -267,25 +267,25 @@ public async Task Create_ObjectNullableShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, null ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -304,18 +304,18 @@ public async Task Create_ObjectBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -333,25 +333,25 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: null}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -370,25 +370,25 @@ public async Task Create_ObjectEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -407,25 +407,25 @@ public async Task Create_ObjectEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -444,25 +444,25 @@ public async Task Create_ObjectNullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -481,25 +481,25 @@ public async Task Create_ObjectNullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -518,24 +518,24 @@ public async Task Create_ObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testatest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testbtest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: null}}}){ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -554,25 +554,25 @@ public async Task Create_ObjectStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [ \"testatest\" \"testbtest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [\"testbtest\" null]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [ \"testatest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -591,28 +591,28 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"a\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"d\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: null}}}}}}) " + "{ foo { objectArray { foo {barString}}}}}") - .Create()); + .Build()); // assert await Snapshot @@ -631,25 +631,25 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: false}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: true}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: null}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); // assert await Snapshot @@ -668,19 +668,19 @@ public async Task Create_ObjectNull() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { neq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: null}) { foo{ barEnum}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: null}) { foo{ barEnum}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( "{ root { foo{ barEnum}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument( "{ root { foo{ barEnum}}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStringTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStringTests.cs index fa2a796441b..b297413a230 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStringTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStringTests.cs @@ -33,19 +33,19 @@ public async Task Create_StringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -64,19 +64,19 @@ public async Task Create_StringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -95,19 +95,19 @@ public async Task Create_StringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -126,19 +126,19 @@ public async Task Create_StringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -157,19 +157,19 @@ public async Task Create_StringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -188,19 +188,19 @@ public async Task Create_StringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -220,19 +220,19 @@ public async Task Create_StringStartsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -251,19 +251,19 @@ public async Task Create_StringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -282,19 +282,19 @@ public async Task Create_StringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -313,19 +313,19 @@ public async Task Create_StringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -344,19 +344,19 @@ public async Task Create_NullableStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -376,19 +376,19 @@ public async Task Create_NullableStringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -407,19 +407,19 @@ public async Task Create_NullableStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -438,19 +438,19 @@ public async Task Create_NullableStringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -469,19 +469,19 @@ public async Task Create_NullableStringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -500,19 +500,19 @@ public async Task Create_NullableStringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -531,19 +531,19 @@ public async Task Create_NullableStringStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -562,19 +562,19 @@ public async Task Create_NullableStringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -594,19 +594,19 @@ public async Task Create_NullableStringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -626,19 +626,19 @@ public async Task Create_NullableStringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStructTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStructTests.cs index fe511180d13..9b02523b791 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStructTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorStructTests.cs @@ -57,19 +57,19 @@ public async Task Create_ObjectShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { eq: 12}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { eq: 12}}}) { foo{ barShort}}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { eq: 13}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { eq: 13}}}) { foo{ barShort}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { eq: null}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { eq: null}}}) { foo{ barShort}}}") + .Build()); // assert await Snapshot @@ -89,19 +89,19 @@ public async Task Create_ObjectNullableShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { eq: 12}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { eq: 12}}}) { foo{ barShort}}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { eq: 13}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { eq: 13}}}) { foo{ barShort}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { eq: null}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { eq: null}}}) { foo{ barShort}}}") + .Build()); // assert await Snapshot @@ -121,17 +121,17 @@ public async Task Create_ObjectNull() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: { barShort: { neq: 123}}}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: { barShort: { neq: 123}}}) { foo{ barShort}}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { foo: null}) { foo{ barShort}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { foo: null}) { foo{ barShort}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { foo { barShort }}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { foo { barShort }}}") + .Build()); // assert await Snapshot @@ -151,22 +151,22 @@ public async Task Create_ObjectNullableListShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNullableList:{ some: { barShort: { eq: 12}}}}) { foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNullableList:{ some: { barShort: { eq: 13}}}}) { foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNullableList:{ some: { barShort: { eq: null}}}}) { foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -186,22 +186,22 @@ public async Task Create_ObjectListShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooList:{ some: { barShort: { eq: 12}}}}) { foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooList:{ some: { barShort: { eq: 13}}}}) { foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooList:{ some: { barShort: { eq: null}}}}) { foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorVariablesTests.cs b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorVariablesTests.cs index 3e3f9b6350d..6c6529155f0 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorVariablesTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/QueryableFilterVisitorVariablesTests.cs @@ -3,41 +3,34 @@ namespace HotChocolate.Data.Filters; -public class QueryableFilterVisitorVariablesTests : IClassFixture +public class QueryableFilterVisitorVariablesTests(SchemaCache cache) : IClassFixture { private static readonly Foo[] _fooEntities = [ - new() { Bar = true, }, - new() { Bar = false, }, + new Foo { Bar = true, }, + new Foo { Bar = false, }, ]; - private readonly SchemaCache _cache; - - public QueryableFilterVisitorVariablesTests(SchemaCache cache) - { - _cache = cache; - } - [Fact] public async Task Create_BooleanEqual_Expression() { // arrange - var tester = _cache.CreateSchema(_fooEntities); + var tester = cache.CreateSchema(_fooEntities); const string query = "query Test($where: Boolean){ root(where: {bar: { eq: $where}}){ bar}}"; // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("where", true) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "where", true }, }) + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("where", false) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "where", false }, }) + .Build()); // assert await Snapshot @@ -51,22 +44,22 @@ await Snapshot public async Task Create_BooleanEqual_Expression_NonNull() { // arrange - var tester = _cache.CreateSchema(_fooEntities); + var tester = cache.CreateSchema(_fooEntities); const string query = "query Test($where: Boolean!){ root(where: {bar: { eq: $where}}){ bar}}"; // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("where", true) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "where", true}, }) + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("where", false) - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "where", false}, }) + .Build()); // assert await Snapshot @@ -90,11 +83,7 @@ public class FooNullable public bool? Bar { get; set; } } - public class FooFilterInput : FilterInputType - { - } + public class FooFilterInput : FilterInputType; - public class FooNullableFilterInput : FilterInputType - { - } -} + public class FooNullableFilterInput : FilterInputType; +} \ No newline at end of file diff --git a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/__snapshots__/QueryableFilterVisitorIdTests.Create_NullableStringIdEqual_Expression.snap b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/__snapshots__/QueryableFilterVisitorIdTests.Create_NullableStringIdEqual_Expression.snap index 6ebded2ea16..5f631247d4e 100644 --- a/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/__snapshots__/QueryableFilterVisitorIdTests.Create_NullableStringIdEqual_Expression.snap +++ b/src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/__snapshots__/QueryableFilterVisitorIdTests.Create_NullableStringIdEqual_Expression.snap @@ -17,7 +17,7 @@ testbtest "data": { "root": [ { - "bar": "Rm9vTnVsbGFibGU6dGVzdGJ0ZXN0" + "bar": "Rm9vTnVsbGFibGU6dGVzdGF0ZXN0" } ] } diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs index 60870613222..a426c6e890c 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs @@ -86,10 +86,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilteringAndPaging.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilteringAndPaging.cs index cd4b04d75e1..925fb8ad93f 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilteringAndPaging.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/FilteringAndPaging.cs @@ -21,14 +21,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorBooleanTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorBooleanTests.cs index 98fbe7c24fa..0a5d787c814 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorBooleanTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorBooleanTests.cs @@ -28,14 +28,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -53,14 +53,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -78,19 +78,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -110,19 +110,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorComparableTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorComparableTests.cs index 34c7a8aa636..e7d334f363c 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorComparableTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorComparableTests.cs @@ -30,19 +30,19 @@ public async Task Create_ShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -61,19 +61,19 @@ public async Task Create_ShortNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -92,24 +92,24 @@ public async Task Create_ShortGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -129,24 +129,24 @@ public async Task Create_ShortNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -167,24 +167,24 @@ public async Task Create_ShortGreaterThanOrEquals_Expression() // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -204,24 +204,24 @@ public async Task Create_ShortNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -241,24 +241,24 @@ public async Task Create_ShortLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -278,24 +278,24 @@ public async Task Create_ShortNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -316,24 +316,24 @@ public async Task Create_ShortLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -353,24 +353,24 @@ public async Task Create_ShortNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -390,19 +390,19 @@ public async Task Create_ShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -421,19 +421,19 @@ public async Task Create_ShortNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -452,19 +452,19 @@ public async Task Create_ShortNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -483,19 +483,19 @@ public async Task Create_ShortNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -515,24 +515,24 @@ public async Task Create_ShortNullableGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -552,24 +552,24 @@ public async Task Create_ShortNullableNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -590,24 +590,24 @@ public async Task Create_ShortNullableGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -627,24 +627,24 @@ public async Task Create_ShortNullableNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -664,24 +664,24 @@ public async Task Create_ShortNullableLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -701,24 +701,24 @@ public async Task Create_ShortNullableNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -739,24 +739,24 @@ public async Task Create_ShortNullableLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -776,24 +776,24 @@ public async Task Create_ShortNullableNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -813,19 +813,19 @@ public async Task Create_ShortNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -844,19 +844,19 @@ public async Task Create_ShortNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorEnumTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorEnumTests.cs index cfbaf386931..3215acf63e9 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorEnumTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorEnumTests.cs @@ -32,19 +32,19 @@ public async Task Create_EnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -63,19 +63,19 @@ public async Task Create_EnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }){ barEnum } }") + .Build()); // assert await Snapshot @@ -94,19 +94,19 @@ public async Task Create_EnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -125,19 +125,19 @@ public async Task Create_EnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -157,19 +157,19 @@ public async Task Create_NullableEnumEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }){ barEnum } }") + .Build()); // assert await Snapshot @@ -188,19 +188,19 @@ public async Task Create_NullableEnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -219,19 +219,19 @@ public async Task Create_NullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -250,19 +250,19 @@ public async Task Create_NullableEnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExecutableTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExecutableTests.cs index 3655f36c40d..d466868c7b2 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExecutableTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExecutableTests.cs @@ -34,14 +34,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -59,14 +59,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -84,19 +84,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -115,19 +115,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExpressionTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExpressionTests.cs index 20f22080776..ef213adb89f 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExpressionTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorExpressionTests.cs @@ -39,19 +39,19 @@ public async Task Create_StringConcatExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { displayName: { eq: \"Sam Sampleman\"}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { displayName: { eq: \"Sam Sampleman\"}}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { displayName: { eq: \"NoMatch\"}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { displayName: { eq: \"NoMatch\"}}){ name lastName}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { displayName: { eq: null}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { displayName: { eq: null}}){ name lastName}}") + .Build()); // assert await Snapshot @@ -70,19 +70,19 @@ public async Task Create_CollectionLengthExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barLength: { eq: 1}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barLength: { eq: 1}}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barLength: { eq: 0}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barLength: { eq: 0}}){ name lastName}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barLength: { eq: null}}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barLength: { eq: null}}){ name lastName}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorInterfacesTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorInterfacesTests.cs index 7527a4d3c60..dbb53834a6f 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorInterfacesTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorInterfacesTests.cs @@ -33,25 +33,25 @@ public async Task Create_InterfaceStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"a\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"b\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: null}}}) " + "{ test{ prop}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorListTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorListTests.cs index 72a462ceaa2..40e1af91abf 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorListTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorListTests.cs @@ -64,8 +64,8 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { fooNested: { @@ -81,19 +81,19 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() } } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -112,22 +112,22 @@ public async Task Create_ArrayNoneObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -146,22 +146,22 @@ public async Task Create_ArrayAllObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -180,22 +180,22 @@ public async Task Create_ArrayAnyObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: null}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs index 54af267c624..25ce70051a8 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs @@ -115,25 +115,25 @@ public async Task Create_ObjectShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -152,25 +152,25 @@ public async Task Create_ObjectShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -189,25 +189,25 @@ public async Task Create_ObjectNullableShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -226,25 +226,25 @@ public async Task Create_ObjectNullableShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, null ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -263,18 +263,18 @@ public async Task Create_ObjectBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -292,25 +292,25 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: null}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -329,25 +329,25 @@ public async Task Create_ObjectEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -366,25 +366,25 @@ public async Task Create_ObjectEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -404,25 +404,25 @@ public async Task Create_ObjectNullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -441,25 +441,25 @@ public async Task Create_ObjectNullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -478,24 +478,24 @@ public async Task Create_ObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testatest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testbtest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: null}}}){ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -514,26 +514,26 @@ public async Task Create_ObjectStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: " + "[ \"testatest\" \"testbtest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [\"testbtest\" null]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [ \"testatest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -552,28 +552,28 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"a\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"d\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: null}}}}}}) " + "{ foo { objectArray { foo {barString}}}}}") - .Create()); + .Build()); // assert await Snapshot @@ -592,25 +592,25 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: false}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: true}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: null}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorStringTests.cs b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorStringTests.cs index 233cc470dbe..8dd09191f2f 100644 --- a/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorStringTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorStringTests.cs @@ -28,19 +28,19 @@ public async Task Create_StringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -59,19 +59,19 @@ public async Task Create_StringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -90,20 +90,20 @@ public async Task Create_StringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -122,20 +122,20 @@ public async Task Create_StringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -154,19 +154,19 @@ public async Task Create_StringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -185,19 +185,19 @@ public async Task Create_StringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -217,19 +217,19 @@ public async Task Create_StringStartsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -248,19 +248,19 @@ public async Task Create_StringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -279,19 +279,19 @@ public async Task Create_StringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -310,19 +310,19 @@ public async Task Create_StringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -341,19 +341,19 @@ public async Task Create_NullableStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -373,19 +373,19 @@ public async Task Create_NullableStringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -404,20 +404,20 @@ public async Task Create_NullableStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -437,20 +437,20 @@ public async Task Create_NullableStringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot @@ -470,19 +470,19 @@ public async Task Create_NullableStringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -501,19 +501,19 @@ public async Task Create_NullableStringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -533,19 +533,19 @@ public async Task Create_NullableStringStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -565,19 +565,19 @@ public async Task Create_NullableStringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -597,19 +597,19 @@ public async Task Create_NullableStringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot @@ -630,19 +630,19 @@ public async Task Create_NullableStringNotEndsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Filters.Tests/QueryableFilteringExtensionsTests.cs b/src/HotChocolate/Data/test/Data.Filters.Tests/QueryableFilteringExtensionsTests.cs index d318ee26251..c6d620779b7 100644 --- a/src/HotChocolate/Data/test/Data.Filters.Tests/QueryableFilteringExtensionsTests.cs +++ b/src/HotChocolate/Data/test/Data.Filters.Tests/QueryableFilteringExtensionsTests.cs @@ -37,10 +37,10 @@ public async Task Test() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ shouldWork(where: {bar: {eq: true}}) { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ shouldWork(where: {bar: {eq: true}}) { bar baz }}") + .Build()); // assert res1.MatchSnapshot(); @@ -58,10 +58,10 @@ public async Task Extensions_Should_FilterQuery() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ shouldWork(where: {bar: {eq: true}}) { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ shouldWork(where: {bar: {eq: true}}) { bar baz }}") + .Build()); // assert res1.MatchSnapshot(); @@ -79,10 +79,10 @@ public async Task Extension_Should_BeTypeMissMatch() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ typeMissmatch(where: {bar: {eq: true}}) { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ typeMissmatch(where: {bar: {eq: true}}) { bar baz }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -103,10 +103,10 @@ public async Task Extension_Should_BeMissingMiddleware() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ missingMiddleware { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ missingMiddleware { bar baz }}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/ProjectionVisitorTestBase.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/ProjectionVisitorTestBase.cs index 056a640ccf2..e5f640ad33f 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/ProjectionVisitorTestBase.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/ProjectionVisitorTestBase.cs @@ -103,10 +103,10 @@ public IRequestExecutor CreateSchema( await next(context); if (context.ContextData.TryGetValue("sql", out var queryString)) { - context.Result = QueryResultBuilder + context.Result = OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableFirstOrDefaultTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableFirstOrDefaultTests.cs index 23ceb96497d..b6804f83a4a 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableFirstOrDefaultTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableFirstOrDefaultTests.cs @@ -109,8 +109,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -123,7 +123,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -140,8 +140,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -155,7 +155,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -172,8 +172,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -186,7 +186,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -203,8 +203,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -218,7 +218,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -235,8 +235,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ rootExecutable { foo { @@ -249,7 +249,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionExtensionsTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionExtensionsTests.cs index cf42bb758f5..9dc44a021c3 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionExtensionsTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionExtensionsTests.cs @@ -28,10 +28,10 @@ public async Task Extensions_Should_ProjectQuery() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ shouldWork { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ shouldWork { bar baz }}") + .Build()); // assert res1.MatchSnapshot(); @@ -49,10 +49,10 @@ public async Task Extension_Should_BeTypeMissMatch() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ typeMissmatch { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ typeMissmatch { bar baz }}") + .Build()); // assert await Snapshot @@ -73,10 +73,10 @@ public async Task Extension_Should_BeMissingMiddleware() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ missingMiddleware { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ missingMiddleware { bar baz }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs index 0f4733af219..66269e8e764 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionFilterTests.cs @@ -127,8 +127,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -148,7 +148,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -165,8 +165,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -188,7 +188,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -205,8 +205,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -226,7 +226,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -243,8 +243,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -265,7 +265,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -282,8 +282,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -291,7 +291,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -308,8 +308,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFiel // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { id @@ -319,7 +319,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFiel } } }") - .Create()); + .Build()); // assert await Snapshot @@ -336,8 +336,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { id @@ -352,7 +352,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionHashSetTest.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionHashSetTest.cs index ebec42a3f79..d0594a4c118 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionHashSetTest.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionHashSetTest.cs @@ -52,8 +52,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -67,7 +67,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -84,8 +84,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -100,7 +100,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionInterfaceTypeTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionInterfaceTypeTests.cs index f342b8c8cf2..5e4a357fccd 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionInterfaceTypeTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionInterfaceTypeTests.cs @@ -51,8 +51,8 @@ public async Task Create_Interface() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -65,7 +65,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -98,8 +98,8 @@ public async Task Create_Interface_Pagination() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -114,7 +114,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -132,8 +132,8 @@ public async Task Create_Interface_Nested() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -148,7 +148,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -166,8 +166,8 @@ public async Task Create_Interface_NestedList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -182,7 +182,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -205,8 +205,8 @@ public async Task Paging_Interface_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -221,7 +221,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -244,8 +244,8 @@ public async Task OffsetPaging_Interface_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -260,7 +260,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -278,8 +278,8 @@ public async Task Create_Interface_Without_Missing() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -288,7 +288,7 @@ ... on Foo { } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionNestedTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionNestedTests.cs index b0bca1c2dd5..b20613c62fd 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionNestedTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionNestedTests.cs @@ -22,8 +22,8 @@ public async Task Create_Object() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -32,7 +32,7 @@ public async Task Create_Object() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -49,8 +49,8 @@ public async Task Create_ObjectNotSettable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -59,7 +59,7 @@ public async Task Create_ObjectNotSettable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -76,8 +76,8 @@ public async Task Create_ObjectNotSettableList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -86,7 +86,7 @@ public async Task Create_ObjectNotSettableList() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -103,8 +103,8 @@ public async Task Create_ObjectMethod() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -113,7 +113,7 @@ public async Task Create_ObjectMethod() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -130,8 +130,8 @@ public async Task Create_ObjectMethodList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -140,7 +140,7 @@ public async Task Create_ObjectMethodList() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSetTest.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSetTest.cs index c28dd3c234c..70773fd7c29 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSetTest.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSetTest.cs @@ -58,8 +58,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -73,7 +73,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -90,8 +90,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -106,7 +106,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortedSetTest.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortedSetTest.cs index 240f6294929..fe467447a6f 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortedSetTest.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortedSetTest.cs @@ -52,8 +52,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -67,7 +67,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -84,8 +84,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -100,7 +100,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortingTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortingTests.cs index ed7724e8a2b..7d5c75e40ed 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortingTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionSortingTests.cs @@ -125,8 +125,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -145,7 +145,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -162,8 +162,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -183,7 +183,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -202,8 +202,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -222,7 +222,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -241,8 +241,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -262,7 +262,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionUnionTypeTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionUnionTypeTests.cs index c3f1b552d75..940174a0329 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionUnionTypeTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionUnionTypeTests.cs @@ -51,8 +51,8 @@ public async Task Create_Union() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -64,7 +64,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -97,8 +97,8 @@ public async Task Create_Union_Pagination() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -112,7 +112,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -130,8 +130,8 @@ public async Task Create_Union_Nested() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -145,7 +145,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -163,8 +163,8 @@ public async Task Create_Union_NestedList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -178,7 +178,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -196,8 +196,8 @@ public async Task Create_Union_Without_Missing() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -206,7 +206,7 @@ ... on Foo { } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorExecutableTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorExecutableTests.cs index ab674b23a28..80e9457c6df 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorExecutableTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorExecutableTests.cs @@ -21,9 +21,9 @@ public async Task Create_ProjectsTwoProperties_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable{ bar baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable{ bar baz }}") + .Build()); // assert await Snapshot @@ -40,9 +40,9 @@ public async Task Create_ProjectsOneProperty_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable{ baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable{ baz }}") + .Build()); // assert await Snapshot @@ -65,9 +65,9 @@ public async Task Create_ProjectsOneProperty_WithResolver() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable{ baz foo }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable{ baz foo }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorIsProjectedTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorIsProjectedTests.cs index df9b7b1d26f..4e8745102e3 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorIsProjectedTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorIsProjectedTests.cs @@ -32,9 +32,9 @@ public async Task IsProjected_Should_NotBeProjectedWhenSelected_When_FalseWithOn // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot @@ -51,9 +51,9 @@ public async Task IsProjected_Should_NotBeProjectedWhenSelected_When_FalseWithTw // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse isProjectedTrue }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse isProjectedTrue }}") + .Build()); // assert await Snapshot @@ -70,9 +70,9 @@ public async Task IsProjected_Should_AlwaysBeProjectedWhenSelected_When_True() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot @@ -89,9 +89,9 @@ public async Task IsProjected_Should_AlwaysBeProjectedWhenSelected_When_TrueAndM // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot @@ -108,9 +108,9 @@ public async Task IsProjected_Should_NotFailWhenSelectionSetSkippedCompletely() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorPagingTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorPagingTests.cs index 7dd1250c96c..332345c4116 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorPagingTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorPagingTests.cs @@ -32,9 +32,9 @@ public async Task Create_ProjectsTwoProperties_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { bar baz } }}") + .Build()); // assert await Snapshot @@ -53,9 +53,9 @@ public async Task Create_ProjectsOneProperty_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { baz } }}") + .Build()); // assert await Snapshot @@ -74,9 +74,9 @@ public async Task Create_ProjectsTwoProperties_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { bar baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { bar baz }} }}") + .Build()); // assert await Snapshot @@ -95,9 +95,9 @@ public async Task Create_ProjectsOneProperty_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -116,9 +116,9 @@ public async Task Create_ProjectsTwoProperties_EdgesAndNodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { bar }} }}") + .Build()); // assert await Snapshot @@ -137,9 +137,9 @@ public async Task Create_ProjectsOneProperty_EdgesAndNodesOverlap() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -158,9 +158,9 @@ public async Task CreateNullable_ProjectsTwoProperties_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { bar baz } }}") + .Build()); // assert await Snapshot @@ -179,9 +179,9 @@ public async Task CreateNullable_ProjectsOneProperty_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { baz } }}") + .Build()); // assert await Snapshot @@ -200,9 +200,9 @@ public async Task CreateNullable_ProjectsTwoProperties_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { bar baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { bar baz }} }}") + .Build()); // assert await Snapshot @@ -221,9 +221,9 @@ public async Task CreateNullable_ProjectsOneProperty_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -242,9 +242,9 @@ public async Task CreateNullable_ProjectsTwoProperties_EdgesAndNodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { bar }} }}") + .Build()); // assert await Snapshot @@ -263,9 +263,9 @@ public async Task CreateNullable_ProjectsOneProperty_EdgesAndNodesOverlap() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -284,9 +284,9 @@ public async Task Create_Projection_Should_Stop_When_UseProjectionEncountered() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ bar list { barBaz } } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ bar list { barBaz } } }}") + .Build()); // assert await Snapshot @@ -305,9 +305,9 @@ public async Task Create_Projection_Should_Stop_When_UsePagingEncountered() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ bar paging { nodes {barBaz }} } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ bar paging { nodes {barBaz }} } }}") + .Build()); // assert await Snapshot @@ -326,9 +326,9 @@ public async Task CreateOffsetPaging_ProjectsTwoProperties_Items_WithArgs() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(take:10, skip:1){ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(take:10, skip:1){ items { bar baz } }}") + .Build()); // assert await Snapshot @@ -347,9 +347,9 @@ public async Task CreateOffsetPaging_ProjectsTwoProperties_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { bar baz } }}") + .Build()); // assert await Snapshot @@ -368,9 +368,9 @@ public async Task CreateOffsetPaging_ProjectsOneProperty_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { baz } }}") + .Build()); // assert await Snapshot @@ -389,9 +389,9 @@ public async Task CreateOffsetPagingNullable_ProjectsTwoProperties_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { bar baz } }}") + .Build()); // assert await Snapshot @@ -410,9 +410,9 @@ public async Task CreateOffsetPagingNullable_ProjectsOneProperty_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { baz } }}") + .Build()); // assert await Snapshot @@ -431,9 +431,9 @@ public async Task CreateOffsetPaging_Projection_Should_Stop_When_UseProjectionEn // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items{ bar list { barBaz } } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items{ bar list { barBaz } } }}") + .Build()); // assert await Snapshot @@ -452,9 +452,9 @@ public async Task CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncoun // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items{ bar paging { nodes {barBaz }} } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items{ bar paging { nodes {barBaz }} } }}") + .Build()); // assert await Snapshot @@ -473,9 +473,9 @@ public async Task CreateNullable_NodesAndEdgesWithAliases() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ b: nodes{ baz } a: edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ b: nodes{ baz } a: edges { node { bar }} }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorScalarTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorScalarTests.cs index 99c497f5712..0a89ba0952d 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorScalarTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableProjectionVisitorScalarTests.cs @@ -21,9 +21,9 @@ public async Task Create_NotSettable_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ notSettable }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ notSettable }}") + .Build()); // assert await Snapshot @@ -40,9 +40,9 @@ public async Task Create_Computed_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ computed }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ computed }}") + .Build()); // assert await Snapshot @@ -59,9 +59,9 @@ public async Task Create_ProjectsTwoProperties_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ bar baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ bar baz }}") + .Build()); // assert await Snapshot @@ -78,9 +78,9 @@ public async Task Create_ProjectsOneProperty_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ baz }}") + .Build()); // assert await Snapshot @@ -103,9 +103,9 @@ public async Task Create_ProjectsOneProperty_WithResolver() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ baz foo }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ baz foo }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableSingleOrDefaultTests.cs b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableSingleOrDefaultTests.cs index 5cc3b67717a..d0af44c26c6 100644 --- a/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableSingleOrDefaultTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.SqlServer.Tests/QueryableSingleOrDefaultTests.cs @@ -115,8 +115,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -130,7 +130,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -147,8 +147,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { rootExecutable { @@ -162,7 +162,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -179,8 +179,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -195,7 +195,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -212,8 +212,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -227,7 +227,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -244,8 +244,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -260,7 +260,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Projections.Tests/SelectionContextTests.cs b/src/HotChocolate/Data/test/Data.Projections.Tests/SelectionContextTests.cs index 593fc6a7507..9f0cd797f7a 100644 --- a/src/HotChocolate/Data/test/Data.Projections.Tests/SelectionContextTests.cs +++ b/src/HotChocolate/Data/test/Data.Projections.Tests/SelectionContextTests.cs @@ -66,7 +66,7 @@ void VisitFields(ISelectedField field) }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); string.Join("\n", list).MatchSnapshot(); } @@ -130,7 +130,7 @@ void VisitFields(ISelectedField field) }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); string.Join("\n", list).MatchSnapshot(); } @@ -216,7 +216,7 @@ ... on Bar { // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); string.Join("\n", list).MatchSnapshot(); } @@ -287,7 +287,7 @@ ... on Bar { }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); Assert.IsType(ex).Message.MatchSnapshot(); } @@ -357,7 +357,7 @@ void VisitFields(ISelectedField field) }"); // assert - Assert.Null(Assert.IsType(result).Errors); + Assert.Null(Assert.IsType(result).Errors); string.Join("\n", list).MatchSnapshot(selectedField); } } diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs index 0f92ff808e9..2501573f894 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableFilterVisitorInterfacesTests.cs @@ -30,18 +30,18 @@ public async Task Create_InterfaceStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { test: { prop: ASC}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { test: { prop: DESC}}) " + "{ test{ prop }}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs index 43949cf52b3..8d35dbca834 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs @@ -33,14 +33,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -58,14 +58,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert await Snapshot @@ -84,14 +84,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorComparableTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorComparableTests.cs index a7d3c10e77a..929ed0acb6c 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorComparableTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorComparableTests.cs @@ -36,14 +36,14 @@ public async Task Create_Short_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await Snapshot @@ -62,14 +62,14 @@ public async Task Create_Short_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorEnumTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorEnumTests.cs index f4e1e2d59bd..2d2cc01b9d1 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorEnumTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorEnumTests.cs @@ -38,14 +38,14 @@ public async Task Create_Enum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await Snapshot @@ -64,14 +64,14 @@ public async Task Create_Enum_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExecutableTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExecutableTests.cs index 1bbdf09bd49..4b0248d4eab 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExecutableTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExecutableTests.cs @@ -33,14 +33,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -58,14 +58,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert await Snapshot @@ -84,14 +84,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExpressionTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExpressionTests.cs index 1debcf8ce3e..c11e4caeabc 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExpressionTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorExpressionTests.cs @@ -38,14 +38,14 @@ public async Task Create_StringConcatExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { displayName: DESC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { displayName: DESC}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { displayName: ASC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { displayName: ASC}){ name lastName}}") + .Build()); // assert await Snapshot @@ -88,14 +88,14 @@ public async Task Create_CollectionLengthExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: ASC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: ASC}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: DESC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: DESC}){ name lastName}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs index cdba0f5d4b9..7b51106c2e0 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs @@ -167,18 +167,18 @@ public async Task Create_ObjectShort_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -197,18 +197,18 @@ public async Task Create_ObjectNullableShort_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -226,18 +226,18 @@ public async Task Create_ObjectEnum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -255,18 +255,18 @@ public async Task Create_ObjectNullableEnum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -284,18 +284,18 @@ public async Task Create_ObjectString_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -313,18 +313,18 @@ public async Task Create_ObjectNullableString_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -342,18 +342,18 @@ public async Task Create_ObjectBool_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -371,18 +371,18 @@ public async Task Create_ObjectNullableBool_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -400,15 +400,15 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC, barShort: ASC }}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -421,18 +421,18 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC, barShort: DESC}}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(order: [ { foo: { barBool: DESC } }, @@ -443,7 +443,7 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorStringTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorStringTests.cs index 65ec86eb95f..b5dd1a8c5b4 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorStringTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorStringTests.cs @@ -33,14 +33,14 @@ public async Task Create_String_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -59,14 +59,14 @@ public async Task Create_String_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorVariablesTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorVariablesTests.cs index fac916a85e6..18822940fb2 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorVariablesTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorVariablesTests.cs @@ -27,16 +27,16 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("order", "ASC") - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "order", "ASC" }, }) + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("order", "DESC") - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "order", "DESC" }, }) + .Build()); // assert await Snapshot @@ -56,16 +56,16 @@ public async Task Create_Boolean_OrderBy_NonNull() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("order", "ASC") - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "order", "ASC" }, }) + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(query) - .AddVariableValue("order", "DESC") - .Create()); + OperationRequestBuilder.Create() + .SetDocument(query) + .SetVariableValues(new Dictionary { { "order", "DESC" }, }) + .Build()); // assert await Snapshot @@ -130,28 +130,29 @@ private TestServer CreateServer(TEntity?[] entities) where T : SortInputType { var builder = new WebHostBuilder() - .ConfigureServices((_, services) => - { - services.AddRouting(); - services.AddGraphQLServer() - .AddSorting() - .AddQueryType( - c => - { - c - .Name("Query") - .Field("root") - .Resolve(entities) - .UseSorting(); - - c - .Name("Query") - .Field("rootExecutable") - .Resolve(entities.AsExecutable()) - .UseSorting(); - }) - .BuildRequestExecutorAsync(); - }) + .ConfigureServices( + (_, services) => + { + services.AddRouting(); + services.AddGraphQLServer() + .AddSorting() + .AddQueryType( + c => + { + c + .Name("Query") + .Field("root") + .Resolve(entities) + .UseSorting(); + + c + .Name("Query") + .Field("rootExecutable") + .Resolve(entities.AsExecutable()) + .UseSorting(); + }) + .BuildRequestExecutorAsync(); + }) .Configure(x => x.UseRouting().UseEndpoints(c => c.MapGraphQL())); return new TestServer(builder); } @@ -188,7 +189,5 @@ public class Foo public bool Bar { get; set; } } - public class FooSortType : SortInputType - { - } -} + public class FooSortType : SortInputType { } +} \ No newline at end of file diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs index 1b489f05d47..69c1d2f8257 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs @@ -34,14 +34,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -59,14 +59,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert await Snapshot @@ -85,14 +85,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorComparableTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorComparableTests.cs index 8151ce37c88..cdbcedc86b6 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorComparableTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorComparableTests.cs @@ -36,14 +36,14 @@ public async Task Create_Short_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -62,14 +62,14 @@ public async Task Create_Short_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorEnumTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorEnumTests.cs index c6d159f0ba6..5253d4e3437 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorEnumTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorEnumTests.cs @@ -38,14 +38,14 @@ public async Task Create_Enum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -64,14 +64,14 @@ public async Task Create_Enum_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExecutableTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExecutableTests.cs index 5fe6906c018..e273626049b 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExecutableTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExecutableTests.cs @@ -34,14 +34,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -59,14 +59,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert res1.MatchSnapshot("ASC"); @@ -82,14 +82,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExpressionTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExpressionTests.cs index a8ca3669fd7..6a76d5fd827 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExpressionTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorExpressionTests.cs @@ -28,14 +28,14 @@ public async Task Create_StringConcatExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { displayName: DESC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { displayName: DESC}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { displayName: ASC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { displayName: ASC}){ name lastName}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -78,14 +78,14 @@ public async Task Create_CollectionLengthExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: ASC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: ASC}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: DESC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: DESC}){ name lastName}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs index 9b782244875..c0bf5e00d04 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs @@ -3,11 +3,11 @@ namespace HotChocolate.Data.Sorting.Expressions; -public class QueryableSortVisitorObjectTests : IClassFixture +public class QueryableSortVisitorObjectTests(SchemaCache cache) : IClassFixture { private static readonly Bar[] _barEntities = [ - new() + new Bar { Foo = new Foo { @@ -29,7 +29,7 @@ public class QueryableSortVisitorObjectTests : IClassFixture }, }, }, - new() + new Bar { Foo = new Foo { @@ -51,7 +51,7 @@ public class QueryableSortVisitorObjectTests : IClassFixture }, }, }, - new() + new Bar { Foo = new Foo { @@ -67,7 +67,7 @@ public class QueryableSortVisitorObjectTests : IClassFixture private static readonly BarNullable?[] _barNullableEntities = [ - new() + new BarNullable { Foo = new FooNullable { @@ -89,7 +89,7 @@ public class QueryableSortVisitorObjectTests : IClassFixture }, }, }, - new() + new BarNullable { Foo = new FooNullable { @@ -111,7 +111,7 @@ public class QueryableSortVisitorObjectTests : IClassFixture }, }, }, - new() + new BarNullable { Foo = new FooNullable { @@ -133,7 +133,7 @@ public class QueryableSortVisitorObjectTests : IClassFixture }, }, }, - new() + new BarNullable { Foo = new FooNullable { @@ -145,42 +145,35 @@ public class QueryableSortVisitorObjectTests : IClassFixture ObjectArray = null, }, }, - new() { Foo = null, }, + new BarNullable { Foo = null, }, ]; - private readonly SchemaCache _cache; - - public QueryableSortVisitorObjectTests(SchemaCache cache) - { - _cache = cache; - } - [Fact] public async Task Create_ObjectShort_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -189,28 +182,28 @@ public async Task Create_ObjectNullableShort_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -218,28 +211,28 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectEnum_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -248,28 +241,28 @@ public async Task Create_ObjectNullableEnum_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -277,28 +270,28 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectString_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -307,28 +300,28 @@ public async Task Create_ObjectNullableString_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -336,28 +329,28 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectBool_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -366,28 +359,28 @@ public async Task Create_ObjectNullableBool_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -395,19 +388,19 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectString_OrderBy_TwoProperties() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC, barShort: ASC }}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -420,18 +413,18 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC, barShort: DESC}}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -444,15 +437,15 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "ASC"), res3, "DESC"), res4, "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "ASC") + .AddResult(res3, "DESC") + .AddResult(res4, "DESC") .MatchAsync(); } @@ -460,12 +453,12 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectString_OrderBy_TwoProperties_Variables() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -475,26 +468,28 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { + ["order"] = new List> + { new() { { "foo", - new Dictionary + new Dictionary { - { "barShort", "ASC" },{ "barBool", "ASC" }, + { "barShort", "ASC" }, { "barBool", "ASC" }, } }, }, + } }) - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -504,30 +499,32 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { + ["order"] = new List> + { new() { { "foo", - new Dictionary { { "barShort", "ASC" }, } + new Dictionary { { "barShort", "ASC" }, } }, }, new() { { "foo", - new Dictionary { { "barBool", "ASC" }, } + new Dictionary { { "barBool", "ASC" }, } }, }, + } }) - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -537,26 +534,28 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { + ["order"] = new List> + { new() { { "foo", - new Dictionary + new Dictionary { - { "barShort", "DESC" },{ "barBool", "DESC" }, + { "barShort", "DESC" }, { "barBool", "DESC" }, } }, }, + } }) - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -566,10 +565,11 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { + ["order"] = new List> + { new() { { @@ -584,16 +584,17 @@ query testSort($order: [BarSortInput!]) { new Dictionary { { "barBool", "DESC" }, } }, }, + } }) - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), res1, "ASC"), res2, "ASC"), res3, "DESC"), res4, "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "ASC") + .AddResult(res3, "DESC") + .AddResult(res4, "DESC") .MatchAsync(); } @@ -647,15 +648,9 @@ public class BarNullable public FooNullable? Foo { get; set; } } - public class BarSortType - : SortInputType - { - } + public class BarSortType : SortInputType; - public class BarNullableSortType - : SortInputType - { - } + public class BarNullableSortType : SortInputType; public enum BarEnum { @@ -664,4 +659,4 @@ public enum BarEnum BAZ, QUX, } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorStringTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorStringTests.cs index 493d0ee4b14..414ceb1fe64 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorStringTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorStringTests.cs @@ -34,14 +34,14 @@ public async Task Create_String_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -60,14 +60,14 @@ public async Task Create_String_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/SortVisitorTestBase.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/SortVisitorTestBase.cs index 96350b3669f..5c625447b15 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/SortVisitorTestBase.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/SortVisitorTestBase.cs @@ -75,10 +75,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/QueryableSortingExtensionsTests.cs b/src/HotChocolate/Data/test/Data.Sorting.Tests/QueryableSortingExtensionsTests.cs index e884961d345..fa0126ef6d9 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/QueryableSortingExtensionsTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/QueryableSortingExtensionsTests.cs @@ -29,10 +29,10 @@ public async Task Extensions_Should_SortQuery() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ shouldWork(order: {bar: DESC}) { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ shouldWork(order: {bar: DESC}) { bar baz }}") + .Build()); // assert res1.MatchSnapshot(); @@ -50,10 +50,10 @@ public async Task Extension_Should_BeTypeMissMatch() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ typeMissmatch(order: {bar: DESC}) { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ typeMissmatch(order: {bar: DESC}) { bar baz }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -74,10 +74,10 @@ public async Task Extension_Should_BeMissingMiddleware() // act var res1 = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery("{ missingMiddleware { bar baz }}") - .Create()); + OperationRequestBuilder + .Create() + .SetDocument("{ missingMiddleware { bar baz }}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 5eab9cef80d..0647ac6cf0c 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -128,17 +128,7 @@ public virtual void EnrichSingleRequest( if (request.Variables is not null && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) { - var variables = new ObjectValueNode( - request.Variables.Select( - t => new ObjectFieldNode( - null, - new NameNode(t.Key), - t.Value is null - ? NullValueNode.Default - : (IValueNode)t.Value)) - .ToArray()); - - EnrichRequestVariables(context, request, variables, activity); + EnrichRequestVariables(context, request, CreateVariablesNode(request.Variables), activity); } if (request.Extensions is not null && @@ -186,17 +176,7 @@ public virtual void EnrichBatchRequest( if (request.Variables is not null && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) { - var variables = new ObjectValueNode( - request.Variables.Select( - t => new ObjectFieldNode( - null, - new NameNode(t.Key), - t.Value is null - ? NullValueNode.Default - : (IValueNode)t.Value)) - .ToArray()); - - EnrichBatchVariables(context, request, variables, i, activity); + EnrichBatchVariables(context, request, CreateVariablesNode(request.Variables), i, activity); } if (request.Extensions is not null && @@ -242,17 +222,7 @@ public virtual void EnrichOperationBatchRequest( if (request.Variables is not null && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) { - var variables = new ObjectValueNode( - request.Variables.Select( - t => new ObjectFieldNode( - null, - new NameNode(t.Key), - t.Value is null - ? NullValueNode.Default - : (IValueNode)t.Value)) - .ToArray()); - - EnrichRequestVariables(context, request, variables, activity); + EnrichRequestVariables(context, request, CreateVariablesNode(request.Variables), activity); } if (request.Extensions is not null && @@ -265,7 +235,7 @@ t.Value is null protected virtual void EnrichRequestVariables( HttpContext context, GraphQLRequest request, - ObjectValueNode variables, + ISyntaxNode variables, Activity activity) { activity.SetTag("graphql.http.request.variables", variables.Print()); @@ -274,7 +244,7 @@ protected virtual void EnrichRequestVariables( protected virtual void EnrichBatchVariables( HttpContext context, GraphQLRequest request, - ObjectValueNode variables, + ISyntaxNode variables, int index, Activity activity) { @@ -360,7 +330,7 @@ public virtual void EnrichExecuteRequest(IRequestContext context, Activity activ } activity.DisplayName = operationDisplayName ?? "Execute Request"; - activity.SetTag("graphql.document.id", context.DocumentId); + activity.SetTag("graphql.document.id", context.DocumentId?.Value); activity.SetTag("graphql.document.hash", context.DocumentHash); activity.SetTag("graphql.document.valid", context.IsValidDocument); activity.SetTag("graphql.operation.id", context.OperationId); @@ -372,7 +342,7 @@ public virtual void EnrichExecuteRequest(IRequestContext context, Activity activ activity.SetTag("graphql.document.body", context.Document.Print()); } - if (context.Result is IQueryResult result) + if (context.Result is IOperationResult result) { var errorCount = result.Errors?.Count ?? 0; activity.SetTag("graphql.errors.count", errorCount); @@ -489,7 +459,7 @@ public virtual void EnrichValidateDocument(IRequestContext context, Activity act UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } - activity.SetTag("graphql.document.id", context.DocumentId); + activity.SetTag("graphql.document.id", context.DocumentId?.Value); activity.SetTag("graphql.document.hash", context.DocumentHash); } @@ -627,8 +597,8 @@ protected virtual void EnrichError(IError error, Activity activity) { if (error.Locations.Count == 1) { - tags.Add(new($"graphql.error.location.column", error.Locations[0].Column)); - tags.Add(new($"graphql.error.location.line", error.Locations[0].Line)); + tags.Add(new("graphql.error.location.column", error.Locations[0].Column)); + tags.Add(new("graphql.error.location.line", error.Locations[0].Line)); } else { @@ -642,4 +612,54 @@ protected virtual void EnrichError(IError error, Activity activity) activity.AddEvent(new("Error", tags: new(tags))); } + + private static ISyntaxNode CreateVariablesNode(IReadOnlyList>? variableSet) + { + if (variableSet is null or { Count: 0, }) + { + return NullValueNode.Default; + } + + if (variableSet.Count == 1) + { + var variables = variableSet[0]; + var variablesCount = variables.Count; + var fields = new ObjectFieldNode[variablesCount]; + var index = 0; + + foreach (var (name, value) in variables) + { + // since we are in the HTTP context here we know that it will always be a IValueNode. + var valueNode = value is null ? NullValueNode.Default : (IValueNode)value; + fields[index++] = new ObjectFieldNode(name, valueNode); + } + + return new ObjectValueNode(fields); + } + + if (variableSet.Count > 0) + { + var variableSetCount = variableSet.Count; + var items = new IValueNode[variableSetCount]; + + for(var i = 0; i < variableSetCount; i++) + { + var variables = variableSet[i]; + var variablesCount = variables.Count; + var fields = new ObjectFieldNode[variablesCount]; + var index = 0; + + foreach (var (name, value) in variables) + { + // since we are in the HTTP context here we know that it will always be a IValueNode. + var valueNode = value is null ? NullValueNode.Default : (IValueNode)value; + fields[index++] = new ObjectFieldNode(name, valueNode); + } + + items[i] = new ObjectValueNode(fields); + } + } + + throw new InvalidOperationException(); + } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index 89b45d5374b..be1f45fe656 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -204,7 +204,7 @@ public override void OperationComplexityResult( var activity = (Activity)value; - activity.SetTag("graphql.document.id", context.DocumentId); + activity.SetTag("graphql.document.id", context.DocumentId?.Value); activity.SetTag("graphql.document.complexity", complexity); activity.SetTag("graphql.executor.allowedComplexity", allowedComplexity); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs index 907306ab582..40f718c391d 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs @@ -136,7 +136,7 @@ public override void ParserErrors(HttpContext context, IReadOnlyList err } } - public override IDisposable FormatHttpResponse(HttpContext context, IQueryResult result) + public override IDisposable FormatHttpResponse(HttpContext context, IOperationResult result) { if (_options.SkipFormatHttpResponse) { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs index 6ab58612b94..561c7036855 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs @@ -19,7 +19,7 @@ protected override void EnrichActivity() protected override void SetStatus() { - if (Context.Result is not null and not IQueryResult { Data: null, }) + if (Context.Result is not null and not IOperationResult { Data: null, }) { Activity.SetStatus(Status.Ok); Activity.SetStatus(ActivityStatusCode.Ok); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs index 0eb85f871f5..fe63e0f1313 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs @@ -19,7 +19,7 @@ protected override void EnrichActivity() protected override void SetStatus() { - if (Context.Result is IQueryResult { Data: null, }) + if (Context.Result is IOperationResult { Data: null, }) { Activity.SetStatus(Status.Error); Activity.SetStatus(ActivityStatusCode.Error); diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index f06ed342320..a76fee60d80 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using ChilliCream.Testing; using HotChocolate.Execution; using Snapshooter; using Snapshooter.Xunit; @@ -355,102 +354,6 @@ public async Task Cause_a_resolver_error_that_deletes_the_whole_result() } } - [Fact] - public async Task MaxComplexity_Not_Reached() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => - { - o.Scopes = ActivityScopes.All; - o.IncludeDocument = true; - }) - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 9; - }) - .ExecuteRequestAsync(@" - { - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }"); - - // assert -#if NET7_0_OR_GREATER - activities.MatchSnapshot(new SnapshotNameExtension("_NET7")); -#else - activities.MatchSnapshot(); -#endif - } - } - - [Fact] - public async Task MaxComplexity_Reached() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => - { - o.Scopes = ActivityScopes.All; - o.IncludeDocument = true; - }) - .AddDocumentFromString(FileResource.Open("CostSchema.graphql")) - .UseField(_ => _ => default) - .ConfigureSchema(s => s.AddCostDirectiveType()) - .ModifyRequestOptions(o => - { - o.Complexity.Enable = true; - o.Complexity.MaximumAllowed = 2; - }) - .ExecuteRequestAsync(@" - { - foo { - ... on Foo { - ... on Foo { - field - ... on Bar { - baz { - foo { - field - } - } - } - } - } - } - }"); - - // assert -#if NET7_0_OR_GREATER - activities.MatchSnapshot(new SnapshotNameExtension("_NET7")); -#else - activities.MatchSnapshot(); -#endif - } - } - public class SimpleQuery { public string SayHello() => "hello"; diff --git a/src/HotChocolate/Fusion/src/Core/DependencyInjection/FusionRequestExecutorBuilderExtensions.cs b/src/HotChocolate/Fusion/src/Core/DependencyInjection/FusionRequestExecutorBuilderExtensions.cs index 7aee48bc808..7b913d1d85b 100644 --- a/src/HotChocolate/Fusion/src/Core/DependencyInjection/FusionRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/Fusion/src/Core/DependencyInjection/FusionRequestExecutorBuilderExtensions.cs @@ -420,7 +420,6 @@ private static IRequestExecutorBuilder UseFusionDefaultPipeline( .UseDocumentParser() .UseDocumentValidation() .UseOperationCache() - .UseOperationComplexityAnalyzer() .UseOperationResolver() .UseOperationVariableCoercion() .UseDistributedOperationExecution(); @@ -445,7 +444,6 @@ private static IRequestExecutorBuilder UseFusionPersistedQueryPipeline( .UseDocumentParser() .UseDocumentValidation() .UseOperationCache() - .UseOperationComplexityAnalyzer() .UseOperationResolver() .UseOperationVariableCoercion() .UseDistributedOperationExecution(); @@ -470,7 +468,6 @@ private static IRequestExecutorBuilder UseFusionAutomaticPersistedQueryPipeline( .UseDocumentParser() .UseDocumentValidation() .UseOperationCache() - .UseOperationComplexityAnalyzer() .UseOperationResolver() .UseOperationVariableCoercion() .UseDistributedOperationExecution(); @@ -496,7 +493,6 @@ internal static void AddDefaultPipeline(this IList pipeli pipeline.Add(DocumentParserMiddleware.Create()); pipeline.Add(DocumentValidationMiddleware.Create()); pipeline.Add(OperationCacheMiddleware.Create()); - pipeline.Add(OperationComplexityMiddleware.Create()); pipeline.Add(OperationResolverMiddleware.Create()); pipeline.Add(OperationVariableCoercionMiddleware.Create()); pipeline.Add(DistributedOperationExecutionMiddleware.Create()); diff --git a/src/HotChocolate/Fusion/src/Core/Execution/Nodes/QueryPlan.cs b/src/HotChocolate/Fusion/src/Core/Execution/Nodes/QueryPlan.cs index e9a4a1adfae..7accd3e49e8 100644 --- a/src/HotChocolate/Fusion/src/Core/Execution/Nodes/QueryPlan.cs +++ b/src/HotChocolate/Fusion/src/Core/Execution/Nodes/QueryPlan.cs @@ -150,7 +150,7 @@ public IReadOnlyList GetExportPath(ISelectionSet selectionSet, string ke /// The query plan represents a subscription request /// and cannot be executed but must be subscribed to. /// - public async Task ExecuteAsync( + public async Task ExecuteAsync( FusionExecutionContext context, CancellationToken cancellationToken = default) { diff --git a/src/HotChocolate/Fusion/src/Core/Execution/Nodes/Subscribe.cs b/src/HotChocolate/Fusion/src/Core/Execution/Nodes/Subscribe.cs index a5a342ac99a..9b810053570 100644 --- a/src/HotChocolate/Fusion/src/Core/Execution/Nodes/Subscribe.cs +++ b/src/HotChocolate/Fusion/src/Core/Execution/Nodes/Subscribe.cs @@ -42,7 +42,7 @@ internal sealed class Subscribe(int id, Config config) : ResolverNodeBase(id, co /// /// The query result stream. /// - internal async IAsyncEnumerable SubscribeAsync( + internal async IAsyncEnumerable SubscribeAsync( FusionExecutionContext rootContext, [EnumeratorCancellation] CancellationToken cancellationToken) { diff --git a/src/HotChocolate/Fusion/src/Core/Execution/Pipeline/OperationExecutionMiddleware.cs b/src/HotChocolate/Fusion/src/Core/Execution/Pipeline/OperationExecutionMiddleware.cs index 7268a12621d..81a50fd5a08 100644 --- a/src/HotChocolate/Fusion/src/Core/Execution/Pipeline/OperationExecutionMiddleware.cs +++ b/src/HotChocolate/Fusion/src/Core/Execution/Pipeline/OperationExecutionMiddleware.cs @@ -49,6 +49,7 @@ public async ValueTask InvokeAsync( IRequestContext context, IBatchDispatcher batchDispatcher) { + // todo: we do need to add variable batching. if (context.Operation is not null && context.Variables is not null && context.Operation.ContextData.TryGetValue(PipelineProps.QueryPlan, out var value) && @@ -62,7 +63,7 @@ context.Variables is not null && context.Services, batchDispatcher, context.Operation, - context.Variables, + context.Variables[0], GetRootObject(context.Operation), () => _queryRoot); diff --git a/src/HotChocolate/Fusion/src/Core/FusionOptions.cs b/src/HotChocolate/Fusion/src/Core/FusionOptions.cs index 31d4ba9c149..ab7c159217b 100644 --- a/src/HotChocolate/Fusion/src/Core/FusionOptions.cs +++ b/src/HotChocolate/Fusion/src/Core/FusionOptions.cs @@ -6,7 +6,7 @@ public sealed class FusionOptions { /// /// Gets or sets a value indicating whether the Fusion query plan - /// can be requested on a per request basis. + /// can be requested on a per-request basis. /// /// The default is false. /// diff --git a/src/HotChocolate/Fusion/src/Core/Utilities/ErrorHelper.cs b/src/HotChocolate/Fusion/src/Core/Utilities/ErrorHelper.cs index 33856adf59a..b5c0384f0f7 100644 --- a/src/HotChocolate/Fusion/src/Core/Utilities/ErrorHelper.cs +++ b/src/HotChocolate/Fusion/src/Core/Utilities/ErrorHelper.cs @@ -5,8 +5,8 @@ namespace HotChocolate.Fusion.Utilities; internal static class ErrorHelper { - public static IQueryResult IncrementalDelivery_NotSupported() => - QueryResultBuilder.CreateError( + public static IOperationResult IncrementalDelivery_NotSupported() => + OperationResultBuilder.CreateError( ErrorBuilder.New() .SetMessage("Incremental delivery is not yet supported.") .Build()); diff --git a/src/HotChocolate/Fusion/test/Core.Tests/DataTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/DataTests.cs index 3861394d703..a00ffb6ada3 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/DataTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/DataTests.cs @@ -50,10 +50,10 @@ query GetUser { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); diff --git a/src/HotChocolate/Fusion/test/Core.Tests/DemoIntegrationTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/DemoIntegrationTests.cs index 4d7bffd4cc4..7a44f889bcb 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/DemoIntegrationTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/DemoIntegrationTests.cs @@ -91,10 +91,10 @@ query GetUser { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -143,11 +143,11 @@ author @skip(if: $skip) { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetVariableValue("skip", true) - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetVariableValues(new Dictionary { { "skip", true } }) + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -197,11 +197,11 @@ errorField @skip(if: $skip) // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetVariableValue("skip", true) - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetVariableValues(new Dictionary { { "skip", true } }) + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -243,10 +243,10 @@ query GetUser { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -288,10 +288,10 @@ query GetUser { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -340,10 +340,10 @@ subscription OnNewReview { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build(), cts.Token); // assert @@ -391,10 +391,10 @@ subscription OnNewReview { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build(), cts.Token); // assert @@ -453,10 +453,60 @@ query GetUser { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); + + // assert + var snapshot = new Snapshot(); + CollectSnapshotData(snapshot, request, result, fusionGraph); + await snapshot.MatchMarkdownAsync(); + + Assert.Null(result.ExpectQueryResult().Errors); + } + + [Fact(Skip = "Do we want to reformat ids?")] + public async Task Authors_And_Reviews_Query_Reformat_AuthorIds() + { + // arrange + using var demoProject = await DemoProject.CreateAsync(); + + // act + var fusionGraph = + await new FusionGraphComposer(logFactory: _logFactory) + .ComposeAsync( + new[] + { + demoProject.Reviews.ToConfiguration(ReviewsExtensionSdl), + demoProject.Accounts.ToConfiguration(AccountsExtensionSdl), + }, + new FusionFeatureCollection(FusionFeatures.NodeField)); + + var executor = await new ServiceCollection() + .AddSingleton(demoProject.HttpClientFactory) + .AddSingleton(demoProject.WebSocketConnectionFactory) + .AddFusionGatewayServer() + .ConfigureFromDocument(SchemaFormatter.FormatAsDocument(fusionGraph)) + .BuildRequestExecutorAsync(); + + var request = Parse( + """ + query ReformatIds { + reviews { + author { + id + } + } + } + """); + + // act + await using var result = await executor.ExecuteAsync( + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -503,10 +553,10 @@ query ReformatIds { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -554,10 +604,10 @@ query GetUser { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -606,10 +656,10 @@ query TopProducts { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -659,10 +709,10 @@ query TopProducts { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -705,11 +755,11 @@ query TopProducts($first: Int!) { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("first", 2) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "first", 2 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -762,10 +812,10 @@ query Introspect { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -813,11 +863,11 @@ ... on User { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", id) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -863,11 +913,11 @@ ... on User { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -913,11 +963,11 @@ ... on User { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", id) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -965,11 +1015,11 @@ ... on User { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", id) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1018,11 +1068,11 @@ ... on User { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", id) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", id }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1071,10 +1121,10 @@ public async Task Hot_Reload() var executorProxy = new RequestExecutorProxy(executorResolver, Schema.DefaultName); var result = await executorProxy.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); var snapshot = new Snapshot(); snapshot.Add(result, "1. Version"); @@ -1094,10 +1144,10 @@ public async Task Hot_Reload() SchemaFormatter.FormatAsDocument(fusionGraph))); result = await executorProxy.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); snapshot.Add(result, "2. Version"); @@ -1136,10 +1186,10 @@ query Introspect { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -1187,12 +1237,11 @@ query ProductReviews( // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1240,12 +1289,16 @@ public async Task Forward_Nested_Variables_No_OpName() // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues( + new Dictionary + { + { "id", "UHJvZHVjdDox" }, + { "first", 1 }, + }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1297,12 +1350,11 @@ public async Task Forward_Nested_Variables_No_OpName_Two_RootSelections() // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1352,12 +1404,11 @@ ... on Product { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1409,12 +1460,11 @@ query ProductReviews( // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1470,12 +1520,11 @@ query Requires { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1530,12 +1579,11 @@ query Requires { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1596,12 +1644,11 @@ query Large { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1644,11 +1691,11 @@ query AfterNull($after: String) { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("after", null) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "after", null }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1700,12 +1747,11 @@ query TopProducts { // act await using var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("id", "UHJvZHVjdDox") - .SetVariableValue("first", 1) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "id", "UHJvZHVjdDox" }, { "first", 1 }, }) + .Build()); // assert var snapshot = new Snapshot(); @@ -1756,10 +1802,7 @@ public void Update() _observer.OnNext(_owner._configuration); } - public void Dispose() - { - - } + public void Dispose() { } } } } diff --git a/src/HotChocolate/Fusion/test/Core.Tests/ErrorTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/ErrorTests.cs index 44db81eec68..440b93e5d01 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/ErrorTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/ErrorTests.cs @@ -56,10 +56,10 @@ public async Task TopLevelResolveSubgraphError() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -107,10 +107,10 @@ public async Task NestedResolveSubgraphError() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -160,10 +160,10 @@ public async Task NestedResolveWithListSubgraphError() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -211,10 +211,10 @@ public async Task ResolveByKeySubgraphError() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -261,10 +261,10 @@ query ReformatIds { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -311,10 +311,10 @@ query ReformatIds { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -361,10 +361,10 @@ query ReformatIds { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -410,10 +410,10 @@ query A { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert result.MatchSnapshot(); diff --git a/src/HotChocolate/Fusion/test/Core.Tests/EventStreamTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/EventStreamTests.cs index b45f5094951..51ca7d3951f 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/EventStreamTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/EventStreamTests.cs @@ -54,10 +54,10 @@ subscription OnNewReview { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build(), cts.Token); // assert diff --git a/src/HotChocolate/Fusion/test/Core.Tests/FileUploadTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/FileUploadTests.cs index adc20e300fd..238329f8485 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/FileUploadTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/FileUploadTests.cs @@ -81,11 +81,11 @@ mutation Upload($file: Upload!) { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("file", new StreamFile("abc", () => stream)) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { {"file", new StreamFile("abc", () => stream) }, }) + .Build(), cts.Token); // assert @@ -137,11 +137,11 @@ mutation Upload($input: UploadProductPictureInput!) { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("input", input) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { {"input", input }, }) + .Build(), cts.Token); // assert @@ -201,11 +201,11 @@ mutation UploadMultiple($input: UploadMultipleProductPicturesInput!) { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("input", input) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { { "input", input } }) + .Build(), cts.Token); // assert diff --git a/src/HotChocolate/Fusion/test/Core.Tests/InterfaceTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/InterfaceTests.cs index 771a5e48b80..81b1b169ec3 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/InterfaceTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/InterfaceTests.cs @@ -57,10 +57,10 @@ query Appointments { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -110,10 +110,10 @@ ... on Patient1 { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); @@ -165,10 +165,10 @@ ... on Patient1 { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); diff --git a/src/HotChocolate/Fusion/test/Core.Tests/IntrospectionTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/IntrospectionTests.cs index d63adde3781..785c7f26249 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/IntrospectionTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/IntrospectionTests.cs @@ -40,10 +40,10 @@ public async Task ShortCircuit_RootTypeName_Requests() // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .Create()); + OperationRequestBuilder + .Create() + .SetDocument(request) + .Build()); // assert var snapshot = new Snapshot(); diff --git a/src/HotChocolate/Fusion/test/Core.Tests/UnionTests.cs b/src/HotChocolate/Fusion/test/Core.Tests/UnionTests.cs index c5278be5cbd..4fbc19e7fe5 100644 --- a/src/HotChocolate/Fusion/test/Core.Tests/UnionTests.cs +++ b/src/HotChocolate/Fusion/test/Core.Tests/UnionTests.cs @@ -71,11 +71,11 @@ ... on ProductNotFoundError { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("input", input) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { {"input", input }, }) + .Build(), cts.Token); // assert @@ -133,11 +133,11 @@ ... on ProductNotFoundError { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("input", input) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { {"input", input}, }) + .Build(), cts.Token); // assert @@ -192,11 +192,11 @@ mutation Upload($input: UploadProductPictureInput!) { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("input", input) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { {"input", input}, }) + .Build(), cts.Token); // assert @@ -251,11 +251,11 @@ mutation Upload($input: UploadProductPictureInput!) { // act var result = await executor.ExecuteAsync( - QueryRequestBuilder - .New() - .SetQuery(request) - .SetVariableValue("input", input) - .Create(), + OperationRequestBuilder + .Create() + .SetDocument(request) + .SetVariableValues(new Dictionary { {"input", input}, }) + .Build(), cts.Token); // assert diff --git a/src/HotChocolate/Language/src/Language.Web/GraphQLRequest.cs b/src/HotChocolate/Language/src/Language.Web/GraphQLRequest.cs index dcd2be453c3..11a4b30b4ff 100644 --- a/src/HotChocolate/Language/src/Language.Web/GraphQLRequest.cs +++ b/src/HotChocolate/Language/src/Language.Web/GraphQLRequest.cs @@ -1,5 +1,8 @@ namespace HotChocolate.Language; +/// +/// Represents the parsed GraphQL request JSON object. +/// public sealed class GraphQLRequest { public GraphQLRequest( @@ -7,7 +10,7 @@ public GraphQLRequest( string? queryId = null, string? queryHash = null, string? operationName = null, - IReadOnlyDictionary? variables = null, + IReadOnlyList>? variables = null, IReadOnlyDictionary? extensions = null) { if (query is null && queryId is null) @@ -31,7 +34,7 @@ public GraphQLRequest( public string? OperationName { get; } - public IReadOnlyDictionary? Variables { get; } + public IReadOnlyList>? Variables { get; } public IReadOnlyDictionary? Extensions { get; } } diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Json.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Json.cs index 2e0e4bfabe0..6107833a80a 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Json.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Json.cs @@ -92,7 +92,7 @@ public ref partial struct Utf8GraphQLRequestParser return parser.ParseObjectOrNull(); } - public static unsafe IReadOnlyDictionary? ParseVariables( + public static unsafe IReadOnlyList>? ParseVariables( string sourceText, ParserOptions? options = null) { @@ -125,7 +125,7 @@ public ref partial struct Utf8GraphQLRequestParser } } - public static IReadOnlyDictionary? ParseVariables( + public static IReadOnlyList>? ParseVariables( ReadOnlySpan sourceText, ParserOptions? options = null) { diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Request.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Request.cs index 48d28b2c539..d336fa30680 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Request.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Request.cs @@ -14,7 +14,7 @@ private ref struct Request public bool HasQuery { get; set; } - public IReadOnlyDictionary? Variables { get; set; } + public IReadOnlyList>? Variables { get; set; } public IReadOnlyDictionary? Extensions { get; set; } diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs index 583437d83f5..d1feeebfea1 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs @@ -41,7 +41,36 @@ public ref partial struct Utf8GraphQLRequestParser } } - private IReadOnlyDictionary? ParseVariables() + private IReadOnlyList>? ParseVariables() + { + switch (_reader.Kind) + { + case TokenKind.LeftBrace: + return new[] { ParseVariablesObject(), }; + + case TokenKind.LeftBracket: + var list = new List>(); + _reader.Expect(TokenKind.LeftBracket); + + while (_reader.Kind != TokenKind.RightBracket) + { + list.Add(ParseObject()); + } + + _reader.Expect(TokenKind.RightBracket); + + return list; + + case TokenKind.Name when _reader.Value.SequenceEqual(GraphQLKeywords.Null): + _reader.MoveNext(); + return null; + + default: + throw ThrowHelper.ExpectedObjectOrNull(_reader); + } + } + + private IReadOnlyDictionary ParseVariablesObject() { switch (_reader.Kind) { @@ -73,10 +102,6 @@ public ref partial struct Utf8GraphQLRequestParser return obj; - case TokenKind.Name when _reader.Value.SequenceEqual(GraphQLKeywords.Null): - _reader.MoveNext(); - return null; - default: throw ThrowHelper.ExpectedObjectOrNull(_reader); } diff --git a/src/HotChocolate/Language/test/Language.Tests/Parser/GraphQLRequestParserTests.cs b/src/HotChocolate/Language/test/Language.Tests/Parser/GraphQLRequestParserTests.cs index b8f1c9f21e4..943d48cfd19 100644 --- a/src/HotChocolate/Language/test/Language.Tests/Parser/GraphQLRequestParserTests.cs +++ b/src/HotChocolate/Language/test/Language.Tests/Parser/GraphQLRequestParserTests.cs @@ -584,7 +584,7 @@ public void Parse_Apollo_AQP_SignatureQuery_Variables_Without_Values() { Assert.Null(r.OperationName); Assert.Equal("hashOfQuery", r.QueryId); - Assert.Empty(r.Variables!); + Assert.Collection(r.Variables!, Assert.Empty); Assert.True(r.Extensions!.ContainsKey("persistedQuery")); Assert.Null(r.Query); Assert.Null(r.QueryHash); @@ -613,7 +613,7 @@ public void Parse_Apollo_AQP_FullRequest_And_Verify_Hash() r => { Assert.Null(r.OperationName); - Assert.Empty(r.Variables!); + Assert.Collection(r.Variables!, Assert.Empty); Assert.True(r.Extensions!.ContainsKey("persistedQuery")); Assert.NotNull(r.Query); diff --git a/src/HotChocolate/Language/test/Language.Tests/Parser/__snapshots__/GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache.snap b/src/HotChocolate/Language/test/Language.Tests/Parser/__snapshots__/GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache.snap index c8ccbec6058..ad676fcfb16 100644 --- a/src/HotChocolate/Language/test/Language.Tests/Parser/__snapshots__/GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache.snap +++ b/src/HotChocolate/Language/test/Language.Tests/Parser/__snapshots__/GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache.snap @@ -1,104 +1,106 @@ Variables: --------------- -{ - "a": { - "Kind": "StringValue", - "Location": null, - "Value": "b", - "Block": false - }, - "b": { - "Kind": "ObjectValue", - "Location": null, - "Fields": [ - { - "Kind": "ObjectField", - "Location": null, - "Name": { - "Kind": "Name", +[ + { + "a": { + "Kind": "StringValue", + "Location": null, + "Value": "b", + "Block": false + }, + "b": { + "Kind": "ObjectValue", + "Location": null, + "Fields": [ + { + "Kind": "ObjectField", "Location": null, - "Value": "a" + "Name": { + "Kind": "Name", + "Location": null, + "Value": "a" + }, + "Value": { + "Kind": "StringValue", + "Location": null, + "Value": "b", + "Block": false + } }, - "Value": { - "Kind": "StringValue", - "Location": null, - "Value": "b", - "Block": false - } - }, - { - "Kind": "ObjectField", - "Location": null, - "Name": { - "Kind": "Name", + { + "Kind": "ObjectField", "Location": null, - "Value": "b" + "Name": { + "Kind": "Name", + "Location": null, + "Value": "b" + }, + "Value": { + "Kind": "BooleanValue", + "Location": null, + "Value": true + } }, - "Value": { - "Kind": "BooleanValue", - "Location": null, - "Value": true - } - }, - { - "Kind": "ObjectField", - "Location": null, - "Name": { - "Kind": "Name", + { + "Kind": "ObjectField", "Location": null, - "Value": "c" + "Name": { + "Kind": "Name", + "Location": null, + "Value": "c" + }, + "Value": { + "Kind": "IntValue", + "Location": null, + "Value": "1" + } }, - "Value": { - "Kind": "IntValue", + { + "Kind": "ObjectField", "Location": null, - "Value": "1" + "Name": { + "Kind": "Name", + "Location": null, + "Value": "d" + }, + "Value": { + "Kind": "FloatValue", + "Location": null, + "Format": "FixedPoint", + "Value": "1.1" + } } - }, - { - "Kind": "ObjectField", - "Location": null, - "Name": { - "Kind": "Name", - "Location": null, - "Value": "d" - }, - "Value": { - "Kind": "FloatValue", + ] + }, + "c": { + "Kind": "ListValue", + "Location": null, + "Items": [ + { + "Kind": "ObjectValue", "Location": null, - "Format": "FixedPoint", - "Value": "1.1" - } - } - ] - }, - "c": { - "Kind": "ListValue", - "Location": null, - "Items": [ - { - "Kind": "ObjectValue", - "Location": null, - "Fields": [ - { - "Kind": "ObjectField", - "Location": null, - "Name": { - "Kind": "Name", - "Location": null, - "Value": "a" - }, - "Value": { - "Kind": "StringValue", + "Fields": [ + { + "Kind": "ObjectField", "Location": null, - "Value": "b", - "Block": false + "Name": { + "Kind": "Name", + "Location": null, + "Value": "a" + }, + "Value": { + "Kind": "StringValue", + "Location": null, + "Value": "b", + "Block": false + } } - } - ] - } - ] + ] + } + ] + } } -} +] --------------- Extensions: diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilterVisitorTestBase.cs index f1a76630fb2..5640fb7716f 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilterVisitorTestBase.cs @@ -68,10 +68,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilteringAndPaging.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilteringAndPaging.cs index 8ecfaf173be..34a1f4777f8 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilteringAndPaging.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/FilteringAndPaging.cs @@ -17,14 +17,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/IntegrationTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/IntegrationTests.cs index 0c1e64d8cfb..e574b87fae7 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/IntegrationTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/IntegrationTests.cs @@ -40,10 +40,10 @@ public async Task Ensure_Marten_Works() await using (var scope = services.CreateAsyncScope()) { - var request = QueryRequestBuilder.New() + var request = OperationRequestBuilder.Create() .SetServices(scope.ServiceProvider) - .SetQuery("{ foos { nodes { id } } }") - .Create(); + .SetDocument("{ foos { nodes { id } } }") + .Build(); var executor = await scope.ServiceProvider.GetRequestExecutorAsync(); snapshot.Add(await executor.ExecuteAsync(request)); diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorBooleanTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorBooleanTests.cs index f94fdf24598..e3cd4431c3b 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorBooleanTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorBooleanTests.cs @@ -28,14 +28,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -53,14 +53,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -78,19 +78,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -110,19 +110,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorComparableTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorComparableTests.cs index 9b26f43e60a..545d67e5517 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorComparableTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorComparableTests.cs @@ -35,19 +35,19 @@ public async Task Create_ShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -69,19 +69,19 @@ public async Task Create_ShortNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -103,24 +103,24 @@ public async Task Create_ShortGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -144,24 +144,24 @@ public async Task Create_ShortNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -186,24 +186,24 @@ public async Task Create_ShortGreaterThanOrEquals_Expression() // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -227,24 +227,24 @@ public async Task Create_ShortNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -268,24 +268,24 @@ public async Task Create_ShortLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -309,24 +309,24 @@ public async Task Create_ShortNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -351,24 +351,24 @@ public async Task Create_ShortLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -392,24 +392,24 @@ public async Task Create_ShortNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -433,19 +433,19 @@ public async Task Create_ShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -467,19 +467,19 @@ public async Task Create_ShortNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -501,19 +501,19 @@ public async Task Create_ShortNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -535,19 +535,19 @@ public async Task Create_ShortNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -570,24 +570,24 @@ public async Task Create_ShortNullableGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -611,24 +611,24 @@ public async Task Create_ShortNullableNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -653,24 +653,24 @@ public async Task Create_ShortNullableGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -694,24 +694,24 @@ public async Task Create_ShortNullableNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -735,24 +735,24 @@ public async Task Create_ShortNullableLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -776,24 +776,24 @@ public async Task Create_ShortNullableNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -818,24 +818,24 @@ public async Task Create_ShortNullableLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -859,24 +859,24 @@ public async Task Create_ShortNullableNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -900,19 +900,19 @@ public async Task Create_ShortNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -934,19 +934,19 @@ public async Task Create_ShortNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorEnumTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorEnumTests.cs index 19447a9e8b5..10ad18a218d 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorEnumTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorEnumTests.cs @@ -39,19 +39,19 @@ public async Task Create_EnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -73,19 +73,19 @@ public async Task Create_EnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }){ barEnum } }") + .Build()); // assert await Snapshot @@ -107,19 +107,19 @@ public async Task Create_EnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -141,19 +141,19 @@ public async Task Create_EnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -176,19 +176,19 @@ public async Task Create_NullableEnumEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }){ barEnum } }") + .Build()); // assert await Snapshot @@ -210,19 +210,19 @@ public async Task Create_NullableEnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -244,19 +244,19 @@ public async Task Create_NullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -278,19 +278,19 @@ public async Task Create_NullableEnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorExecutableTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorExecutableTests.cs index a0d044007e6..13cf082daa9 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorExecutableTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorExecutableTests.cs @@ -35,14 +35,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "true").AddResult(res2, "false") @@ -57,14 +57,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -80,19 +80,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -111,19 +111,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs index f1f37aa3e59..668ca3da6e7 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs @@ -32,25 +32,25 @@ public async Task Create_InterfaceStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"a\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"b\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: null}}}) " + "{ test{ prop}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorListTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorListTests.cs index afc7c1ce9e9..2ade80ce548 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorListTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorListTests.cs @@ -71,22 +71,22 @@ public async Task Create_ArrayAllObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -108,8 +108,8 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { fooNested: { @@ -125,19 +125,19 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() } } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -156,22 +156,22 @@ public async Task Create_ArrayNoneObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot.Create().AddResult( @@ -192,16 +192,16 @@ public async Task Create_ArrayAnyObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorObjectTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorObjectTests.cs index b5dbea8362d..be02d815557 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorObjectTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorObjectTests.cs @@ -122,25 +122,25 @@ public async Task Create_ObjectShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -162,25 +162,25 @@ public async Task Create_ObjectShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -202,25 +202,25 @@ public async Task Create_ObjectNullableShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -242,25 +242,25 @@ public async Task Create_ObjectNullableShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, null ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -282,18 +282,18 @@ public async Task Create_ObjectBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -313,25 +313,25 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: null}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -353,25 +353,25 @@ public async Task Create_ObjectEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -393,25 +393,25 @@ public async Task Create_ObjectEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -434,25 +434,25 @@ public async Task Create_ObjectNullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -474,25 +474,25 @@ public async Task Create_ObjectNullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -514,24 +514,24 @@ public async Task Create_ObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testatest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testbtest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: null}}}){ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -553,26 +553,26 @@ public async Task Create_ObjectStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: " + "[ \"testatest\" \"testbtest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [\"testbtest\" null]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [ \"testatest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -594,28 +594,28 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"a\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"d\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: null}}}}}}) " + "{ foo { objectArray { foo {barString}}}}}") - .Create()); + .Build()); // assert await Snapshot @@ -637,25 +637,25 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: false}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: true}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: null}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorStringTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorStringTests.cs index 76539c35f0c..eb4e6b3692d 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorStringTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Filters.Tests/QueryableFilterVisitorStringTests.cs @@ -15,8 +15,8 @@ public class QueryableFilterVisitorStringTests private static readonly FooNullable[] _fooNullableEntities = [ - new() { Bar = "testatest", }, - new() { Bar = "testbtest", }, + new() { Bar = "testatest", }, + new() { Bar = "testbtest", }, new() { Bar = null, }, ]; @@ -35,26 +35,26 @@ public async Task Create_StringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( """ { - root(where: { bar: { eq: "testatest"}}) { + root(where: { bar: { eq: "testatest"}}) { bar } } """) - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot.Create() @@ -72,19 +72,19 @@ public async Task Create_StringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot.Create() @@ -102,20 +102,20 @@ public async Task Create_StringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create() @@ -133,20 +133,20 @@ public async Task Create_StringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -165,19 +165,19 @@ public async Task Create_StringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -196,19 +196,19 @@ public async Task Create_StringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -228,19 +228,19 @@ public async Task Create_StringStartsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -259,19 +259,19 @@ public async Task Create_StringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -290,19 +290,19 @@ public async Task Create_StringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( @@ -321,19 +321,19 @@ public async Task Create_StringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( @@ -352,19 +352,19 @@ public async Task Create_NullableStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatest").AddResult( @@ -384,19 +384,19 @@ public async Task Create_NullableStringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatest").AddResult( @@ -415,20 +415,20 @@ public async Task Create_NullableStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -448,20 +448,20 @@ public async Task Create_NullableStringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -481,19 +481,19 @@ public async Task Create_NullableStringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -512,19 +512,19 @@ public async Task Create_NullableStringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -544,19 +544,19 @@ public async Task Create_NullableStringStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -576,19 +576,19 @@ public async Task Create_NullableStringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -608,19 +608,19 @@ public async Task Create_NullableStringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( @@ -641,19 +641,19 @@ public async Task Create_NullableStringNotEndsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorBooleanTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorBooleanTests.cs index 1be5c8a5c06..668a139d49a 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorBooleanTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorBooleanTests.cs @@ -29,14 +29,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -54,14 +54,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert await Snapshot @@ -80,14 +80,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorComparableTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorComparableTests.cs index e6ccc04a032..814f07bcbed 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorComparableTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorComparableTests.cs @@ -35,14 +35,14 @@ public async Task Create_Short_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -65,14 +65,14 @@ public async Task Create_Short_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorEnumTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorEnumTests.cs index e60da877795..96f9b06706a 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorEnumTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorEnumTests.cs @@ -39,14 +39,14 @@ public async Task Create_Enum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -69,14 +69,14 @@ public async Task Create_Enum_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExecutableTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExecutableTests.cs index 531cf7415c1..faca43b4819 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExecutableTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExecutableTests.cs @@ -29,14 +29,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -58,14 +58,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert res1.MatchSnapshot("ASC"); @@ -81,14 +81,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExpressionTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExpressionTests.cs index a657ea7e235..50d26a48c66 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExpressionTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorExpressionTests.cs @@ -58,14 +58,14 @@ public async Task Create_CollectionLengthExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: ASC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: ASC}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: DESC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: DESC}){ name lastName}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorObjectTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorObjectTests.cs index 2104781cd85..0bc85331078 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorObjectTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorObjectTests.cs @@ -5,11 +5,11 @@ namespace HotChocolate.Data; [Collection(SchemaCacheCollectionFixture.DefinitionName)] -public class QueryableSortVisitorObjectTests +public class QueryableSortVisitorObjectTests(SchemaCache cache) { private static readonly Bar[] _barEntities = [ - new() + new Bar { Foo = new Foo { @@ -23,7 +23,7 @@ public class QueryableSortVisitorObjectTests }, }, }, - new() + new Bar { Foo = new Foo { @@ -45,7 +45,7 @@ public class QueryableSortVisitorObjectTests }, }, }, - new() + new Bar { Foo = new Foo { @@ -61,7 +61,7 @@ public class QueryableSortVisitorObjectTests private static readonly BarNullable[] _barNullableEntities = [ - new() + new BarNullable { Foo = new FooNullable { @@ -83,7 +83,7 @@ public class QueryableSortVisitorObjectTests }, }, }, - new() + new BarNullable { Foo = new FooNullable { @@ -105,7 +105,7 @@ public class QueryableSortVisitorObjectTests }, }, }, - new() + new BarNullable { Foo = new FooNullable { @@ -127,7 +127,7 @@ public class QueryableSortVisitorObjectTests }, }, }, - new() + new BarNullable { Foo = new FooNullable { @@ -139,46 +139,35 @@ public class QueryableSortVisitorObjectTests ObjectArray = null, }, }, - new() { Foo = null, }, + new BarNullable { Foo = null, }, ]; - private readonly SchemaCache _cache; - - public QueryableSortVisitorObjectTests(SchemaCache cache) - { - _cache = cache; - } - [Fact] public async Task Create_ObjectShort_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -187,32 +176,28 @@ public async Task Create_ObjectNullableShort_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -220,32 +205,28 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectEnum_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -254,32 +235,28 @@ public async Task Create_ObjectNullableEnum_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -287,32 +264,28 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectString_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -321,32 +294,28 @@ public async Task Create_ObjectNullableString_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -354,32 +323,28 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectBool_OrderBy() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "DESC") .MatchAsync(); } @@ -388,32 +353,28 @@ public async Task Create_ObjectNullableBool_OrderBy() { // arrange var tester = - _cache.CreateSchema(_barNullableEntities); + cache.CreateSchema(_barNullableEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "13") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "13") .MatchAsync(); } @@ -421,19 +382,19 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectString_OrderBy_TwoProperties() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC, barShort: ASC }}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -446,18 +407,18 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC, barShort: DESC}}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -470,23 +431,15 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "ASC"), - res3, - "DESC"), - res4, - "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "ASC") + .AddResult(res3, "DESC") + .AddResult(res4, "DESC") .MatchAsync(); } @@ -494,144 +447,149 @@ await SnapshotExtensions.AddResult( public async Task Create_ObjectString_OrderBy_TwoProperties_Variables() { // arrange - var tester = _cache.CreateSchema(_barEntities); + var tester = cache.CreateSchema(_barEntities); // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @" - query testSort($order: [BarSortInput!]) { - root(order: $order) { - foo { - barBool - barShort - } + OperationRequestBuilder.Create() + .SetDocument( + """ + query testSort($order: [BarSortInput!]) { + root(order: $order) { + foo { + barBool + barShort } - }") - .SetVariableValue( - "order", - new List> + } + } + """) + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", - new Dictionary { - { "barShort", "ASC" }, { "barBool", "ASC" }, - } + "foo", + new Dictionary + { + { "barShort", "ASC" }, { "barBool", "ASC" }, + } + }, }, - }, + } }) - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @" - query testSort($order: [BarSortInput!]) { - root(order: $order) { - foo { - barBool - barShort - } + OperationRequestBuilder.Create() + .SetDocument( + """ + query testSort($order: [BarSortInput!]) { + root(order: $order) { + foo { + barBool + barShort } - }") - .SetVariableValue( - "order", - new List> + } + } + """) + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", new Dictionary { { "barShort", "ASC" }, } + { + "foo", new Dictionary { { "barShort", "ASC" }, } + }, }, - }, - new() - { + new() { - "foo", new Dictionary { { "barBool", "ASC" }, } + { + "foo", new Dictionary { { "barBool", "ASC" }, } + }, }, - }, + } }) - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @" - query testSort($order: [BarSortInput!]) { - root(order: $order) { - foo { - barBool - barShort - } + OperationRequestBuilder.Create() + .SetDocument( + """ + query testSort($order: [BarSortInput!]) { + root(order: $order) { + foo { + barBool + barShort } - }") - .SetVariableValue( - "order", - new List> + } + } + """) + .SetVariableValues( + new Dictionary { - new() - { + ["order"] = + new List> { - "foo", - new Dictionary + new() { - { "barShort", "DESC" }, { "barBool", "DESC" }, - } - }, - }, + { + "foo", + new Dictionary + { + { "barShort", "DESC" }, { "barBool", "DESC" }, + } + }, + }, + } }) - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( - @" - query testSort($order: [BarSortInput!]) { - root(order: $order) { - foo { - barBool - barShort - } + OperationRequestBuilder.Create() + .SetDocument( + """ + query testSort($order: [BarSortInput!]) { + root(order: $order) { + foo { + barBool + barShort } - }") - .SetVariableValue( - "order", - new List> + } + } + """) + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", new Dictionary { { "barShort", "DESC" }, } + { + "foo", new Dictionary { { "barShort", "DESC" }, } + }, }, - }, - new() - { + new() { - "foo", new Dictionary { { "barBool", "DESC" }, } + { + "foo", new Dictionary { { "barBool", "DESC" }, } + }, }, - }, + } }) - .Create()); + .Build()); // assert - await SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - SnapshotExtensions.AddResult( - Snapshot - .Create(), - res1, - "ASC"), - res2, - "ASC"), - res3, - "DESC"), - res4, - "DESC") + await Snapshot + .Create() + .AddResult(res1, "ASC") + .AddResult(res2, "ASC") + .AddResult(res3, "DESC") + .AddResult(res4, "DESC") .MatchAsync(); } @@ -685,15 +643,9 @@ public class BarNullable public FooNullable? Foo { get; set; } } - public class BarSortType - : SortInputType - { - } + public class BarSortType : SortInputType; - public class BarNullableSortType - : SortInputType - { - } + public class BarNullableSortType : SortInputType; public enum BarEnum { @@ -702,4 +654,4 @@ public enum BarEnum BAZ, QUX, } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorStringTests.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorStringTests.cs index 60516b6f6b5..720a9a61020 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorStringTests.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/QueryableSortVisitorStringTests.cs @@ -32,14 +32,14 @@ public async Task Create_String_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -62,14 +62,14 @@ public async Task Create_String_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/SortVisitorTestBase.cs b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/SortVisitorTestBase.cs index 254fa737b7c..046cfa6dafb 100644 --- a/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/SortVisitorTestBase.cs +++ b/src/HotChocolate/Marten/test/Data.Marten.Sorting.Tests/SortVisitorTestBase.cs @@ -125,10 +125,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/FilterVisitorTestBase.cs index df1b31f019c..1106ecc248c 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/FilterVisitorTestBase.cs @@ -60,10 +60,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbAggregateFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbAggregateFluentTests.cs index 2201f961be7..a4cf88abb39 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbAggregateFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbAggregateFluentTests.cs @@ -47,14 +47,14 @@ public async Task BsonElement_Rename() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -83,14 +83,14 @@ public async Task AggregateFluent_Serializer() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { baz: { eq: \"2020-01-11T00:00:00Z\"}}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { baz: { eq: \"2020-01-11T00:00:00Z\"}}){ baz}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { baz: { eq: \"2020-01-12T00:00:00Z\"}}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { baz: { eq: \"2020-01-12T00:00:00Z\"}}){ baz}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -147,10 +147,10 @@ private static IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbCollectionTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbCollectionTests.cs index 116df43a52e..5305733ad72 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbCollectionTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbCollectionTests.cs @@ -46,14 +46,14 @@ public async Task BsonElement_Rename() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -83,14 +83,14 @@ public async Task Collection_Serializer() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { baz: { eq: \"2020-01-11T00:00:00Z\"}}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { baz: { eq: \"2020-01-11T00:00:00Z\"}}){ baz}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { baz: { eq: \"2020-01-12T00:00:00Z\"}}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { baz: { eq: \"2020-01-12T00:00:00Z\"}}){ baz}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -146,10 +146,10 @@ private static IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterCombinatorTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterCombinatorTests.cs index d414a262050..a254b946ed1 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterCombinatorTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterCombinatorTests.cs @@ -12,7 +12,7 @@ public class MongoDbFilterCombinatorTests { private static readonly Foo[] _fooEntities = [ - new() { Bar = true, }, + new() { Bar = true, }, new() { Bar = false, }, ]; @@ -30,9 +30,9 @@ public async Task Create_Empty_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { }){ bar }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { }){ bar }}") + .Build()); await Snapshot.Create() .Add(res1) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorBooleanTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorBooleanTests.cs index 75a88a6025d..1f30b3a2402 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorBooleanTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorBooleanTests.cs @@ -37,14 +37,14 @@ public async Task Create_BooleanEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -63,14 +63,14 @@ public async Task Create_BooleanNotEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -89,19 +89,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -121,19 +121,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorComparableTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorComparableTests.cs index bbf45ff5552..37c1f2ae79e 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorComparableTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorComparableTests.cs @@ -39,7 +39,7 @@ public class MongoDbFilterVisitorComparableTests }, new FooNullable { - BarShort = null, + BarShort = null, BarDateTime = null, }, new FooNullable @@ -67,21 +67,21 @@ public async Task Create_ShortEqual_Expression_DateTime() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00Z\"}})" + + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00Z\"}})" + "{ barDateTime}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00Z\"}})" + + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00Z\"}})" + "{ barDateTime}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barDateTime: { eq: null}}){ barDateTime}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barDateTime: { eq: null}}){ barDateTime}}") + .Build()); // assert await Snapshot @@ -101,21 +101,21 @@ public async Task Create_ShortEqual_Expression_DateTime_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00:00Z\"}})" + + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00:00Z\"}})" + "{ barDateTime}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00:00Z\"}})" + + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barDateTime: { eq: \"2000-01-12T00:00:00Z\"}})" + "{ barDateTime}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barDateTime: { eq: null}}){ barDateTime}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barDateTime: { eq: null}}){ barDateTime}}") + .Build()); // assert await Snapshot @@ -144,7 +144,7 @@ public async Task Create_ShortEqual_Expression() var res2 = await tester.ExecuteAsync( """ - { + { root(where: { barShort: { eq: 13 } }) { barShort } @@ -153,8 +153,8 @@ public async Task Create_ShortEqual_Expression() var res3 = await tester.ExecuteAsync( """ - { - root(where: { barShort: { eq: null } }) { + { + root(where: { barShort: { eq: null } }) { barShort } } @@ -177,19 +177,19 @@ public async Task Create_ShortNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -209,24 +209,24 @@ public async Task Create_ShortGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -246,24 +246,24 @@ public async Task Create_ShortNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -284,24 +284,24 @@ public async Task Create_ShortGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -321,24 +321,24 @@ public async Task Create_ShortNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -358,24 +358,24 @@ public async Task Create_ShortLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -395,24 +395,24 @@ public async Task Create_ShortNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -429,24 +429,24 @@ public async Task Create_ShortLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -466,24 +466,24 @@ public async Task Create_ShortNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -503,19 +503,19 @@ public async Task Create_ShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -531,19 +531,19 @@ public async Task Create_ShortNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -563,19 +563,19 @@ public async Task Create_ShortNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -594,19 +594,19 @@ public async Task Create_ShortNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -616,7 +616,7 @@ await Snapshot .AddResult(res3, "null") .MatchAsync(); } - + [Fact] public async Task Create_ShortNullableGreaterThan_Expression() { @@ -625,24 +625,24 @@ public async Task Create_ShortNullableGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -661,24 +661,24 @@ public async Task Create_ShortNullableNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -698,24 +698,24 @@ public async Task Create_ShortNullableGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -735,24 +735,24 @@ public async Task Create_ShortNullableNotGreaterThanOrEquals_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -772,24 +772,24 @@ public async Task Create_ShortNullableLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -809,24 +809,24 @@ public async Task Create_ShortNullableNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -847,24 +847,24 @@ public async Task Create_ShortNullableLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -884,24 +884,24 @@ public async Task Create_ShortNullableNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -921,19 +921,19 @@ public async Task Create_ShortNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -952,19 +952,19 @@ public async Task Create_ShortNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorDateOnlyTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorDateOnlyTests.cs index 1472698f823..baecbd19cfc 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorDateOnlyTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorDateOnlyTests.cs @@ -43,14 +43,14 @@ public async Task Create_DateOnlyEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"2022-01-16\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"2022-01-16\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"2022-01-15\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"2022-01-15\" } }){ bar } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -68,14 +68,14 @@ public async Task Create_DateOnlyNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"2022-01-15\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"2022-01-15\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"2022-01-16\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"2022-01-16\" } }){ bar } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -94,19 +94,19 @@ public async Task Create_NullableDateOnlyEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"2022-01-16\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"2022-01-16\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"2022-01-15\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"2022-01-15\" } }){ bar } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null } }){ bar } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -127,19 +127,19 @@ public async Task Create_NullableDateOnlyNotEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"2022-01-15\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"2022-01-15\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"2022-01-16\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"2022-01-16\" } }){ bar } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null } }){ bar } }") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorEnumTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorEnumTests.cs index 9135b35cc4f..6c7cc029a05 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorEnumTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorEnumTests.cs @@ -40,19 +40,19 @@ public async Task Create_EnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }) { barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -71,19 +71,19 @@ public async Task Create_EnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }){ barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -102,19 +102,19 @@ public async Task Create_EnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -133,19 +133,19 @@ public async Task Create_EnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -164,19 +164,19 @@ public async Task Create_NullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }){ barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -195,19 +195,19 @@ public async Task Create_NullableEnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }) { barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -226,19 +226,19 @@ public async Task Create_NullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -257,19 +257,19 @@ public async Task Create_NullableEnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorListTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorListTests.cs index ffa068bba57..175676c32dc 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorListTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorListTests.cs @@ -125,8 +125,8 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { fooNested: { @@ -142,19 +142,19 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() } } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -173,22 +173,22 @@ public async Task Create_ArrayNoneObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -207,22 +207,22 @@ public async Task Create_ArrayAllObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { all: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -241,19 +241,19 @@ public async Task Create_ArrayAnyObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { fooNested: { all: null}}){ fooNested {bar}}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { fooNested: { all: null}}){ fooNested {bar}}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -273,8 +273,8 @@ public async Task Create_ArraySomeStringEqualWithNull_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -286,19 +286,19 @@ public async Task Create_ArraySomeStringEqualWithNull_Expression() bar } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { some: { eq: \"d\"}}}){ bar }}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { some: { eq: null}}}){ bar }}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -317,22 +317,22 @@ public async Task Create_ArrayNoneStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { none: { eq: \"a\"}}}){ bar }}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { none: { eq: \"d\"}}}){ bar }}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { none: { eq: null}}}){ bar }}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -351,22 +351,22 @@ public async Task Create_ArrayAllStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { all: { eq: \"a\"}}}){ bar }}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { all: { eq: \"d\"}}}){ bar }}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { all: { eq: null}}}){ bar }}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -385,19 +385,19 @@ public async Task Create_ArrayAnyStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { any: false}}){ bar }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { any: false}}){ bar }}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { any: true}}){ bar }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { any: true}}){ bar }}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { all: null}}){ bar }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { all: null}}){ bar }}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectIdTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectIdTests.cs index 08f0d7305f8..93a2721b1fa 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectIdTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectIdTests.cs @@ -39,22 +39,22 @@ public async Task Create_ObjectIdEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { eq: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { eq: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { eq: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -73,22 +73,22 @@ public async Task Create_ObjectIdNotEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { neq: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { neq: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { neq: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -107,28 +107,28 @@ public async Task Create_ObjectIdGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gt: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -148,28 +148,28 @@ public async Task Create_ObjectIdNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -190,28 +190,28 @@ public async Task Create_ObjectIdGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -231,28 +231,28 @@ public async Task Create_ObjectIdNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -272,24 +272,24 @@ public async Task Create_ObjectIdLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: null}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: null}}){ objectId}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -309,28 +309,28 @@ public async Task Create_ObjectIdNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -351,28 +351,28 @@ public async Task Create_ObjectIdLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -392,28 +392,28 @@ public async Task Create_ObjectIdNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -431,8 +431,8 @@ public async Task Create_ObjectIdIn_Expression() var tester = CreateSchema(_fooEntities); var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(@"{ + OperationRequestBuilder.Create() + .SetDocument(@"{ root(where: { objectId: { in: [ ""6124e80f3f5fc839830c1f69"", @@ -442,11 +442,11 @@ public async Task Create_ObjectIdIn_Expression() objectId } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(@"{ + OperationRequestBuilder.Create() + .SetDocument(@"{ root(where: { objectId: { in: [ null, ""6124e80f3f5fc839830c1f6b"" ] @@ -454,11 +454,11 @@ public async Task Create_ObjectIdIn_Expression() objectId } }") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery(@"{ + OperationRequestBuilder.Create() + .SetDocument(@"{ root(where: { objectId: { in: [ null, ""6124e80f3f5fc839830c1f6b"" ] @@ -466,7 +466,7 @@ public async Task Create_ObjectIdIn_Expression() objectId } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -485,8 +485,8 @@ public async Task Create_ObjectIdNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root( where: { @@ -498,11 +498,11 @@ public async Task Create_ObjectIdNotIn_Expression() objectId } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root( where: { @@ -514,12 +514,12 @@ public async Task Create_ObjectIdNotIn_Expression() objectId } }") - .SetQuery("{ root(where: { objectId: { nin: [ null, \"6124e80f3f5fc839830c1f6b\" ]}}){ objectId}}") - .Create()); + .SetDocument("{ root(where: { objectId: { nin: [ null, \"6124e80f3f5fc839830c1f6b\" ]}}){ objectId}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root( where: { @@ -531,7 +531,7 @@ public async Task Create_ObjectIdNotIn_Expression() objectId } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -551,22 +551,22 @@ public async Task Create_ObjectIdNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { eq: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { eq: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { eq: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -585,22 +585,22 @@ public async Task Create_ObjectIdNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { neq: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { neq: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { neq: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -619,24 +619,24 @@ public async Task Create_ObjectIdNullableGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { gt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { gt: null}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { gt: null}}){ objectId}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -656,28 +656,28 @@ public async Task Create_ObjectIdNullableNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngt: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -698,28 +698,28 @@ public async Task Create_ObjectIdNullableGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { gte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -739,28 +739,28 @@ public async Task Create_ObjectIdNullableNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { ngte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -780,24 +780,24 @@ public async Task Create_ObjectIdNullableLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { lt: null}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { lt: null}}){ objectId}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -817,28 +817,28 @@ public async Task Create_ObjectIdNullableNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlt: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -860,28 +860,28 @@ public async Task Create_ObjectIdNullableLowerThanOrEquals_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { lte: null}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -901,27 +901,27 @@ public async Task Create_ObjectIdNullableNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: \"6124e80f3f5fc839830c1f69\"}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: \"6124e80f3f5fc839830c1f6a\"}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nlte: \"6124e80f3f5fc839830c1f6b\"}}){ objectId}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { nlte: null}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { nlte: null}}){ objectId}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -941,25 +941,25 @@ public async Task Create_ObjectIdNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { in: [ \"6124e80f3f5fc839830c1f69\", " + "\"6124e80f3f5fc839830c1f6a\" ]}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { in: [ \"6124e80f3f5fc839830c1f6a\", " + "\"6124e80f3f5fc839830c1f6b\" ]}}){ objectId}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { in: [ \"6124e80f3f5fc839830c1f6a\", " + "null ]}}){ objectId}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -978,21 +978,21 @@ public async Task Create_ObjectIdNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { objectId: { nin: [ \"6124e80f3f5fc839830c1f69\", " + "\"6124e80f3f5fc839830c1f6a\" ]}}){ objectId}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { nin: [ \"6124e80f3f5fc839830c1f6a\", \"6124e80f3f5fc839830c1f6b\" ]}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { nin: [ \"6124e80f3f5fc839830c1f6a\", \"6124e80f3f5fc839830c1f6b\" ]}}){ objectId}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { objectId: { nin: [ \"6124e80f3f5fc839830c1f6a\", null ]}}){ objectId}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { objectId: { nin: [ \"6124e80f3f5fc839830c1f6a\", null ]}}){ objectId}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectTests.cs index 89d97cd0e1a..6b72e0e4e74 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorObjectTests.cs @@ -124,25 +124,25 @@ public async Task Create_ObjectShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -161,25 +161,25 @@ public async Task Create_ObjectShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -198,25 +198,25 @@ public async Task Create_ObjectNullableShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -235,25 +235,25 @@ public async Task Create_ObjectNullableShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, null ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -272,18 +272,18 @@ public async Task Create_ObjectBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -303,25 +303,25 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: null}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -340,25 +340,25 @@ public async Task Create_ObjectEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -377,25 +377,25 @@ public async Task Create_ObjectEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -414,25 +414,25 @@ public async Task Create_ObjectNullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -451,25 +451,25 @@ public async Task Create_ObjectNullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -488,24 +488,24 @@ public async Task Create_ObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testatest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testbtest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: null}}}){ foo{ barString}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -524,26 +524,26 @@ public async Task Create_ObjectStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: " + "[ \"testatest\" \"testbtest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [\"testbtest\" null]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [ \"testatest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -562,28 +562,28 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"a\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"d\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: null}}}}}}) " + "{ foo { objectArray { foo {barString}}}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -602,25 +602,25 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: false}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: true}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: null}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); // arrange await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorStringTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorStringTests.cs index 3f0fdd234ad..026406b94eb 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorStringTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorStringTests.cs @@ -36,19 +36,19 @@ public async Task Create_StringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -67,19 +67,19 @@ public async Task Create_StringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -98,20 +98,20 @@ public async Task Create_StringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -130,20 +130,20 @@ public async Task Create_StringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -162,19 +162,19 @@ public async Task Create_StringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -193,19 +193,19 @@ public async Task Create_StringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -224,19 +224,19 @@ public async Task Create_StringStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -255,19 +255,19 @@ public async Task Create_StringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -286,19 +286,19 @@ public async Task Create_StringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -317,19 +317,19 @@ public async Task Create_StringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -348,19 +348,19 @@ public async Task Create_NullableStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -379,19 +379,19 @@ public async Task Create_NullableStringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -410,20 +410,20 @@ public async Task Create_NullableStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -442,20 +442,20 @@ public async Task Create_NullableStringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -474,19 +474,19 @@ public async Task Create_NullableStringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -505,19 +505,19 @@ public async Task Create_NullableStringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -536,19 +536,19 @@ public async Task Create_NullableStringStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -567,19 +567,19 @@ public async Task Create_NullableStringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -598,19 +598,19 @@ public async Task Create_NullableStringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -629,19 +629,19 @@ public async Task Create_NullableStringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorTimeOnlyTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorTimeOnlyTests.cs index 30931d71c80..cae11f4ca3d 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorTimeOnlyTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterVisitorTimeOnlyTests.cs @@ -42,14 +42,14 @@ public async Task Create_TimeOnlyEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"06:30:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"06:30:00\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"16:00:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"16:00:00\" } }){ bar } }") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -67,14 +67,14 @@ public async Task Create_TimeOnlyNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"06:30:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"06:30:00\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"16:00:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"16:00:00\" } }){ bar } }") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -92,19 +92,19 @@ public async Task Create_NullableTimeOnlyEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"06:30:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"06:30:00\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"16:00:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"16:00:00\" } }){ bar } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null } }){ bar } }") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -123,19 +123,19 @@ public async Task Create_NullableTimeOnlyNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"06:30:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"06:30:00\" } }){ bar } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"16:00:00\" } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"16:00:00\" } }){ bar } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null } }){ bar } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null } }){ bar } }") + .Build()); // arrange await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFindFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFindFluentTests.cs index 673b9a52f45..f4fa640750f 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFindFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFindFluentTests.cs @@ -54,14 +54,14 @@ public async Task BsonElement_Rename() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -90,14 +90,14 @@ public async Task FindFluent_Serializer() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { baz: { eq: \"2020-01-11T00:00:00Z\"}}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { baz: { eq: \"2020-01-11T00:00:00Z\"}}){ baz}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { baz: { eq: \"2020-01-12T00:00:00Z\"}}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { baz: { eq: \"2020-01-12T00:00:00Z\"}}){ baz}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -123,14 +123,14 @@ public async Task FindFluent_CombineQuery() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"2020-01-11T00:00:00Z\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"2020-01-11T00:00:00Z\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"2020-01-12T00:00:00Z\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"2020-01-12T00:00:00Z\"}}){ bar}}") + .Build()); // arrange await SnapshotExtensions.AddResult( @@ -192,10 +192,10 @@ private static IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingAggregateFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingAggregateFluentTests.cs index 1f0670bd78b..10b6434e3d8 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingAggregateFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingAggregateFluentTests.cs @@ -265,10 +265,10 @@ private ValueTask CreateSchemaAsync() if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingFindFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingFindFluentTests.cs index 43bfab69d02..ca00cdda9aa 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingFindFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbCursorPagingFindFluentTests.cs @@ -298,10 +298,10 @@ private ValueTask CreateSchemaAsync() if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingAggregateTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingAggregateTests.cs index c104eea91ff..7f9787c3b73 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingAggregateTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingAggregateTests.cs @@ -213,10 +213,10 @@ private ValueTask CreateSchemaAsync() if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingFindFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingFindFluentTests.cs index bc90ae986ed..739f2c3bcbe 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingFindFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/MongoDbOffsetPagingFindFluentTests.cs @@ -211,10 +211,10 @@ private ValueTask CreateSchemaAsync() if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/VisitorTestBase.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/VisitorTestBase.cs index fc413410ea3..010357a7708 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/VisitorTestBase.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Paging.Tests/VisitorTestBase.cs @@ -65,10 +65,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionObjectsTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionObjectsTests.cs index 2f7e5b50d55..0036367d1ef 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionObjectsTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionObjectsTests.cs @@ -27,7 +27,7 @@ public class MongoDbProjectionObjectTests(MongoResource resource) : IClassFixtur { Number = 2, Foo = new FooNullable { - BarEnum = BarEnum.FOO, + BarEnum = BarEnum.FOO, BarShort = 14, }, }, @@ -73,8 +73,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFiel // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { number @@ -83,7 +83,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFiel } } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -100,8 +100,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { number @@ -115,7 +115,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() } } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorIsProjectedTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorIsProjectedTests.cs index 3a6eaadb100..7e713407c4c 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorIsProjectedTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorIsProjectedTests.cs @@ -5,19 +5,19 @@ namespace HotChocolate.Data.MongoDb.Projections; -public class MongoDbProjectionVisitorIsProjectedTests(MongoResource resource) +public class MongoDbProjectionVisitorIsProjectedTests(MongoResource resource) : IClassFixture { private static readonly Foo[] _fooEntities = [ new Foo { - IsProjectedTrue = true, + IsProjectedTrue = true, IsProjectedFalse = false, }, new Foo { - IsProjectedTrue = true, + IsProjectedTrue = true, IsProjectedFalse = false, }, ]; @@ -38,9 +38,9 @@ public async Task IsProjected_Should_NotBeProjectedWhenSelected_When_FalseWithOn // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -57,9 +57,9 @@ public async Task IsProjected_Should_NotBeProjectedWhenSelected_When_FalseWithTw // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse isProjectedTrue }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse isProjectedTrue }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -76,9 +76,9 @@ public async Task IsProjected_Should_AlwaysBeProjectedWhenSelected_When_True() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -98,7 +98,7 @@ public async Task IsProjected_Should_NotFailWhenSelectionSetSkippedCompletely() """ { root { - isProjectedFalse + isProjectedFalse } } """); diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorPagingTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorPagingTests.cs index 8aedbb6215d..b7eaebe7f53 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorPagingTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorPagingTests.cs @@ -36,9 +36,9 @@ public async Task Create_ProjectsTwoProperties_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { bar baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -55,9 +55,9 @@ public async Task Create_ProjectsOneProperty_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -74,9 +74,9 @@ public async Task Create_ProjectsTwoProperties_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { bar baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { bar baz }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -93,9 +93,9 @@ public async Task Create_ProjectsOneProperty_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { baz }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -112,9 +112,9 @@ public async Task Create_ProjectsTwoProperties_EdgesAndNodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { bar }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -131,9 +131,9 @@ public async Task Create_ProjectsOneProperty_EdgesAndNodesOverlap() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { baz }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -150,9 +150,9 @@ public async Task CreateNullable_ProjectsTwoProperties_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { bar baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -169,9 +169,9 @@ public async Task CreateNullable_ProjectsOneProperty_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -188,9 +188,9 @@ public async Task CreateNullable_ProjectsTwoProperties_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { bar baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { bar baz }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -207,9 +207,9 @@ public async Task CreateNullable_ProjectsOneProperty_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { baz }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -226,9 +226,9 @@ public async Task CreateNullable_ProjectsTwoProperties_EdgesAndNodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { bar }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -245,9 +245,9 @@ public async Task CreateNullable_ProjectsOneProperty_EdgesAndNodesOverlap() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { baz }} }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -264,9 +264,9 @@ public async Task Create_Projection_Should_Stop_When_UseProjectionEncountered() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ bar list { barBaz } } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ bar list { barBaz } } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -283,9 +283,9 @@ public async Task CreateOffsetPaging_ProjectsTwoProperties_Items_WithArgs() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(take:10, skip:1) { items { bar baz } } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(take:10, skip:1) { items { bar baz } } }") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -302,9 +302,9 @@ public async Task CreateOffsetPaging_ProjectsTwoProperties_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { bar baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -321,9 +321,9 @@ public async Task CreateOffsetPaging_ProjectsOneProperty_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -343,9 +343,9 @@ public async Task CreateOffsetPagingNullable_ProjectsTwoProperties_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { bar baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -364,9 +364,9 @@ public async Task CreateOffsetPagingNullable_ProjectsOneProperty_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { baz } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -383,9 +383,9 @@ public async Task CreateOffsetPaging_Projection_Should_Stop_When_UseProjectionEn // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items{ bar list { barBaz } } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items{ bar list { barBaz } } }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -402,9 +402,9 @@ public async Task CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncoun // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items{ bar paging { nodes {barBaz }} } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items{ bar paging { nodes {barBaz }} } }}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorScalarTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorScalarTests.cs index ef648f89c08..fd7574989be 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorScalarTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/MongoDbProjectionVisitorScalarTests.cs @@ -29,9 +29,9 @@ public async Task Create_ProjectsTwoProperties_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ bar baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ bar baz }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -48,9 +48,9 @@ public async Task Create_ProjectsOneProperty_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ baz }}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -77,9 +77,9 @@ public async Task Create_ProjectsOneProperty_WithResolver() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ baz foo }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ baz foo }}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/ProjectionVisitorTestBase.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/ProjectionVisitorTestBase.cs index 02b8fa824fd..cea21f3d763 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/ProjectionVisitorTestBase.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Projections.Tests/ProjectionVisitorTestBase.cs @@ -65,10 +65,10 @@ public IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbAggregateFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbAggregateFluentTests.cs index 391bc252b12..e99a8f99eba 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbAggregateFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbAggregateFluentTests.cs @@ -48,14 +48,14 @@ public async Task BsonElement_Rename() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -86,14 +86,14 @@ public async Task Collection_Configuration() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { baz: ASC}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { baz: ASC}){ baz}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { baz: DESC}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { baz: DESC}){ baz}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -151,10 +151,10 @@ private static IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbCollectionTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbCollectionTests.cs index f844826709e..c9b205ecd9c 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbCollectionTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbCollectionTests.cs @@ -48,14 +48,14 @@ public async Task BsonElement_Rename() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -86,14 +86,14 @@ public async Task Collection_Configuration() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { baz: ASC}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { baz: ASC}){ baz}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { baz: DESC}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { baz: DESC}){ baz}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -151,10 +151,10 @@ private static IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbFindFluentTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbFindFluentTests.cs index 16b61f8a333..b4fb4946441 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbFindFluentTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbFindFluentTests.cs @@ -56,14 +56,14 @@ public async Task BsonElement_Rename() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -94,14 +94,14 @@ public async Task Collection_Configuration() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { baz: ASC}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { baz: ASC}){ baz}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { baz: DESC}){ baz}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { baz: DESC}){ baz}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -131,14 +131,14 @@ public async Task FindFluent_CombineQuery() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -206,10 +206,10 @@ private static IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorBooleanTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorBooleanTests.cs index 100e4d94d6d..d90ed73230d 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorBooleanTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorBooleanTests.cs @@ -36,14 +36,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -62,14 +62,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorComparableTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorComparableTests.cs index 8784637a08f..b61440f8341 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorComparableTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorComparableTests.cs @@ -38,14 +38,14 @@ public async Task Create_Short_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -64,14 +64,14 @@ public async Task Create_Short_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorEnumTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorEnumTests.cs index f011cb42e45..a7627e9c9d6 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorEnumTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorEnumTests.cs @@ -40,14 +40,14 @@ public async Task Create_Enum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -66,14 +66,14 @@ public async Task Create_Enum_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorObjectTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorObjectTests.cs index 2496232186a..9ba37cdfc4f 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorObjectTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorObjectTests.cs @@ -124,18 +124,18 @@ public async Task Create_ObjectShort_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -154,18 +154,18 @@ public async Task Create_ObjectNullableShort_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -183,18 +183,18 @@ public async Task Create_ObjectEnum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -213,18 +213,18 @@ public async Task Create_ObjectNullableEnum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -242,18 +242,18 @@ public async Task Create_ObjectString_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -272,18 +272,18 @@ public async Task Create_ObjectNullableString_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -301,18 +301,18 @@ public async Task Create_ObjectBool_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -331,18 +331,18 @@ public async Task Create_ObjectNullableBool_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorStringTests.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorStringTests.cs index 96c800f7e48..2a78d58972b 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorStringTests.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/MongoDbSortVisitorStringTests.cs @@ -36,14 +36,14 @@ public async Task Create_String_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( @@ -62,14 +62,14 @@ public async Task Create_String_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/SortVisitorTestBase.cs b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/SortVisitorTestBase.cs index 467953d2d33..c6e17eead7a 100644 --- a/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/SortVisitorTestBase.cs +++ b/src/HotChocolate/MongoDb/test/Data.MongoDb.Sorting.Tests/SortVisitorTestBase.cs @@ -58,10 +58,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/MongoDb/test/Types.MongoDb/BsonTypeTests.cs b/src/HotChocolate/MongoDb/test/Types.MongoDb/BsonTypeTests.cs index 9b5ca712fd0..d06935b71a9 100644 --- a/src/HotChocolate/MongoDb/test/Types.MongoDb/BsonTypeTests.cs +++ b/src/HotChocolate/MongoDb/test/Types.MongoDb/BsonTypeTests.cs @@ -49,19 +49,22 @@ public async Task Input_Should_MatchSnapshot_When_BsonDocument() var executor = await new ServiceCollection() .AddGraphQL() .AddBsonType() - .AddQueryType(x => x.Name("Query") - .Field("in") - .Type() - .Argument("val", x => x.Type()) - .Resolve(ctx => - { - res = ctx.ArgumentValue("val"); - return "done"; - })) + .AddQueryType( + x => x.Name("Query") + .Field("in") + .Type() + .Argument("val", x => x.Type()) + .Resolve( + ctx => + { + res = ctx.ArgumentValue("val"); + return "done"; + })) .BuildRequestExecutorAsync(); // act - await executor.ExecuteAsync(@" + await executor.ExecuteAsync( + @" { in(val: { int32: 42, @@ -95,15 +98,17 @@ public async Task Input_Should_MatchSnapshotAndType_When_DictionaryPassed() var executor = await new ServiceCollection() .AddGraphQL() .AddBsonType() - .AddQueryType(x => x.Name("Query") - .Field("in") - .Type() - .Argument("val", x => x.Type()) - .Resolve(ctx => - { - res = ctx.ArgumentValue("val"); - return "done"; - })) + .AddQueryType( + x => x.Name("Query") + .Field("in") + .Type() + .Argument("val", x => x.Type()) + .Resolve( + ctx => + { + res = ctx.ArgumentValue("val"); + return "done"; + })) .BuildRequestExecutorAsync(); // act @@ -130,15 +135,17 @@ public async Task Input_Should_MatchSnapshotAndType_When_ListPassed() var executor = await new ServiceCollection() .AddGraphQL() .AddBsonType() - .AddQueryType(x => x.Name("Query") - .Field("in") - .Type() - .Argument("val", x => x.Type()) - .Resolve(ctx => - { - res = ctx.ArgumentValue("val"); - return "done"; - })) + .AddQueryType( + x => x.Name("Query") + .Field("in") + .Type() + .Argument("val", x => x.Type()) + .Resolve( + ctx => + { + res = ctx.ArgumentValue("val"); + return "done"; + })) .BuildRequestExecutorAsync(); // act @@ -186,7 +193,8 @@ public async Task Output_Should_MatchSnapshot_When_Value(string fieldName) [Theory] [InlineData("int", "42", typeof(BsonInt64))] [InlineData("long", long.MaxValue, typeof(BsonInt64))] - [InlineData("decimal", + [InlineData( + "decimal", "\"42.1234\"", typeof(BsonString))] // we do not know that it should be a BsonDecimal [InlineData("double", 43.23, typeof(BsonDouble))] @@ -203,15 +211,17 @@ public async Task Input_Should_MatchSnapshotAndType_When_Passed( var executor = await new ServiceCollection() .AddGraphQL() .AddBsonType() - .AddQueryType(x => x.Name("Query") - .Field("in") - .Type() - .Argument("val", x => x.Type()) - .Resolve(ctx => - { - res = ctx.ArgumentValue("val"); - return "done"; - })) + .AddQueryType( + x => x.Name("Query") + .Field("in") + .Type() + .Argument("val", x => x.Type()) + .Resolve( + ctx => + { + res = ctx.ArgumentValue("val"); + return "done"; + })) .BuildRequestExecutorAsync(); // act @@ -239,15 +249,17 @@ public async Task Input_Should_MatchSnapshotAndType_When_PassedVariable( var executor = await new ServiceCollection() .AddGraphQL() .AddBsonType() - .AddQueryType(x => x.Name("Query") - .Field("in") - .Type() - .Argument("val", x => x.Type()) - .Resolve(ctx => - { - res = ctx.ArgumentValue("val"); - return "done"; - })) + .AddQueryType( + x => x.Name("Query") + .Field("in") + .Type() + .Argument("val", x => x.Type()) + .Resolve( + ctx => + { + res = ctx.ArgumentValue("val"); + return "done"; + })) .BuildRequestExecutorAsync(); // act @@ -304,11 +316,12 @@ public async Task Output_Return_Object() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => new BsonDocument { { "foo", "bar" }, })) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => new BsonDocument { { "foo", "bar" }, })) .Create(); var executor = schema.MakeExecutable(); @@ -325,11 +338,12 @@ public async Task Output_Return_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Resolve(_ => new BsonArray { new BsonDocument(), })) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Resolve(_ => new BsonArray { new BsonDocument(), })) .Create(); var executor = schema.MakeExecutable(); @@ -346,12 +360,13 @@ public async Task Input_Object() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -369,12 +384,13 @@ public async Task Input_Value_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -392,12 +408,13 @@ public async Task Input_Object_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -415,12 +432,13 @@ public async Task Input_Value_String() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -438,12 +456,13 @@ public async Task Input_Value_Int() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -461,12 +480,13 @@ public async Task Input_Value_Float() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -483,12 +503,13 @@ public async Task Input_Value_Boolean() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -506,12 +527,13 @@ public async Task Input_Value_Null() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); @@ -529,22 +551,27 @@ public async Task Input_Value_List_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", new List { "abc", }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues( + new Dictionary + { + { "foo", new List { "abc", } }, + }) + .Build()); // assert result.MatchSnapshot(); @@ -555,24 +582,30 @@ public async Task Input_Object_List_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue( - "foo", - new List { new Dictionary { { "abc", "def" }, }, }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues( + new Dictionary + { + { + "foo", + new List { new Dictionary { { "abc", "def" }, }, } + }, + }) + .Build()); // assert result.MatchSnapshot(); @@ -583,22 +616,23 @@ public async Task Input_Value_String_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", "bar") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", "bar" }, }) + .Build()); // assert result.MatchSnapshot(); @@ -609,22 +643,23 @@ public async Task Input_Value_Int_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", 123) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", 123 }, }) + .Build()); // assert result.MatchSnapshot(); @@ -635,22 +670,23 @@ public async Task Input_Value_Float_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", 1.2) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", 1.2 }, }) + .Build()); // assert result.MatchSnapshot(); @@ -661,22 +697,27 @@ public async Task Input_Value_BsonDocument_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentLiteral("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentLiteral("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", new BsonDocument { { "a", "b" }, }) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues( + new Dictionary + { + { "foo", new BsonDocument { { "a", "b" }, } }, + }) + .Build()); // assert result.MatchSnapshot(); @@ -687,22 +728,23 @@ public async Task Input_Value_Boolean_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", false) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", false }, }) + .Build()); // assert result.MatchSnapshot(); @@ -713,22 +755,23 @@ public async Task Input_Value_Null_As_Variable() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var executor = schema.MakeExecutable(); // act var result = await executor.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("query ($foo: Bson) { foo(input: $foo) }") - .SetVariableValue("foo", null) - .Create()); + OperationRequestBuilder.Create() + .SetDocument("query ($foo: Bson) { foo(input: $foo) }") + .SetVariableValues(new Dictionary { { "foo", null }, }) + .Build()); // assert result.MatchSnapshot(); @@ -739,12 +782,13 @@ public void IsInstanceOfType_EnumValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -761,12 +805,13 @@ public void IsInstanceOfType_ObjectValue_True() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -783,12 +828,13 @@ public void IsInstanceOfType_ListValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -805,12 +851,13 @@ public void IsInstanceOfType_StringValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -827,12 +874,13 @@ public void IsInstanceOfType_IntValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -849,12 +897,13 @@ public void IsInstanceOfType_FloatValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -871,12 +920,13 @@ public void IsInstanceOfType_BooleanValue_False() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -893,12 +943,13 @@ public void IsInstanceOfType_NullValue_True() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -915,12 +966,13 @@ public void IsInstanceOfType_Null_ArgumentNullException() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -945,12 +997,13 @@ public void ParseValue_ScalarValues(object value, Type expectedType) { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -967,12 +1020,13 @@ public void ParseValue_Decimal() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -989,12 +1043,13 @@ public void ParseValue_List_Of_Object() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1011,12 +1066,13 @@ public void ParseValue_List_Of_String() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1033,12 +1089,13 @@ public void ParseValue_List_Of_Foo() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1055,12 +1112,13 @@ public void ParseValue_Dictionary() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1078,12 +1136,13 @@ public void Deserialize_ValueNode() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1100,12 +1159,13 @@ public void Deserialize_Dictionary() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1127,12 +1187,13 @@ public void Deserialize_NestedDictionary() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1155,12 +1216,13 @@ public void Deserialize_List() { // arrange var schema = SchemaBuilder.New() - .AddQueryType(d => d - .Name("Query") - .Field("foo") - .Type() - .Argument("input", a => a.Type()) - .Resolve(ctx => ctx.ArgumentValue("input"))) + .AddQueryType( + d => d + .Name("Query") + .Field("foo") + .Type() + .Argument("input", a => a.Type()) + .Resolve(ctx => ctx.ArgumentValue("input"))) .Create(); var type = schema.GetType("Bson"); @@ -1222,11 +1284,12 @@ public class OutputQuery public BsonBoolean Boolean => new(true); - public BsonArray BsonArray => new(new[] - { - BsonBoolean.False, - BsonBoolean.True, - }); + public BsonArray BsonArray => new( + new[] + { + BsonBoolean.False, + BsonBoolean.True, + }); public BsonString String => new("String"); @@ -1253,11 +1316,12 @@ public class OutputQuery ["Double"] = new BsonDouble(42.23), ["Double"] = new BsonDouble(42.23), ["Boolean"] = new BsonBoolean(true), - ["BsonArray"] = new BsonArray(new[] - { - BsonBoolean.False, - BsonBoolean.True, - }), + ["BsonArray"] = new BsonArray( + new[] + { + BsonBoolean.False, + BsonBoolean.True, + }), ["String"] = new BsonString("String"), ["Null"] = BsonNull.Value, ["Nested"] = new BsonDocument() @@ -1267,4 +1331,4 @@ public class OutputQuery }, }; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/MongoDb/test/Types.MongoDb/ObjectIdTypeTests.cs b/src/HotChocolate/MongoDb/test/Types.MongoDb/ObjectIdTypeTests.cs index 7abec7f60b9..a7b2485d19b 100644 --- a/src/HotChocolate/MongoDb/test/Types.MongoDb/ObjectIdTypeTests.cs +++ b/src/HotChocolate/MongoDb/test/Types.MongoDb/ObjectIdTypeTests.cs @@ -26,17 +26,17 @@ public async Task Should_ReturnObjectIdOnQuery() { // arrange var executor = await CreateSchema(); - var query = @" + const string query = + """ { - foo { - id - } + foo { + id + } } - "; + """; // act - var request = QueryRequestBuilder.Create(query); - var result = await executor.ExecuteAsync(request, CancellationToken.None); + var result = await executor.ExecuteAsync(query, CancellationToken.None); // assert result.MatchSnapshot(); @@ -53,15 +53,14 @@ public async Task Should_ReturnInputOnQuery() }"; // act - var request = QueryRequestBuilder.Create(query); - var result = await executor.ExecuteAsync(request, CancellationToken.None); + var result = await executor.ExecuteAsync(query, CancellationToken.None); // assert result.MatchSnapshot(); } - private ValueTask CreateSchema() => - new ServiceCollection() + private static ValueTask CreateSchema() + => new ServiceCollection() .AddGraphQL() .AddQueryType() .AddType() diff --git a/src/HotChocolate/OpenApi/test/HotChocolate.OpenApi.Tests/IntegrationTests.cs b/src/HotChocolate/OpenApi/test/HotChocolate.OpenApi.Tests/IntegrationTests.cs index 939406db70f..e4a6ec1085b 100644 --- a/src/HotChocolate/OpenApi/test/HotChocolate.OpenApi.Tests/IntegrationTests.cs +++ b/src/HotChocolate/OpenApi/test/HotChocolate.OpenApi.Tests/IntegrationTests.cs @@ -28,7 +28,48 @@ public async Task ExecuteQuery_PetStoreExpandedWithoutMutationConventions_Return .BuildRequestExecutorAsync(); // Act - var result = await schema.ExecuteAsync(QueryRequestBuilder.Create(query)); + var result = await schema.ExecuteAsync(query); + + // Assert + Assert.NotNull(result); + Snapshot.Match(result, postFix: caseName, extension: ".json"); + } + + + [Theory] + [InlineData("me", "query { me { firstName lastName email picture promoCode } }")] + [InlineData("getProducts", "query { products(longitude: 1, latitude: 1) { productId displayName } }")] + public async Task QueryUber_Returns_Results(string caseName, string query) + { + // Arrange + var httpClientFactoryMock = new Mock(); + var builder = new WebHostBuilder(); + builder.ConfigureServices(services => + { + services.AddRouting(); + services.AddControllers(); + }); + builder.Configure(app => + { + app.UseRouting(); + app.UseEndpoints(e => e.MapControllers()); + }); + var openApiServer = new TestServer(builder); + + httpClientFactoryMock.Setup(f => f.CreateClient(It.IsAny())) + .Returns(() => openApiServer.CreateClient()); + + await openApiServer.Host.StartAsync(); + var apiDocument = FileResource.Open("Uber.json"); + + var schema = await new ServiceCollection() + .AddSingleton(httpClientFactoryMock.Object) + .AddGraphQL() + .AddOpenApi("Uber", apiDocument) + .BuildRequestExecutorAsync(); + + // Act + var result = await schema.ExecuteAsync(query); // Assert Assert.NotNull(result); @@ -55,7 +96,7 @@ public async Task ExecuteQuery_PetStoreExpandedWithMutationConventions_ReturnsEx .BuildRequestExecutorAsync(); // Act - var result = await schema.ExecuteAsync(QueryRequestBuilder.Create(query)); + var result = await schema.ExecuteAsync(query); // Assert Assert.NotNull(result); @@ -82,7 +123,7 @@ public async Task ExecuteQuery_SyntheticWithLinks_ReturnsExpectedResult( .BuildRequestExecutorAsync(); // Act - var result = await schema.ExecuteAsync(QueryRequestBuilder.Create(query)); + var result = await schema.ExecuteAsync(query); // Assert httpClientFactoryMock.Verify(f => f.CreateClient(It.IsAny()), Times.Exactly(2)); diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesRequestExecutorBuilderExtensions.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesRequestExecutorBuilderExtensions.cs index 586f963d2de..380b92c7507 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesRequestExecutorBuilderExtensions.cs @@ -29,7 +29,7 @@ public static IRequestExecutorBuilder AddFileSystemQueryStorage( } return builder.ConfigureSchemaServices( - s => s.AddFileSystemQueryStorage(cacheDirectory)); + s => s.AddFileSystemOperationDocumentStorage(cacheDirectory)); } /// @@ -52,6 +52,6 @@ public static IRequestExecutorBuilder AddReadOnlyFileSystemQueryStorage( } return builder.ConfigureSchemaServices( - s => s.AddReadOnlyFileSystemQueryStorage(cacheDirectory)); + s => s.AddFileSystemOperationDocumentStorage(cacheDirectory)); } } \ No newline at end of file diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions.cs index 08f56ca1ff1..598ccb68cdb 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/Extensions/HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions.cs @@ -12,33 +12,7 @@ namespace HotChocolate; public static class HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions { /// - /// Adds a file system read and write query storage to the - /// services collection. - /// - /// - /// The service collection to which the services are added. - /// - /// - /// The directory path that shall be used to store queries. - /// - public static IServiceCollection AddFileSystemQueryStorage( - this IServiceCollection services, - string? cacheDirectory = null) - { - if (services is null) - { - throw new ArgumentNullException(nameof(services)); - } - - return services - .AddReadOnlyFileSystemQueryStorage(cacheDirectory) - .AddSingleton( - sp => sp.GetRequiredService()); - } - - /// - /// Adds a file system read-only query storage to the - /// services collection. + /// Adds a file system based operation document storage to the service collection. /// /// /// The service collection to which the services are added. @@ -46,7 +20,7 @@ public static IServiceCollection AddFileSystemQueryStorage( /// /// The directory path that shall be used to read queries from. /// - public static IServiceCollection AddReadOnlyFileSystemQueryStorage( + public static IServiceCollection AddFileSystemOperationDocumentStorage( this IServiceCollection services, string? cacheDirectory = null) { @@ -56,15 +30,12 @@ public static IServiceCollection AddReadOnlyFileSystemQueryStorage( } return services - .RemoveService() - .RemoveService() + .RemoveService() .RemoveService() - .AddSingleton() - .AddSingleton( - sp => sp.GetRequiredService()) + .AddSingleton() .AddSingleton( cacheDirectory is null ? new DefaultQueryFileMap() : new DefaultQueryFileMap(cacheDirectory)); } -} +} \ No newline at end of file diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/FileSystemQueryStorage.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/FileSystemQueryStorage.cs index 1879b7d9187..9922b30850f 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/FileSystemQueryStorage.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.FileSystem/FileSystemQueryStorage.cs @@ -9,15 +9,11 @@ namespace HotChocolate.PersistedQueries.FileSystem; /// -/// An implementation of -/// and that -/// uses the local file system. +/// An implementation of that uses the file system. /// -public class FileSystemQueryStorage - : IReadStoredQueries - , IWriteStoredQueries +public class FileSystemQueryStorage : IOperationDocumentStorage { - private static readonly Task _null = Task.FromResult(null); + private static readonly Task _null = Task.FromResult(null); private readonly IQueryFileMap _queryMap; /// @@ -26,8 +22,7 @@ public class FileSystemQueryStorage /// The query identifier mapping. public FileSystemQueryStorage(IQueryFileMap queryMap) { - _queryMap = queryMap - ?? throw new ArgumentNullException(nameof(queryMap)); + _queryMap = queryMap ?? throw new ArgumentNullException(nameof(queryMap)); if (!Directory.Exists(_queryMap.Root)) { @@ -36,26 +31,23 @@ public FileSystemQueryStorage(IQueryFileMap queryMap) } /// - public Task TryReadQueryAsync( - string queryId, + public ValueTask TryReadAsync( + OperationDocumentId documentId, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(queryId)) + if (OperationDocumentId.IsNullOrEmpty(documentId)) { - throw new ArgumentNullException(nameof(queryId)); + throw new ArgumentNullException(nameof(documentId)); } - var filePath = _queryMap.MapToFilePath(queryId); + var filePath = _queryMap.MapToFilePath(documentId.Value); - if (!File.Exists(filePath)) - { - return _null; - } - - return TryReadQueryInternalAsync(filePath, cancellationToken); + return File.Exists(filePath) + ? TryReadInternalAsync(filePath, cancellationToken) + : default; } - private static async Task TryReadQueryInternalAsync( + private static async ValueTask TryReadInternalAsync( string filePath, CancellationToken cancellationToken) { @@ -75,39 +67,45 @@ public FileSystemQueryStorage(IQueryFileMap queryMap) cancellationToken) .ConfigureAwait(false); - return new QueryDocument(document); + return new OperationDocument(document); } /// - public Task WriteQueryAsync( - string queryId, - IQuery query, + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(queryId)) + if (OperationDocumentId.IsNullOrEmpty(documentId)) { - throw new ArgumentNullException(nameof(queryId)); + throw new ArgumentNullException(nameof(documentId)); } - if (query is null) + if (document is null) { - throw new ArgumentNullException(nameof(query)); + throw new ArgumentNullException(nameof(document)); } - var filePath = _queryMap.MapToFilePath(queryId); - return WriteQueryInternalAsync(query, filePath, cancellationToken); + var filePath = _queryMap.MapToFilePath(documentId.Value); + return SaveInternalAsync(filePath, document, cancellationToken); } - private static async Task WriteQueryInternalAsync( - IQuery query, + private static async ValueTask SaveInternalAsync( string filePath, + IOperationDocument document, CancellationToken cancellationToken) { - if (!File.Exists(filePath)) + if (File.Exists(filePath)) { - using var stream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write); - await query.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); - await stream.FlushAsync(cancellationToken).ConfigureAwait(false); + return; } + +#if NETSTANDARD2_0 + using var stream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write); +#else + await using var stream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write); +#endif + await document.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + await stream.FlushAsync(cancellationToken).ConfigureAwait(false); } -} +} \ No newline at end of file diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderExtensions.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderExtensions.cs index f34c589af84..a87c138d502 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderExtensions.cs @@ -16,7 +16,7 @@ public static class HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderEx /// /// The service collection to which the services are added. /// - public static IRequestExecutorBuilder AddInMemoryQueryStorage( + public static IRequestExecutorBuilder AddInMemoryOperationDocumentStorage( this IRequestExecutorBuilder builder) { if (builder is null) @@ -25,25 +25,6 @@ public static IRequestExecutorBuilder AddInMemoryQueryStorage( } return builder.ConfigureSchemaServices( - s => s.AddInMemoryQueryStorage()); - } - - /// - /// Adds a file system read-only query storage to the - /// services collection. - /// - /// - /// The service collection to which the services are added. - /// - public static IRequestExecutorBuilder AddReadOnlyInMemoryQueryStorage( - this IRequestExecutorBuilder builder) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.ConfigureSchemaServices( - s => s.AddReadOnlyInMemoryQueryStorage()); + s => s.AddInMemoryOperationDocumentStorage()); } } \ No newline at end of file diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions.cs index 9aa72b5ab06..4f20a605012 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/Extensions/HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions.cs @@ -13,13 +13,12 @@ namespace HotChocolate; public static class HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions { /// - /// Adds a file system read and write query storage to the - /// services collection. + /// Adds an in-memory operation document storage to the service collection. /// /// /// The service collection to which the services are added. /// - public static IServiceCollection AddInMemoryQueryStorage( + public static IServiceCollection AddInMemoryOperationDocumentStorage( this IServiceCollection services) { if (services is null) @@ -28,33 +27,10 @@ public static IServiceCollection AddInMemoryQueryStorage( } return services - .AddReadOnlyInMemoryQueryStorage() - .AddSingleton( - sp => sp.GetRequiredService()); - } - - /// - /// Adds a file system read-only query storage to the - /// services collection. - /// - /// - /// The service collection to which the services are added. - /// - public static IServiceCollection AddReadOnlyInMemoryQueryStorage( - this IServiceCollection services) - { - if (services is null) - { - throw new ArgumentNullException(nameof(services)); - } - - return services - .RemoveService() - .RemoveService() - .AddSingleton(c => new InMemoryQueryStorage( - c.GetService() ?? - c.GetApplicationService())) - .AddSingleton( - sp => sp.GetRequiredService()); + .RemoveService() + .AddSingleton( + c => new InMemoryQueryStorage( + c.GetService() ?? + c.GetApplicationService())); } } diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/InMemoryQueryStorage.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/InMemoryQueryStorage.cs index 0383070127a..f1769ceab38 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/InMemoryQueryStorage.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.InMemory/InMemoryQueryStorage.cs @@ -8,15 +8,10 @@ namespace HotChocolate.PersistedQueries.FileSystem; /// -/// An implementation of -/// and that -/// uses the local file system. +/// An implementation of that uses an in-memory cache. /// -public class InMemoryQueryStorage - : IReadStoredQueries - , IWriteStoredQueries +public class InMemoryQueryStorage : IOperationDocumentStorage { - private static readonly Task _null = Task.FromResult(null); private readonly IMemoryCache _cache; /// @@ -26,54 +21,52 @@ public InMemoryQueryStorage(IMemoryCache cache) { _cache = cache ?? throw new ArgumentNullException(nameof(cache)); } - + /// - public Task TryReadQueryAsync( - string queryId, + public ValueTask TryReadAsync( + OperationDocumentId documentId, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(queryId)) - { - throw new ArgumentNullException(nameof(queryId)); - } - - if (_cache.TryGetValue(queryId, out Task? queryDocumentTask)) + if (OperationDocumentId.IsNullOrEmpty(documentId)) { - return queryDocumentTask ?? _null; + throw new ArgumentNullException(nameof(documentId)); } - return _null; + return _cache.TryGetValue(documentId.Value, out OperationDocument? document) + ? new ValueTask(document) + : new ValueTask(default(IOperationDocument)); } - /// - public Task WriteQueryAsync( - string queryId, - IQuery query, + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(queryId)) + if (OperationDocumentId.IsNullOrEmpty(documentId)) { - throw new ArgumentNullException(nameof(queryId)); + throw new ArgumentNullException(nameof(documentId)); } - - if (query is null) + + if (document is null) { - throw new ArgumentNullException(nameof(query)); + throw new ArgumentNullException(nameof(document)); } - _cache.GetOrCreate>(queryId, _ => - { - if (query is QueryDocument queryDocument) + _cache.GetOrCreate( + documentId.Value, + _ => { - return Task.FromResult(queryDocument); - } + if (document is OperationDocument parsedDocument) + { + return parsedDocument; + } + + var documentNode = Utf8GraphQLParser.Parse(document.AsSpan()); + return new OperationDocument(documentNode); - var document = Utf8GraphQLParser.Parse(query.AsSpan()); - queryDocument = new QueryDocument(document); - return Task.FromResult(queryDocument); - }); + }); - return Task.CompletedTask; + return default; } } diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions.cs index f96c125b564..07d4d46cc77 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions.cs @@ -24,7 +24,7 @@ public static class HotChocolateRedisPersistedQueriesRequestExecutorBuilderExten /// /// A timeout after which a query is removed from the Redis cache. /// - public static IRequestExecutorBuilder AddRedisQueryStorage( + public static IRequestExecutorBuilder AddRedisOperationDocumentStorage( this IRequestExecutorBuilder builder, Func databaseFactory, TimeSpan? queryExpiration = null) @@ -40,7 +40,7 @@ public static IRequestExecutorBuilder AddRedisQueryStorage( } return builder.ConfigureSchemaServices( - s => s.AddRedisQueryStorage( + s => s.AddRedisOperationDocumentStorage( sp => databaseFactory(sp.GetCombinedServices()), queryExpiration)); } @@ -58,7 +58,7 @@ public static IRequestExecutorBuilder AddRedisQueryStorage( /// /// A timeout after which a query is removed from the Redis cache. /// - public static IRequestExecutorBuilder AddRedisQueryStorage( + public static IRequestExecutorBuilder AddRedisOperationDocumentStorage( this IRequestExecutorBuilder builder, Func multiplexerFactory, TimeSpan? queryExpiration = null) @@ -74,7 +74,7 @@ public static IRequestExecutorBuilder AddRedisQueryStorage( } return builder.ConfigureSchemaServices( - s => s.AddRedisQueryStorage( + s => s.AddRedisOperationDocumentStorage( sp => multiplexerFactory(sp.GetCombinedServices()).GetDatabase(), queryExpiration)); } @@ -90,7 +90,7 @@ public static IRequestExecutorBuilder AddRedisQueryStorage( /// /// A timeout after which a query is removed from the Redis cache. /// - public static IRequestExecutorBuilder AddRedisQueryStorage( + public static IRequestExecutorBuilder AddRedisOperationDocumentStorage( this IRequestExecutorBuilder builder, TimeSpan? queryExpiration = null) { @@ -99,85 +99,8 @@ public static IRequestExecutorBuilder AddRedisQueryStorage( throw new ArgumentNullException(nameof(builder)); } - return builder.AddRedisQueryStorage( + return builder.AddRedisOperationDocumentStorage( sp => sp.GetRequiredService(), queryExpiration); } - - /// - /// Adds a redis read-only query storage to the services collection. - /// - /// - /// The service collection to which the services are added. - /// - /// - /// A factory that resolves the redis database that - /// shall be used for persistence. - /// - public static IRequestExecutorBuilder AddReadOnlyRedisQueryStorage( - this IRequestExecutorBuilder builder, - Func databaseFactory) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (databaseFactory is null) - { - throw new ArgumentNullException(nameof(databaseFactory)); - } - - return builder.ConfigureSchemaServices( - s => s.AddReadOnlyRedisQueryStorage( - sp => databaseFactory(sp.GetCombinedServices()))); - } - - /// - /// Adds a redis read-only query storage to the services collection. - /// - /// - /// The service collection to which the services are added. - /// - /// - /// A factory that resolves the redis connection multiplexer. - /// - public static IRequestExecutorBuilder AddReadOnlyRedisQueryStorage( - this IRequestExecutorBuilder builder, - Func multiplexerFactory) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (multiplexerFactory is null) - { - throw new ArgumentNullException(nameof(multiplexerFactory)); - } - - return builder.ConfigureSchemaServices( - s => s.AddReadOnlyRedisQueryStorage( - sp => multiplexerFactory(sp.GetCombinedServices()).GetDatabase())); - } - - /// - /// Adds a redis read-only query storage to the services collection - /// and uses the first - /// registered on the application services. - /// - /// - /// The service collection to which the services are added. - /// - public static IRequestExecutorBuilder AddReadOnlyRedisQueryStorage( - this IRequestExecutorBuilder builder) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.AddReadOnlyRedisQueryStorage( - sp => sp.GetRequiredService()); - } } diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesServiceCollectionExtensions.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesServiceCollectionExtensions.cs index 24fe76855ad..a63dda67948 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesServiceCollectionExtensions.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/Extensions/HotChocolateRedisPersistedQueriesServiceCollectionExtensions.cs @@ -13,8 +13,7 @@ namespace HotChocolate; public static class HotChocolateRedisPersistedQueriesServiceCollectionExtensions { /// - /// Adds a redis read and write query storage to the - /// services collection. + /// Adds a Redis based operation document storage to the service collection. /// /// /// The service collection to which the services are added. @@ -26,7 +25,7 @@ public static class HotChocolateRedisPersistedQueriesServiceCollectionExtensions /// /// A timeout after which a query is removed from the Redis cache. /// - public static IServiceCollection AddRedisQueryStorage( + public static IServiceCollection AddRedisOperationDocumentStorage( this IServiceCollection services, Func databaseFactory, TimeSpan? queryExpiration = null) @@ -42,44 +41,11 @@ public static IServiceCollection AddRedisQueryStorage( } return services - .RemoveService() - .RemoveService() - .AddSingleton(sp => new RedisQueryStorage(databaseFactory(sp), queryExpiration)) - .AddSingleton(sp => sp.GetRequiredService()) - .AddSingleton(sp => sp.GetRequiredService()); + .RemoveService() + .AddSingleton( + sp => new RedisQueryStorage(databaseFactory(sp), queryExpiration)); } - - /// - /// Adds a redis read-only query storage to the services collection. - /// - /// - /// The service collection to which the services are added. - /// - /// - /// A factory that resolves the redis database that - /// shall be used for persistence. - /// - public static IServiceCollection AddReadOnlyRedisQueryStorage( - this IServiceCollection services, - Func databaseFactory) - { - if (services is null) - { - throw new ArgumentNullException(nameof(services)); - } - - if (databaseFactory is null) - { - throw new ArgumentNullException(nameof(databaseFactory)); - } - - return services - .RemoveService() - .RemoveService() - .AddSingleton(sp => new RedisQueryStorage(databaseFactory(sp))) - .AddSingleton(sp => sp.GetRequiredService()); - } - + private static IServiceCollection RemoveService( this IServiceCollection services) { @@ -92,4 +58,4 @@ private static IServiceCollection RemoveService( return services; } -} +} \ No newline at end of file diff --git a/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/RedisQueryStorage.cs b/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/RedisQueryStorage.cs index bfbf35c29d8..94626dd9a0a 100644 --- a/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/RedisQueryStorage.cs +++ b/src/HotChocolate/PersistedQueries/src/PersistedQueries.Redis/RedisQueryStorage.cs @@ -8,13 +8,9 @@ namespace HotChocolate.PersistedQueries.Redis; /// -/// An implementation of -/// and that -/// uses a redis database. +/// An implementation of that uses Redis as a storage. /// -public class RedisQueryStorage - : IReadStoredQueries - , IWriteStoredQueries +public class RedisQueryStorage : IOperationDocumentStorage { private readonly IDatabase _database; private readonly TimeSpan? _queryExpiration; @@ -33,43 +29,50 @@ public RedisQueryStorage(IDatabase database, TimeSpan? queryExpiration = null) } /// - public Task TryReadQueryAsync( - string queryId, + public ValueTask TryReadAsync( + OperationDocumentId documentId, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(queryId)) + if (OperationDocumentId.IsNullOrEmpty(documentId)) { - throw new ArgumentNullException(nameof(queryId)); + throw new ArgumentNullException(nameof(documentId)); } - return TryReadQueryInternalAsync(queryId); + return TryReadInternalAsync(documentId); } - - private async Task TryReadQueryInternalAsync( - string queryId) + + private async ValueTask TryReadInternalAsync(OperationDocumentId documentId) { - var buffer = (byte[]?)await _database.StringGetAsync(queryId).ConfigureAwait(false); - return buffer is null ? null : new QueryDocument(Utf8GraphQLParser.Parse(buffer)); + var buffer = (byte[]?)await _database.StringGetAsync(documentId.Value).ConfigureAwait(false); + return buffer is null ? null : new OperationDocument(Utf8GraphQLParser.Parse(buffer)); } /// - public Task WriteQueryAsync( - string queryId, - IQuery query, + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(queryId)) + if (OperationDocumentId.IsNullOrEmpty(documentId)) { - throw new ArgumentNullException(nameof(queryId)); + throw new ArgumentNullException(nameof(documentId)); } - - if (query is null) + + if (document is null) { - throw new ArgumentNullException(nameof(query)); + throw new ArgumentNullException(nameof(document)); } + + return SaveInternalAsync(documentId, document); + } - return _queryExpiration.HasValue - ? _database.StringSetAsync(queryId, query.AsSpan().ToArray(), _queryExpiration.Value) - : _database.StringSetAsync(queryId, query.AsSpan().ToArray()); + private async ValueTask SaveInternalAsync( + OperationDocumentId documentId, + IOperationDocument document) + { + var promise = _queryExpiration.HasValue + ? _database.StringSetAsync(documentId.Value, document.ToArray(), _queryExpiration.Value) + : _database.StringSetAsync(documentId.Value, document.ToArray()); + await promise.ConfigureAwait(false); } } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/FileSystemQueryStorageTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/FileSystemQueryStorageTests.cs index 5c39fc5fad9..726905ebe4d 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/FileSystemQueryStorageTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/FileSystemQueryStorageTests.cs @@ -16,19 +16,16 @@ public async Task Write_Query_To_Storage() try { // arrange - path = IOPath.Combine( - IOPath.GetTempPath(), - "d_" + Guid.NewGuid().ToString("N")); + path = IOPath.Combine(IOPath.GetTempPath(), "d_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(path); - var storage = new FileSystemQueryStorage( - new DefaultQueryFileMap(path)); + var storage = new FileSystemQueryStorage(new DefaultQueryFileMap(path)); - var query = new QuerySourceText("{ foo }"); - var queryId = "1234"; + var query = new OperationDocumentSourceText("{ foo }"); + var documentId = new OperationDocumentId("1234"); // act - await storage.WriteQueryAsync(queryId, query); + await storage.SaveAsync(documentId, query); // assert Assert.True(File.Exists(IOPath.Combine(path, "1234.graphql"))); @@ -43,29 +40,24 @@ public async Task Write_Query_To_Storage() } } } - - [InlineData(null)] - [InlineData("")] - [Theory] - public async Task Write_Query_QueryId_Invalid(string queryId) + + [Fact] + public async Task Write_Query_documentId_Invalid() { string? path = null; try { // arrange - path = IOPath.Combine( - IOPath.GetTempPath(), - "d_" + Guid.NewGuid().ToString("N")); + path = IOPath.Combine(IOPath.GetTempPath(), "d_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(path); - var storage = new FileSystemQueryStorage( - new DefaultQueryFileMap(path)); + var storage = new FileSystemQueryStorage(new DefaultQueryFileMap(path)); - var query = new QuerySourceText("{ foo }"); + var query = new OperationDocumentSourceText("{ foo }"); // act - Task Action() => storage.WriteQueryAsync(queryId, query); + async Task Action() => await storage.SaveAsync(new OperationDocumentId(), query); // assert await Assert.ThrowsAsync(Action); @@ -87,16 +79,13 @@ public async Task Write_Query_Query_Is_Null() try { // arrange - path = IOPath.Combine( - IOPath.GetTempPath(), - "d_" + Guid.NewGuid().ToString("N")); + path = IOPath.Combine(IOPath.GetTempPath(), "d_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(path); - var storage = new FileSystemQueryStorage( - new DefaultQueryFileMap(path)); + var storage = new FileSystemQueryStorage(new DefaultQueryFileMap(path)); // act - Task Action() => storage.WriteQueryAsync("1234", null!); + async Task Action() => await storage.SaveAsync(new OperationDocumentId("1234"), null!); // assert await Assert.ThrowsAsync(Action); @@ -123,15 +112,15 @@ public async Task Read_Query_From_Storage() var storage = new FileSystemQueryStorage(new DefaultQueryFileMap(path)); - var queryId = "1234"; - await File.WriteAllTextAsync(IOPath.Combine(path, queryId + ".graphql"), "{ foo }"); + var documentId = "1234"; + await File.WriteAllTextAsync(IOPath.Combine(path, documentId + ".graphql"), "{ foo }"); // act - var query = await storage.TryReadQueryAsync(queryId); + var query = await storage.TryReadAsync(new OperationDocumentId(documentId)); // assert Assert.NotNull(query); - query!.Document.ToString().MatchSnapshot(); + Assert.IsType(query).Document!.ToString().MatchSnapshot(); } finally { @@ -141,27 +130,22 @@ public async Task Read_Query_From_Storage() } } } - - [InlineData(null)] - [InlineData("")] - [Theory] - public async Task Read_Query_QueryId_Invalid(string queryId) + + [Fact] + public async Task Read_Query_documentId_Invalid() { string? path = null; try { // arrange - path = IOPath.Combine( - IOPath.GetTempPath(), - "d_" + Guid.NewGuid().ToString("N")); + path = IOPath.Combine(IOPath.GetTempPath(), "d_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(path); - var storage = new FileSystemQueryStorage( - new DefaultQueryFileMap(path)); + var storage = new FileSystemQueryStorage(new DefaultQueryFileMap(path)); // act - Task Action() => storage.TryReadQueryAsync(queryId); + async Task Action() => await storage.TryReadAsync(new OperationDocumentId()); // assert await Assert.ThrowsAsync(Action); diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/IntegrationTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/IntegrationTests.cs index 7c9bedad5ab..b50a99e3499 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/IntegrationTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/IntegrationTests.cs @@ -27,19 +27,19 @@ public async Task ExecutePersistedQuery() { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() .BuildRequestExecutorAsync(); // act - var result = await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + var result = await executor.ExecuteAsync(OperationRequest.FromId(queryId)); // assert File.Delete(cachedQuery); @@ -65,19 +65,19 @@ public async Task ExecutePersistedQuery_NotFound() { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() .BuildRequestExecutorAsync(); // act - var result = await executor.ExecuteAsync(new QueryRequest(queryId: "does_not_exist")); + var result = await executor.ExecuteAsync(OperationRequest.FromId("does_not_exist")); // assert File.Delete(cachedQuery); diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/ServiceCollectionTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/ServiceCollectionTests.cs index afeebe7bfa0..a3261aee6bb 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/ServiceCollectionTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/ServiceCollectionTests.cs @@ -13,7 +13,7 @@ public void AddFileSystemQueryStorage_Services_Is_Null() // act void Action() => HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions - .AddFileSystemQueryStorage(null!); + .AddFileSystemOperationDocumentStorage(null!); // assert Assert.Throws(Action); @@ -26,7 +26,7 @@ public void AddFileSystemQueryStorage_1_Services() var services = new ServiceCollection(); // act - services.AddFileSystemQueryStorage("foo"); + services.AddFileSystemOperationDocumentStorage("foo"); // assert services.ToDictionary( @@ -42,7 +42,7 @@ public void AddFileSystemQueryStorage_2_Services() var services = new ServiceCollection(); // act - services.AddFileSystemQueryStorage(); + services.AddFileSystemOperationDocumentStorage(); // assert services.ToDictionary( @@ -58,7 +58,7 @@ public void AddReadOnlyFileSystemQueryStorage_Services_Is_Null() // act void Action() => HotChocolateFileSystemPersistedQueriesServiceCollectionExtensions - .AddReadOnlyFileSystemQueryStorage(null!); + .AddFileSystemOperationDocumentStorage(null!); // assert Assert.Throws((Action) Action); @@ -71,7 +71,7 @@ public void AddReadOnlyFileSystemQueryStorage_1_Services() var services = new ServiceCollection(); // act - services.AddReadOnlyFileSystemQueryStorage("foo"); + services.AddFileSystemOperationDocumentStorage("foo"); // assert services.ToDictionary( @@ -88,7 +88,7 @@ public void AddReadOnlyFileSystemQueryStorage_2_Services() var services = new ServiceCollection(); // act - services.AddReadOnlyFileSystemQueryStorage(); + services.AddFileSystemOperationDocumentStorage(); // assert services.ToDictionary( diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap index b09b91346d1..4c9157734be 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap index 44a94577351..ad1afe74fa4 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": null, @@ -12,7 +14,10 @@ "Locations": null, "Extensions": { "code": "HC0020", - "requestedKey": "does_not_exist" + "requestedKey": { + "IsEmpty": false, + "Value": "does_not_exist" + } }, "Exception": null } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_1_Services.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_1_Services.snap index f3d0728f1da..fdc43c35ce2 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_1_Services.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_1_Services.snap @@ -1,6 +1,4 @@ { - "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage", - "HotChocolate.Execution.IReadStoredQueries": null, - "HotChocolate.PersistedQueries.FileSystem.IQueryFileMap": null, - "HotChocolate.Execution.IWriteStoredQueries": null + "HotChocolate.Execution.IOperationDocumentStorage": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage", + "HotChocolate.PersistedQueries.FileSystem.IQueryFileMap": null } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_2_Services.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_2_Services.snap index f3d0728f1da..fdc43c35ce2 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_2_Services.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddFileSystemQueryStorage_2_Services.snap @@ -1,6 +1,4 @@ { - "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage", - "HotChocolate.Execution.IReadStoredQueries": null, - "HotChocolate.PersistedQueries.FileSystem.IQueryFileMap": null, - "HotChocolate.Execution.IWriteStoredQueries": null + "HotChocolate.Execution.IOperationDocumentStorage": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage", + "HotChocolate.PersistedQueries.FileSystem.IQueryFileMap": null } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_1_Services.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_1_Services.snap index b252fc074f5..2e0ff4ebb3b 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_1_Services.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_1_Services.snap @@ -1,10 +1,6 @@ [ { - "Key": "HotChocolate.Execution.IReadStoredQueries", - "Value": null - }, - { - "Key": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage", + "Key": "HotChocolate.Execution.IOperationDocumentStorage", "Value": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage" }, { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_2_Services.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_2_Services.snap index b252fc074f5..2e0ff4ebb3b 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_2_Services.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.FileSystem.Tests/__snapshots__/ServiceCollectionTests.AddReadOnlyFileSystemQueryStorage_2_Services.snap @@ -1,10 +1,6 @@ [ { - "Key": "HotChocolate.Execution.IReadStoredQueries", - "Value": null - }, - { - "Key": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage", + "Key": "HotChocolate.Execution.IOperationDocumentStorage", "Value": "HotChocolate.PersistedQueries.FileSystem.FileSystemQueryStorage" }, { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/InMemoryQueryStorageTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/InMemoryQueryStorageTests.cs index e5ded1c654b..eec3788c8e0 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/InMemoryQueryStorageTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/InMemoryQueryStorageTests.cs @@ -14,24 +14,24 @@ public async Task Write_Query_To_Storage() // arrange var serviceCollection = new ServiceCollection(); serviceCollection.AddMemoryCache(); - serviceCollection.AddInMemoryQueryStorage(); + serviceCollection.AddInMemoryOperationDocumentStorage(); IServiceProvider services = serviceCollection.BuildServiceProvider(); var memoryCache = services.GetRequiredService(); - var queryStorage = services.GetRequiredService(); + var queryStorage = services.GetRequiredService(); const string queryId = "abc"; var query = Utf8GraphQLParser.Parse("{ __typename }"); // act - await queryStorage.WriteQueryAsync( - queryId, - new QueryDocument(query), + await queryStorage.SaveAsync( + new OperationDocumentId(queryId), + new OperationDocument(query), CancellationToken.None); // assert Assert.True(memoryCache.TryGetValue(queryId, out var o)); - await Assert.IsType>(o); + Assert.IsType(o); } [Fact] @@ -40,23 +40,23 @@ public async Task Read_Query_From_Storage() // arrange var serviceCollection = new ServiceCollection(); serviceCollection.AddMemoryCache(); - serviceCollection.AddInMemoryQueryStorage(); + serviceCollection.AddInMemoryOperationDocumentStorage(); IServiceProvider services = serviceCollection.BuildServiceProvider(); var memoryCache = services.GetRequiredService(); - var queryStorage = services.GetRequiredService(); + var queryStorage = services.GetRequiredService(); const string queryId = "abc"; var query = Utf8GraphQLParser.Parse("{ __typename }"); - await memoryCache.GetOrCreate(queryId, _ => Task.FromResult(new QueryDocument(query)))!; + memoryCache.GetOrCreate(queryId, _ => new OperationDocument(query)); // act - var document = await queryStorage.TryReadQueryAsync( - queryId, + var document = await queryStorage.TryReadAsync( + new OperationDocumentId(queryId), CancellationToken.None); // assert Assert.NotNull(document); - Assert.Same(query, document!.Document); + Assert.Same(query, Assert.IsType(document).Document); } } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/IntegrationTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/IntegrationTests.cs index e70be31f47f..e828a3b8347 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/IntegrationTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/IntegrationTests.cs @@ -21,17 +21,17 @@ public async Task ExecutePersistedQuery() .AddMemoryCache() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddInMemoryQueryStorage() + .AddInMemoryOperationDocumentStorage() .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() @@ -41,10 +41,10 @@ public async Task ExecutePersistedQuery() var cache = services.GetRequiredService(); var executor = await services.GetRequestExecutorAsync(); - await cache.GetOrCreate(queryId, _ => Task.FromResult(new QueryDocument(document)))!; + cache.GetOrCreate(queryId, _ => new OperationDocument(document)); // act - var result = await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + var result = await executor.ExecuteAsync(OperationRequest.FromId(queryId)); // assert result.ToJson().MatchSnapshot(); @@ -59,17 +59,17 @@ public async Task ExecutePersistedQuery_NotFound() .AddMemoryCache() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddInMemoryQueryStorage() + .AddInMemoryOperationDocumentStorage() .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() @@ -79,8 +79,7 @@ public async Task ExecutePersistedQuery_NotFound() var executor = await services.GetRequestExecutorAsync(); // act - var result = - await executor.ExecuteAsync(new QueryRequest(queryId: "does_not_exist")); + var result = await executor.ExecuteAsync(OperationRequest.FromId("does_not_exist")); // assert result.ToJson().MatchSnapshot(); diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/RequestExecutorBuilderTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/RequestExecutorBuilderTests.cs index 8fa0cc88899..ccc5540398c 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/RequestExecutorBuilderTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/RequestExecutorBuilderTests.cs @@ -11,21 +11,8 @@ public void AddFileSystemQueryStorage_2_Services_Is_Null() // act void Action() => HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderExtensions - .AddInMemoryQueryStorage(null!); + .AddInMemoryOperationDocumentStorage(null!); Assert.Throws(Action); } - - [Fact] - public void AddReadOnlyFileSystemQueryStorage_Services_Is_Null() - { - // arrange - // act - void Action() - => HotChocolateInMemoryPersistedQueriesRequestExecutorBuilderExtensions - .AddReadOnlyInMemoryQueryStorage(null!); - - // assert - Assert.Throws(Action); - } } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/ServiceCollectionTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/ServiceCollectionTests.cs index 2b86c4cf26b..ebf7d2e9257 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/ServiceCollectionTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.InMemory.Tests/ServiceCollectionTests.cs @@ -9,22 +9,10 @@ public void AddFileSystemQueryStorage_Services_Is_Null() // act void Action() => HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions - .AddInMemoryQueryStorage(null!); + .AddInMemoryOperationDocumentStorage(null!); // assert - Assert.Throws((Action) Action); - } - - [Fact] - public void AddReadOnlyFileSystemQueryStorage_Services_Is_Null() - { - // arrange - // act - void Action() - => HotChocolateInMemoryPersistedQueriesServiceCollectionExtensions - .AddReadOnlyInMemoryQueryStorage(null!); - - // assert - Assert.Throws(Action); + Assert.Throws((Action)Action); } } + diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/IntegrationTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/IntegrationTests.cs index 39decbe4dd7..261e0b1b5b2 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/IntegrationTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/IntegrationTests.cs @@ -22,32 +22,35 @@ public IntegrationTests(RedisResource redisResource) public async Task ExecutePersistedQuery() { // arrange - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); var storage = new RedisQueryStorage(_database); - await storage.WriteQueryAsync(queryId, new QuerySourceText("{ __typename }")); + + await storage.SaveAsync( + documentId, + new OperationDocumentSourceText("{ __typename }")); var executor = await new ServiceCollection() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddRedisQueryStorage(_ => _database) + .AddRedisOperationDocumentStorage(_ => _database) .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() .BuildRequestExecutorAsync(); // act - var result = await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + var result = await executor.ExecuteAsync(OperationRequest.FromId(documentId)); // assert result.MatchSnapshot(); @@ -57,37 +60,37 @@ public async Task ExecutePersistedQuery() public async Task ExecutePersistedQuery_After_Expiration() { // arrange - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); var executor = await new ServiceCollection() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddRedisQueryStorage(_ => _database, TimeSpan.FromMilliseconds(10)) + .AddRedisOperationDocumentStorage(_ => _database, TimeSpan.FromMilliseconds(10)) .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() .BuildRequestExecutorAsync(); // ... write query to cache - var cache = executor.Services.GetRequiredService(); - await cache.WriteQueryAsync(queryId, new QuerySourceText("{ __typename }")); + var cache = executor.Services.GetRequiredService(); + await cache.SaveAsync(documentId, new OperationDocumentSourceText("{ __typename }")); // ... wait for query to expire await Task.Delay(100).ConfigureAwait(false); // act - var result = await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + var result = await executor.ExecuteAsync(OperationRequest.FromId(documentId)); // assert Assert.Collection( @@ -103,32 +106,32 @@ public async Task ExecutePersistedQuery_After_Expiration() public async Task ExecutePersistedQuery_Before_Expiration() { // arrange - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); var storage = new RedisQueryStorage(_database, TimeSpan.FromMilliseconds(10000)); - await storage.WriteQueryAsync(queryId, new QuerySourceText("{ __typename }")); + await storage.SaveAsync(documentId, new OperationDocumentSourceText("{ __typename }")); var executor = await new ServiceCollection() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddRedisQueryStorage(_ => _database) + .AddRedisOperationDocumentStorage(_ => _database) .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() .BuildRequestExecutorAsync(); // act - var result = await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + var result = await executor.ExecuteAsync(OperationRequest.FromId(documentId)); // assert Assert.Null(result.ExpectQueryResult().Errors); @@ -140,9 +143,9 @@ public async Task ExecutePersistedQuery_Before_Expiration() public async Task ExecutePersistedQuery_ApplicationDI() { // arrange - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); var storage = new RedisQueryStorage(_database); - await storage.WriteQueryAsync(queryId, new QuerySourceText("{ __typename }")); + await storage.SaveAsync(documentId, new OperationDocumentSourceText("{ __typename }")); var executor = await new ServiceCollection() @@ -151,17 +154,17 @@ public async Task ExecutePersistedQuery_ApplicationDI() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) // and in the redis storage setup refer to that instance. - .AddRedisQueryStorage(sp => sp.GetRequiredService()) + .AddRedisOperationDocumentStorage(sp => sp.GetRequiredService()) .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() @@ -169,7 +172,7 @@ public async Task ExecutePersistedQuery_ApplicationDI() // act var result = - await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + await executor.ExecuteAsync(OperationRequest.FromId(documentId)); // assert result.MatchSnapshot(); @@ -179,9 +182,9 @@ public async Task ExecutePersistedQuery_ApplicationDI() public async Task ExecutePersistedQuery_ApplicationDI_Default() { // arrange - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); var storage = new RedisQueryStorage(_database); - await storage.WriteQueryAsync(queryId, new QuerySourceText("{ __typename }")); + await storage.SaveAsync(documentId, new OperationDocumentSourceText("{ __typename }")); var executor = await new ServiceCollection() @@ -190,17 +193,17 @@ public async Task ExecutePersistedQuery_ApplicationDI_Default() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) // and in the redis storage setup refer to that instance. - .AddRedisQueryStorage() + .AddRedisOperationDocumentStorage() .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() @@ -208,7 +211,7 @@ public async Task ExecutePersistedQuery_ApplicationDI_Default() // act var result = - await executor.ExecuteAsync(new QueryRequest(queryId: queryId)); + await executor.ExecuteAsync(OperationRequest.FromId(documentId)); // assert result.MatchSnapshot(); @@ -218,25 +221,25 @@ public async Task ExecutePersistedQuery_ApplicationDI_Default() public async Task ExecutePersistedQuery_NotFound() { // arrange - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); var storage = new RedisQueryStorage(_database); - await storage.WriteQueryAsync(queryId, new QuerySourceText("{ __typename }")); + await storage.SaveAsync(documentId, new OperationDocumentSourceText("{ __typename }")); var executor = await new ServiceCollection() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddRedisQueryStorage(_ => _database) + .AddRedisOperationDocumentStorage(_ => _database) .UseRequest(n => async c => { await n(c); - if (c.IsPersistedDocument && c.Result is IQueryResult r) + if (c.IsPersistedDocument && c.Result is IOperationResult r) { - c.Result = QueryResultBuilder + c.Result = OperationResultBuilder .FromResult(r) .SetExtension("persistedDocument", true) - .Create(); + .Build(); } }) .UsePersistedQueryPipeline() @@ -244,7 +247,7 @@ public async Task ExecutePersistedQuery_NotFound() // act var result = - await executor.ExecuteAsync(new QueryRequest(queryId: "does_not_exist")); + await executor.ExecuteAsync(OperationRequest.FromId("does_not_exist")); // assert result.MatchSnapshot(); diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RedisQueryStorageTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RedisQueryStorageTests.cs index d1199a59f85..585e6f4c58e 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RedisQueryStorageTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RedisQueryStorageTests.cs @@ -1,5 +1,4 @@ -using System.Text; -using HotChocolate.Execution; +using HotChocolate.Execution; using HotChocolate.Language; using HotChocolate.Language.Utilities; using Snapshooter.Xunit; @@ -8,50 +7,44 @@ namespace HotChocolate.PersistedQueries.Redis; -public class RedisQueryStorageTests - : IClassFixture +public class RedisQueryStorageTests(RedisResource redisResource) : IClassFixture { - private readonly IDatabase _database; - - public RedisQueryStorageTests(RedisResource redisResource) - { - _database = redisResource.GetConnection().GetDatabase(); - } + private readonly IDatabase _database = redisResource.GetConnection().GetDatabase(); [Fact] public Task Write_Query_To_Storage() { var snapshotName = Snapshot.FullName(); - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); return TryTest(async () => { // arrange var storage = new RedisQueryStorage(_database); - var query = new QuerySourceText("{ foo }"); + var query = new OperationDocumentSourceText("{ foo }"); // act - await storage.WriteQueryAsync(queryId, query); + await storage.SaveAsync(documentId, query); // assert - var buffer = ((byte[])await _database.StringGetAsync(queryId!))!; + var buffer = ((byte[])await _database.StringGetAsync(documentId.Value))!; Utf8GraphQLParser.Parse(buffer).Print().MatchSnapshot(snapshotName); }, - () => _database.KeyDeleteAsync(queryId)); + () => _database.KeyDeleteAsync(documentId.Value)); } - - [InlineData(null)] - [InlineData("")] - [Theory] - public Task Write_Query_QueryId_Invalid(string queryId) + + [Fact] + public Task Write_Query_documentId_Invalid() { + var documentId = new OperationDocumentId(); + return TryTest(async () => { var storage = new RedisQueryStorage(_database); - var query = new QuerySourceText("{ foo }"); + var query = new OperationDocumentSourceText("{ foo }"); // act - Task Action() => storage.WriteQueryAsync(queryId, query); + async Task Action() => await storage.SaveAsync(documentId, query); // assert await Assert.ThrowsAsync(Action); @@ -64,10 +57,10 @@ public Task Write_Query_Query_Is_Null() return TryTest(async () => { var storage = new RedisQueryStorage(_database); - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); // act - Task Action() => storage.WriteQueryAsync(queryId, null!); + async Task Action() => await storage.SaveAsync(documentId, null!); // assert await Assert.ThrowsAsync(Action); @@ -78,36 +71,35 @@ public Task Write_Query_Query_Is_Null() public Task Read_Query_From_Storage() { var snapshotName = Snapshot.FullName(); - var queryId = Guid.NewGuid().ToString("N"); + var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); return TryTest(async () => { // arrange var storage = new RedisQueryStorage(_database); - var buffer = Encoding.UTF8.GetBytes("{ foo }"); - await _database.StringSetAsync(queryId, buffer); + var buffer = "{ foo }"u8.ToArray(); + await _database.StringSetAsync(documentId.Value, buffer); // act - var query = await storage.TryReadQueryAsync(queryId); + var query = await storage.TryReadAsync(documentId); // assert Assert.NotNull(query); - query!.Document.Print().MatchSnapshot(snapshotName); + Assert.IsType(query).Document.Print().MatchSnapshot(snapshotName); }, - () => _database.KeyDeleteAsync(queryId)); + () => _database.KeyDeleteAsync(documentId.Value)); } - [InlineData(null)] - [InlineData("")] - [Theory] - public Task Read_Query_QueryId_Invalid(string queryId) + [Fact] + public Task Read_Query_documentId_Invalid() { + var documentId = new OperationDocumentId(); return TryTest(async () => { var storage = new RedisQueryStorage(_database); // act - Task Action() => storage.TryReadQueryAsync(queryId); + async Task Action() => await storage.TryReadAsync(documentId); // assert await Assert.ThrowsAsync(Action); diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RequestExecutorBuilderTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RequestExecutorBuilderTests.cs index 02ad859e056..95b94b16617 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RequestExecutorBuilderTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/RequestExecutorBuilderTests.cs @@ -22,7 +22,7 @@ public void AddRedisQueryStorage_Services_Is_Null() // act void Action() => HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions - .AddRedisQueryStorage(null!, _ => _database); + .AddRedisOperationDocumentStorage(null!, _ => _database); // assert Assert.Throws(Action); @@ -35,7 +35,7 @@ public void AddRedisQueryStorage_MultiplexerServices_Is_Null() // act void Action() => HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions - .AddRedisQueryStorage(null!, _ => _multiplexer); + .AddRedisOperationDocumentStorage(null!, _ => _multiplexer); // assert Assert.Throws(Action); @@ -48,7 +48,7 @@ public void AddRedisQueryStorage_DefaultServices_Is_Null() // act void Action() => HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions - .AddRedisQueryStorage(null!); + .AddRedisOperationDocumentStorage(null!); // assert Assert.Throws(Action); @@ -62,7 +62,7 @@ public void AddRedisQueryStorage_Factory_Is_Null() // act void Action() => - builder.AddRedisQueryStorage(default(Func)!); + builder.AddRedisOperationDocumentStorage(default(Func)!); // assert Assert.Throws(Action); @@ -76,75 +76,7 @@ public void AddRedisQueryStorage_MultiplexerFactory_Is_Null() // act void Action() => - builder.AddRedisQueryStorage(default(Func)!); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_Services_Is_Null() - { - // arrange - // act - void Action() => - HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions - .AddReadOnlyRedisQueryStorage(null!, _ => _database); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_MultiplexerServices_Is_Null() - { - // arrange - // act - void Action() => - HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions - .AddReadOnlyRedisQueryStorage(null!, _ => _multiplexer); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_DefaultServices_Is_Null() - { - // arrange - // act - void Action() => - HotChocolateRedisPersistedQueriesRequestExecutorBuilderExtensions - .AddReadOnlyRedisQueryStorage(null!); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_Factory_Is_Null() - { - // arrange - var builder = new ServiceCollection().AddGraphQL(); - - // act - void Action() => - builder.AddReadOnlyRedisQueryStorage(default(Func)!); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_MultiplexerFactory_Is_Null() - { - // arrange - var builder = new ServiceCollection().AddGraphQL(); - - // act - void Action() => - builder.AddReadOnlyRedisQueryStorage( - default(Func)!); + builder.AddRedisOperationDocumentStorage(default(Func)!); // assert Assert.Throws(Action); diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/ServiceCollectionExtensionsTests.cs b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/ServiceCollectionExtensionsTests.cs index 5fa004d6eec..edbe06c0ec2 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/ServiceCollectionExtensionsTests.cs +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/ServiceCollectionExtensionsTests.cs @@ -23,7 +23,7 @@ public void AddRedisQueryStorage_Services_Is_Null() // act void Action() => HotChocolateRedisPersistedQueriesServiceCollectionExtensions - .AddRedisQueryStorage(null!, _ => _database); + .AddRedisOperationDocumentStorage(null!, _ => _database); // assert Assert.Throws(Action); @@ -37,7 +37,7 @@ public void AddRedisQueryStorage_Factory_Is_Null() // act void Action() - => services.AddRedisQueryStorage(null!); + => services.AddRedisOperationDocumentStorage(null!); // assert Assert.Throws(Action); @@ -50,51 +50,7 @@ public void AddRedisQueryStorage_Services() var services = new ServiceCollection(); // act - services.AddRedisQueryStorage(_ => _database); - - // assert - services.ToDictionary( - k => k.ServiceType.GetTypeName(), - v => v.ImplementationType?.GetTypeName()) - .OrderBy(t => t.Key) - .MatchSnapshot(); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_Services_Is_Null() - { - // arrange - // act - void Action() - => HotChocolateRedisPersistedQueriesServiceCollectionExtensions - .AddReadOnlyRedisQueryStorage(null!, _ => _database); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_Factory_Is_Null() - { - // arrange - var services = new ServiceCollection(); - - // act - void Action() - => services.AddReadOnlyRedisQueryStorage(null!); - - // assert - Assert.Throws(Action); - } - - [Fact] - public void AddReadOnlyRedisQueryStorage_Services() - { - // arrange - var services = new ServiceCollection(); - - // act - services.AddReadOnlyRedisQueryStorage(_ => _database); + services.AddRedisOperationDocumentStorage(_ => _database); // assert services.ToDictionary( diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap index b09b91346d1..4c9157734be 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI.snap index b09b91346d1..4c9157734be 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI_Default.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI_Default.snap index b09b91346d1..4c9157734be 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI_Default.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_ApplicationDI_Default.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_Before_Expiration.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_Before_Expiration.snap index b09b91346d1..4c9157734be 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_Before_Expiration.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_Before_Expiration.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": { diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap index 44a94577351..ad1afe74fa4 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/IntegrationTests.ExecutePersistedQuery_NotFound.snap @@ -1,5 +1,7 @@ { "Kind": "SingleResult", + "RequestIndex": null, + "VariableIndex": null, "Label": null, "Path": null, "Data": null, @@ -12,7 +14,10 @@ "Locations": null, "Extensions": { "code": "HC0020", - "requestedKey": "does_not_exist" + "requestedKey": { + "IsEmpty": false, + "Value": "does_not_exist" + } }, "Exception": null } diff --git a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/ServiceCollectionExtensionsTests.AddRedisQueryStorage_Services.snap b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/ServiceCollectionExtensionsTests.AddRedisQueryStorage_Services.snap index 9a2e0384122..59a5afafa7a 100644 --- a/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/ServiceCollectionExtensionsTests.AddRedisQueryStorage_Services.snap +++ b/src/HotChocolate/PersistedQueries/test/PersistedQueries.Redis.Tests/__snapshots__/ServiceCollectionExtensionsTests.AddRedisQueryStorage_Services.snap @@ -1,14 +1,6 @@ [ { - "Key": "HotChocolate.Execution.IReadStoredQueries", - "Value": null - }, - { - "Key": "HotChocolate.Execution.IWriteStoredQueries", - "Value": null - }, - { - "Key": "HotChocolate.PersistedQueries.Redis.RedisQueryStorage", + "Key": "HotChocolate.Execution.IOperationDocumentStorage", "Value": null } ] diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs index 8d3da2f61f8..ddb2ac1dcec 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs @@ -60,10 +60,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilteringAndPaging.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilteringAndPaging.cs index bc278fcfcd5..e6d0f67f45b 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilteringAndPaging.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilteringAndPaging.cs @@ -27,14 +27,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ nodes { bar } }}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ nodes { bar }}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorBooleanTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorBooleanTests.cs index 6c017a65f34..ef08e518dba 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorBooleanTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorBooleanTests.cs @@ -34,14 +34,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -59,14 +59,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -84,19 +84,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -116,19 +116,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorComparableTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorComparableTests.cs index 00481796c61..696a84002f6 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorComparableTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorComparableTests.cs @@ -36,19 +36,19 @@ public async Task Create_ShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -67,19 +67,19 @@ public async Task Create_ShortNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -98,24 +98,24 @@ public async Task Create_ShortGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -135,24 +135,24 @@ public async Task Create_ShortNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -173,24 +173,24 @@ public async Task Create_ShortGreaterThanOrEquals_Expression() // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -210,24 +210,24 @@ public async Task Create_ShortNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -247,24 +247,24 @@ public async Task Create_ShortLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -284,24 +284,24 @@ public async Task Create_ShortNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -322,24 +322,24 @@ public async Task Create_ShortLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -359,24 +359,24 @@ public async Task Create_ShortNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -396,19 +396,19 @@ public async Task Create_ShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -427,19 +427,19 @@ public async Task Create_ShortNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ null, 14 ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -458,19 +458,19 @@ public async Task Create_ShortNullableEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { eq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { eq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -489,19 +489,19 @@ public async Task Create_ShortNullableNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { neq: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { neq: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -521,24 +521,24 @@ public async Task Create_ShortNullableGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -558,24 +558,24 @@ public async Task Create_ShortNullableNotGreaterThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -596,24 +596,24 @@ public async Task Create_ShortNullableGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { gte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { gte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -633,24 +633,24 @@ public async Task Create_ShortNullableNotGreaterThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { ngte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { ngte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -670,24 +670,24 @@ public async Task Create_ShortNullableLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -707,24 +707,24 @@ public async Task Create_ShortNullableNotLowerThan_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlt: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlt: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -745,24 +745,24 @@ public async Task Create_ShortNullableLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { lte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { lte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -782,24 +782,24 @@ public async Task Create_ShortNullableNotLowerThanOrEquals_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 12}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 12}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 13}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 13}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: 14}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: 14}}){ barShort}}") + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nlte: null}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nlte: null}}){ barShort}}") + .Build()); // assert await Snapshot @@ -819,19 +819,19 @@ public async Task Create_ShortNullableIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { in: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot @@ -850,19 +850,19 @@ public async Task Create_ShortNullableNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 12, 13 ]}}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, 14 ]}}){ barShort}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barShort: { nin: [ 13, null ]}}){ barShort}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorEnumTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorEnumTests.cs index c9ffeaba514..eefe5731c93 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorEnumTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorEnumTests.cs @@ -38,19 +38,19 @@ public async Task Create_EnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -69,19 +69,19 @@ public async Task Create_EnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }){ barEnum } }") + .Build()); // assert await Snapshot @@ -100,19 +100,19 @@ public async Task Create_EnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ]}}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ]}}){ barEnum}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ]}}){ barEnum}}") + .Build()); // assert await Snapshot @@ -131,19 +131,19 @@ public async Task Create_EnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -163,19 +163,19 @@ public async Task Create_NullableEnumEqual_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { eq: null } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { eq: null } }){ barEnum } }") + .Build()); // assert await Snapshot @@ -194,19 +194,19 @@ public async Task Create_NullableEnumNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: BAR } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: FOO } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { neq: null } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { neq: null } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -225,19 +225,19 @@ public async Task Create_NullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ BAR FOO ] } }) { barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { in: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot @@ -256,19 +256,19 @@ public async Task Create_NullableEnumNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ BAR FOO ] } }){ barEnum } }") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ FOO ] } }) { barEnum } }") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { barEnum: { nin: [ null FOO ] } }) { barEnum } }") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorExecutableTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorExecutableTests.cs index c78f2c86f6f..2f9546eefae 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorExecutableTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorExecutableTests.cs @@ -34,14 +34,14 @@ public async Task Create_BooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -59,14 +59,14 @@ public async Task Create_BooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); // assert await Snapshot @@ -84,19 +84,19 @@ public async Task Create_NullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -115,19 +115,19 @@ public async Task Create_NullableBooleanNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: true}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: false}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs index bed31139271..8746197fe31 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorInterfacesTests.cs @@ -33,25 +33,25 @@ public async Task Create_InterfaceStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"a\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: \"b\"}}}) " + "{ test{ prop }}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { test: { prop: { eq: null}}}) " + "{ test{ prop}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorListTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorListTests.cs index 43a92cdf232..d56d97b9898 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorListTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorListTests.cs @@ -60,8 +60,8 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { fooNested: { @@ -77,19 +77,19 @@ public async Task Create_ArraySomeObjectStringEqualWithNull_Expression() } } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { some: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -108,22 +108,22 @@ public async Task Create_ArrayNoneObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"a\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: \"d\"}}}}){ fooNested {bar}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { none: {bar: { eq: null}}}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot @@ -142,16 +142,16 @@ public async Task Create_ArrayAnyObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { any: false}}){ fooNested {bar}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { fooNested: { any: true}}){ fooNested {bar}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorObjectTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorObjectTests.cs index 1357f0d76d1..df0a0a138a3 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorObjectTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorObjectTests.cs @@ -124,25 +124,25 @@ public async Task Create_ObjectShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -161,25 +161,25 @@ public async Task Create_ObjectShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ null, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -198,25 +198,25 @@ public async Task Create_ObjectNullableShortEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 12}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: 13}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { eq: null}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -235,25 +235,25 @@ public async Task Create_ObjectNullableShortIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 12, 13 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, 14 ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barShort: { in: [ 13, null ]}}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -272,18 +272,18 @@ public async Task Create_ObjectBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -301,25 +301,25 @@ public async Task Create_ObjectNullableBooleanEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: true}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: false}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barBool: { eq: null}}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -338,25 +338,25 @@ public async Task Create_ObjectEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -375,25 +375,25 @@ public async Task Create_ObjectEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -419,25 +419,25 @@ public async Task Create_ObjectNullableEnumEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: BAR}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: FOO}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { eq: null}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -466,25 +466,25 @@ public async Task Create_ObjectNullableEnumIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ BAR FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barEnum: { in: [ null FOO ]}}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -503,24 +503,24 @@ public async Task Create_ObjectStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testatest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: \"testbtest\"}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { eq: null}}}){ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -539,26 +539,26 @@ public async Task Create_ObjectStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: " + "[ \"testatest\" \"testbtest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [\"testbtest\" null]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { barString: { in: [ \"testatest\" ]}}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -577,28 +577,28 @@ public async Task Create_ArrayObjectNestedArraySomeStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"a\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: \"d\"}}}}}}) " + "{ foo { objectArray { foo { barString}}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo:{ objectArray: { " + "some: { foo: { barString: { eq: null}}}}}}) " + "{ foo { objectArray { foo {barString}}}}}") - .Create()); + .Build()); // assert await Snapshot @@ -619,25 +619,25 @@ public async Task Create_ArrayObjectNestedArrayAnyStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: false}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: true}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { foo: { objectArray: { any: null}}}) " + "{ foo { objectArray { foo { barString }}}}}") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorStringTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorStringTests.cs index 3cc2e46cdbb..04b9d2ad80b 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorStringTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/QueryableFilterVisitorStringTests.cs @@ -34,19 +34,19 @@ public async Task Create_StringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -65,19 +65,19 @@ public async Task Create_StringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot @@ -96,20 +96,20 @@ public async Task Create_StringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -128,20 +128,20 @@ public async Task Create_StringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -160,19 +160,19 @@ public async Task Create_StringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -191,19 +191,19 @@ public async Task Create_StringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -223,19 +223,19 @@ public async Task Create_StringStartsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -254,19 +254,19 @@ public async Task Create_StringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -285,19 +285,19 @@ public async Task Create_StringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( @@ -316,19 +316,19 @@ public async Task Create_StringNotEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( @@ -347,19 +347,19 @@ public async Task Create_NullableStringEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { eq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { eq: null}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatest").AddResult( @@ -379,19 +379,19 @@ public async Task Create_NullableStringNotEqual_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testatest\"}}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: \"testbtest\"}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { neq: null}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { neq: null}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatest").AddResult( @@ -410,20 +410,20 @@ public async Task Create_NullableStringIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { in: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { in: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -443,20 +443,20 @@ public async Task Create_NullableStringNotIn_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(where: { bar: { nin: [ \"testatest\" \"testbtest\" ]}}){ bar}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [\"testbtest\" null]}}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nin: [ \"testatest\" ]}}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testatestAndtestb").AddResult( @@ -476,19 +476,19 @@ public async Task Create_NullableStringContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { contains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { contains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -507,19 +507,19 @@ public async Task Create_NullableStringNoContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"a\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: \"b\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { ncontains: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { ncontains: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "a").AddResult( @@ -539,19 +539,19 @@ public async Task Create_NullableStringStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { startsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { startsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -571,19 +571,19 @@ public async Task Create_NullableStringNotStartsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testa\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: \"testb\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nstartsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nstartsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "testa").AddResult( @@ -603,19 +603,19 @@ public async Task Create_NullableStringEndsWith_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { endsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { endsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( @@ -636,19 +636,19 @@ public async Task Create_NullableStringNotEndsWith_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"atest\" }}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: \"btest\" }}){ bar}}") + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(where: { bar: { nendsWith: null }}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(where: { bar: { nendsWith: null }}){ bar}}") + .Build()); // assert await Snapshot.Create().AddResult(res1, "atest").AddResult( diff --git a/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenAsyncDocumentQueryTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenAsyncDocumentQueryTests.cs index 8ff847d20bd..62ed56155b0 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenAsyncDocumentQueryTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenAsyncDocumentQueryTests.cs @@ -430,10 +430,10 @@ private ValueTask CreateSchemaAsync() if (context.ContextData.TryGetValue("query", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenDocumentQueryTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenDocumentQueryTests.cs index 70e4237b17d..8be74fec7a2 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenDocumentQueryTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/RavenDocumentQueryTests.cs @@ -427,10 +427,10 @@ private ValueTask CreateSchemaAsync() await next(context); if (context.ContextData.TryGetValue("query", out var queryString)) { - context.Result = QueryResultBuilder + context.Result = OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("query", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/VisitorTestBase.cs b/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/VisitorTestBase.cs index 260467a382b..70e4728304e 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/VisitorTestBase.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Paging.Tests/VisitorTestBase.cs @@ -67,10 +67,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/ProjectionVisitorTestBase.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/ProjectionVisitorTestBase.cs index 12a4e3a5059..a455b3079f9 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/ProjectionVisitorTestBase.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/ProjectionVisitorTestBase.cs @@ -104,10 +104,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline(); diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableFirstOrDefaultTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableFirstOrDefaultTests.cs index 8ea12b900a1..593b842b9cd 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableFirstOrDefaultTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableFirstOrDefaultTests.cs @@ -120,8 +120,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -134,7 +134,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -151,8 +151,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -166,7 +166,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -183,8 +183,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -197,7 +197,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -214,8 +214,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -229,7 +229,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -246,8 +246,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ rootExecutable { foo { @@ -260,7 +260,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionFilterTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionFilterTests.cs index 4238d7edd96..f5c03095669 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionFilterTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionFilterTests.cs @@ -140,8 +140,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -161,7 +161,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -177,8 +177,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -200,7 +200,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -216,8 +216,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -237,7 +237,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -253,8 +253,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -275,7 +275,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -291,8 +291,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { foo { @@ -300,7 +300,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -316,8 +316,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFiel // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { id @@ -327,7 +327,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_TwoFiel } } }") - .Create()); + .Build()); // assert await Snapshot @@ -343,8 +343,8 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { id @@ -359,7 +359,7 @@ public async Task Should_NotInitializeObject_When_ResultOfLeftJoinIsNull_Deep() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionHashSetTest.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionHashSetTest.cs index 06f3d6c4acc..feabc436e02 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionHashSetTest.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionHashSetTest.cs @@ -63,8 +63,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -78,7 +78,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -94,8 +94,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -110,7 +110,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionInterfaceTypeTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionInterfaceTypeTests.cs index c3a7f81fae5..8b8b0c867d9 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionInterfaceTypeTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionInterfaceTypeTests.cs @@ -58,8 +58,8 @@ public async Task Create_Interface() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -72,7 +72,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -104,8 +104,8 @@ public async Task Create_Interface_Pagination() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -120,7 +120,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -138,8 +138,8 @@ public async Task Create_Interface_Nested() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -154,7 +154,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -172,8 +172,8 @@ public async Task Create_Interface_NestedList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -188,7 +188,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -210,8 +210,8 @@ public async Task Paging_Interface_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -226,7 +226,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -248,8 +248,8 @@ public async Task OffsetPaging_Interface_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -264,7 +264,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -282,8 +282,8 @@ public async Task Create_Interface_Without_Missing() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -292,7 +292,7 @@ ... on Foo { } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionNestedTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionNestedTests.cs index 181e89d14fc..c81a71b48ad 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionNestedTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionNestedTests.cs @@ -27,8 +27,8 @@ public async Task Create_Object() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -37,7 +37,7 @@ public async Task Create_Object() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -53,8 +53,8 @@ public async Task Create_ObjectNotSettable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -63,7 +63,7 @@ public async Task Create_ObjectNotSettable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -79,8 +79,8 @@ public async Task Create_ObjectNotSettableList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -89,7 +89,7 @@ public async Task Create_ObjectNotSettableList() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -105,8 +105,8 @@ public async Task Create_ObjectMethod() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -115,7 +115,7 @@ public async Task Create_ObjectMethod() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -131,8 +131,8 @@ public async Task Create_ObjectMethodList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -141,7 +141,7 @@ public async Task Create_ObjectMethodList() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSetTest.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSetTest.cs index cf7ab06122d..c942773380d 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSetTest.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSetTest.cs @@ -57,8 +57,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -72,7 +72,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -88,8 +88,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -104,7 +104,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortedSetTest.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortedSetTest.cs index d0aad8e4bfb..ac0d61a2827 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortedSetTest.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortedSetTest.cs @@ -63,8 +63,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -78,7 +78,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -94,8 +94,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -110,7 +110,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortingTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortingTests.cs index 56d06d1a5ad..a79abccf39e 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortingTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionSortingTests.cs @@ -131,8 +131,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -151,7 +151,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -167,8 +167,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -188,7 +188,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -204,8 +204,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -224,7 +224,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -240,8 +240,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -261,7 +261,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionUnionTypeTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionUnionTypeTests.cs index 702eef01751..444a6eb8f43 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionUnionTypeTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionUnionTypeTests.cs @@ -58,8 +58,8 @@ public async Task Create_Union() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -71,7 +71,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -102,8 +102,8 @@ public async Task Create_Union_Pagination() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -117,7 +117,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -134,8 +134,8 @@ public async Task Create_Union_Nested() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -149,7 +149,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -166,8 +166,8 @@ public async Task Create_Union_NestedList() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -181,7 +181,7 @@ ... on Bar { } } }") - .Create()); + .Build()); // assert await Snapshot @@ -198,8 +198,8 @@ public async Task Create_Union_Without_Missing() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -208,7 +208,7 @@ ... on Foo { } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorExecutableTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorExecutableTests.cs index e862c5e72b4..929f5138731 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorExecutableTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorExecutableTests.cs @@ -28,9 +28,9 @@ public async Task Create_ProjectsTwoProperties_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable{ bar baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable{ bar baz }}") + .Build()); // assert await Snapshot @@ -46,9 +46,9 @@ public async Task Create_ProjectsOneProperty_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable{ baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable{ baz }}") + .Build()); // assert await Snapshot @@ -70,9 +70,9 @@ public async Task Create_ProjectsOneProperty_WithResolver() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable{ baz foo }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable{ baz foo }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorIsProjectedTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorIsProjectedTests.cs index 447b5522409..8e02d5698ac 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorIsProjectedTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorIsProjectedTests.cs @@ -39,9 +39,9 @@ public async Task IsProjected_Should_NotBeProjectedWhenSelected_When_FalseWithOn // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot @@ -58,9 +58,9 @@ public async Task IsProjected_Should_NotBeProjectedWhenSelected_When_FalseWithTw // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse isProjectedTrue }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse isProjectedTrue }}") + .Build()); // assert await Snapshot @@ -77,9 +77,9 @@ public async Task IsProjected_Should_AlwaysBeProjectedWhenSelected_When_True() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot @@ -96,9 +96,9 @@ public async Task IsProjected_Should_AlwaysBeProjectedWhenSelected_When_TrueAndM // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot @@ -115,9 +115,9 @@ public async Task IsProjected_Should_NotFailWhenSelectionSetSkippedCompletely() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root { isProjectedFalse }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root { isProjectedFalse }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorPagingTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorPagingTests.cs index a1ca37a1022..f657b4b4af5 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorPagingTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorPagingTests.cs @@ -39,9 +39,9 @@ public async Task Create_ProjectsTwoProperties_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { bar baz } }}") + .Build()); // assert await Snapshot @@ -59,9 +59,9 @@ public async Task Create_ProjectsOneProperty_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { baz } }}") + .Build()); // assert await Snapshot @@ -79,9 +79,9 @@ public async Task Create_ProjectsTwoProperties_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { bar baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { bar baz }} }}") + .Build()); // assert await Snapshot @@ -99,9 +99,9 @@ public async Task Create_ProjectsOneProperty_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -119,9 +119,9 @@ public async Task Create_ProjectsTwoProperties_EdgesAndNodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { bar }} }}") + .Build()); // assert await Snapshot @@ -139,9 +139,9 @@ public async Task Create_ProjectsOneProperty_EdgesAndNodesOverlap() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -159,9 +159,9 @@ public async Task CreateNullable_ProjectsTwoProperties_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { bar baz } }}") + .Build()); // assert await Snapshot @@ -179,9 +179,9 @@ public async Task CreateNullable_ProjectsOneProperty_Nodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes { baz } }}") + .Build()); // assert await Snapshot @@ -199,9 +199,9 @@ public async Task CreateNullable_ProjectsTwoProperties_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { bar baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { bar baz }} }}") + .Build()); // assert await Snapshot @@ -219,9 +219,9 @@ public async Task CreateNullable_ProjectsOneProperty_Edges() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -239,9 +239,9 @@ public async Task CreateNullable_ProjectsTwoProperties_EdgesAndNodes() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { bar }} }}") + .Build()); // assert await Snapshot @@ -259,9 +259,9 @@ public async Task CreateNullable_ProjectsOneProperty_EdgesAndNodesOverlap() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ baz } edges { node { baz }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ baz } edges { node { baz }} }}") + .Build()); // assert await Snapshot @@ -279,9 +279,9 @@ public async Task Create_Projection_Should_Stop_When_UseProjectionEncountered() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ bar list { barBaz } } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ bar list { barBaz } } }}") + .Build()); // assert await Snapshot @@ -299,9 +299,9 @@ public async Task Create_Projection_Should_Stop_When_UsePagingEncountered() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ nodes{ bar paging { nodes {barBaz }} } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ nodes{ bar paging { nodes {barBaz }} } }}") + .Build()); // assert await Snapshot @@ -319,9 +319,9 @@ public async Task CreateOffsetPaging_ProjectsTwoProperties_Items_WithArgs() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(take:10, skip:1){ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(take:10, skip:1){ items { bar baz } }}") + .Build()); // assert await Snapshot @@ -339,9 +339,9 @@ public async Task CreateOffsetPaging_ProjectsTwoProperties_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { bar baz } }}") + .Build()); // assert await Snapshot @@ -359,9 +359,9 @@ public async Task CreateOffsetPaging_ProjectsOneProperty_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { baz } }}") + .Build()); // assert await Snapshot @@ -380,9 +380,9 @@ public async Task CreateOffsetPagingNullable_ProjectsTwoProperties_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { bar baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { bar baz } }}") + .Build()); // assert await Snapshot @@ -400,9 +400,9 @@ public async Task CreateOffsetPagingNullable_ProjectsOneProperty_Items() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items { baz } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items { baz } }}") + .Build()); // assert await Snapshot @@ -420,9 +420,9 @@ public async Task CreateOffsetPaging_Projection_Should_Stop_When_UseProjectionEn // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items{ bar list { barBaz } } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items{ bar list { barBaz } } }}") + .Build()); // assert await Snapshot @@ -440,9 +440,9 @@ public async Task CreateOffsetPaging_Projection_Should_Stop_When_UsePagingEncoun // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ items{ bar paging { nodes {barBaz }} } }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ items{ bar paging { nodes {barBaz }} } }}") + .Build()); // assert await Snapshot @@ -460,9 +460,9 @@ public async Task CreateNullable_NodesAndEdgesWithAliases() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ b: nodes{ baz } a: edges { node { bar }} }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ b: nodes{ baz } a: edges { node { bar }} }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorScalarTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorScalarTests.cs index 8bbb54a8da1..35e55f6237d 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorScalarTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableProjectionVisitorScalarTests.cs @@ -27,9 +27,9 @@ public async Task Create_NotSettable_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ notSettable }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ notSettable }}") + .Build()); // assert await Snapshot @@ -45,9 +45,9 @@ public async Task Create_Computed_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ computed }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ computed }}") + .Build()); // assert await Snapshot @@ -63,9 +63,9 @@ public async Task Create_ProjectsTwoProperties_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ bar baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ bar baz }}") + .Build()); // assert await Snapshot @@ -81,9 +81,9 @@ public async Task Create_ProjectsOneProperty_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ baz }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ baz }}") + .Build()); // assert await Snapshot @@ -105,9 +105,9 @@ public async Task Create_ProjectsOneProperty_WithResolver() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root{ baz foo }}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root{ baz foo }}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableSingleOrDefaultTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableSingleOrDefaultTests.cs index 582320a37e9..80da1f984b7 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableSingleOrDefaultTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Projections.Tests/QueryableSingleOrDefaultTests.cs @@ -120,8 +120,8 @@ public async Task Create_DeepFilterObjectTwoProjections() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -135,7 +135,7 @@ public async Task Create_DeepFilterObjectTwoProjections() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -151,8 +151,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { rootExecutable { @@ -166,7 +166,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Executable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -182,8 +182,8 @@ public async Task Create_ListObjectDifferentLevelProjection() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -198,7 +198,7 @@ public async Task Create_ListObjectDifferentLevelProjection() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -214,8 +214,8 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -229,7 +229,7 @@ public async Task Create_DeepFilterObjectTwoProjections_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot @@ -245,8 +245,8 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root { @@ -261,7 +261,7 @@ public async Task Create_ListObjectDifferentLevelProjection_Nullable() } } }") - .Create()); + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorBooleanTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorBooleanTests.cs index 3e0c3d34de0..bf5f896c422 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorBooleanTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorBooleanTests.cs @@ -28,14 +28,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -53,14 +53,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert await Snapshot @@ -79,14 +79,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorComparableTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorComparableTests.cs index 6f610677c56..96737c68395 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorComparableTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorComparableTests.cs @@ -34,14 +34,14 @@ public async Task Create_Short_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await Snapshot @@ -60,14 +60,14 @@ public async Task Create_Short_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: ASC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: ASC}){ barShort}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barShort: DESC}){ barShort}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barShort: DESC}){ barShort}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorEnumTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorEnumTests.cs index 7b8954c89ba..7e66442f108 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorEnumTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorEnumTests.cs @@ -38,14 +38,14 @@ public async Task Create_Enum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await Snapshot @@ -64,14 +64,14 @@ public async Task Create_Enum_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: ASC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: ASC}){ barEnum}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barEnum: DESC}){ barEnum}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barEnum: DESC}){ barEnum}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExecutableTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExecutableTests.cs index e03ea763573..de165c1daf0 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExecutableTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExecutableTests.cs @@ -28,14 +28,14 @@ public async Task Create_Boolean_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -53,14 +53,14 @@ public async Task Create_Boolean_OrderBy_List() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: ASC}]){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: [{ bar: DESC}]){ bar}}") + .Build()); // assert await Snapshot @@ -79,14 +79,14 @@ public async Task Create_Boolean_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ rootExecutable(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ rootExecutable(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExpressionTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExpressionTests.cs index b18fa20c755..71018387785 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExpressionTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorExpressionTests.cs @@ -59,14 +59,14 @@ public async Task Create_CollectionLengthExpression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: ASC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: ASC}){ name lastName}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { barLength: DESC}){ name lastName}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { barLength: DESC}){ name lastName}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorObjectTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorObjectTests.cs index 1a9c572575b..48c2cb6aa85 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorObjectTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorObjectTests.cs @@ -156,18 +156,18 @@ public async Task Create_ObjectShort_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -186,18 +186,18 @@ public async Task Create_ObjectNullableShort_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: ASC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barShort: DESC}}) " + "{ foo{ barShort}}}") - .Create()); + .Build()); // assert await Snapshot @@ -215,18 +215,18 @@ public async Task Create_ObjectEnum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -245,18 +245,18 @@ public async Task Create_ObjectNullableEnum_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: ASC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barEnum: DESC}}) " + "{ foo{ barEnum}}}") - .Create()); + .Build()); // assert await Snapshot @@ -274,18 +274,18 @@ public async Task Create_ObjectString_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -304,18 +304,18 @@ public async Task Create_ObjectNullableString_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: ASC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barString: DESC}}) " + "{ foo{ barString}}}") - .Create()); + .Build()); // assert await Snapshot @@ -333,18 +333,18 @@ public async Task Create_ObjectBool_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -363,18 +363,18 @@ public async Task Create_ObjectNullableBool_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC}}) " + "{ foo{ barBool}}}") - .Create()); + .Build()); // assert await Snapshot @@ -392,15 +392,15 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: ASC, barShort: ASC }}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -413,18 +413,18 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( "{ root(order: { foo: { barBool: DESC, barShort: DESC}}) " + "{ foo{ barBool barShort}}}") - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" { root(order: [ @@ -437,7 +437,7 @@ public async Task Create_ObjectString_OrderBy_TwoProperties() } } ") - .Create()); + .Build()); // assert await Snapshot @@ -457,8 +457,8 @@ public async Task Create_ObjectString_OrderBy_TwoProperties_Variables() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -468,26 +468,28 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", - new Dictionary { - { "barShort", "ASC" }, { "barBool", "ASC" }, - } + "foo", + new Dictionary + { + { "barShort", "ASC" }, { "barBool", "ASC" }, + } + }, }, - }, + } }) - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -497,28 +499,30 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", new Dictionary { { "barShort", "ASC" }, } + { + "foo", new Dictionary { { "barShort", "ASC" }, } + }, }, - }, - new() - { + new() { - "foo", new Dictionary { { "barBool", "ASC" }, } + { + "foo", new Dictionary { { "barBool", "ASC" }, } + }, }, - }, + } }) - .Create()); + .Build()); var res3 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -528,26 +532,28 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", - new Dictionary { - { "barShort", "DESC" }, { "barBool", "DESC" }, - } + "foo", + new Dictionary + { + { "barShort", "DESC" }, { "barBool", "DESC" }, + } + }, }, - }, + } }) - .Create()); + .Build()); var res4 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @" query testSort($order: [BarSortInput!]) { root(order: $order) { @@ -557,24 +563,26 @@ query testSort($order: [BarSortInput!]) { } } }") - .SetVariableValue( - "order", - new List> + .SetVariableValues( + new Dictionary { - new() + ["order"] = new List> { + new() { - "foo", new Dictionary { { "barShort", "DESC" }, } + { + "foo", new Dictionary { { "barShort", "DESC" }, } + }, }, - }, - new() - { + new() { - "foo", new Dictionary { { "barBool", "DESC" }, } + { + "foo", new Dictionary { { "barBool", "DESC" }, } + }, }, - }, + } }) - .Create()); + .Build()); // assert await Snapshot @@ -637,14 +645,10 @@ public class BarNullable } public class BarSortType - : SortInputType - { - } + : SortInputType { } public class BarNullableSortType - : SortInputType - { - } + : SortInputType { } public enum BarEnum { @@ -653,4 +657,4 @@ public enum BarEnum BAZ, QUX, } -} +} \ No newline at end of file diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorStringTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorStringTests.cs index 18390601ab4..888279c3d08 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorStringTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/QueryableSortVisitorStringTests.cs @@ -31,14 +31,14 @@ public async Task Create_String_OrderBy() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot @@ -57,14 +57,14 @@ public async Task Create_String_OrderBy_Nullable() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: ASC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: ASC}){ bar}}") + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery("{ root(order: { bar: DESC}){ bar}}") - .Create()); + OperationRequestBuilder.Create() + .SetDocument("{ root(order: { bar: DESC}){ bar}}") + .Build()); // assert await Snapshot diff --git a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/SortVisitorTestBase.cs b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/SortVisitorTestBase.cs index 89a259a4076..68301becbfd 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/SortVisitorTestBase.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Sorting.Tests/SortVisitorTestBase.cs @@ -81,10 +81,10 @@ protected IRequestExecutor CreateSchema( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs index 16b72f1a0d9..e93eede1e17 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/FilterVisitorTestBase.cs @@ -85,10 +85,10 @@ protected async Task CreateSchemaAsync( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorContainsTests.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorContainsTests.cs index 835a62d44b8..c847f30541b 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorContainsTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorContainsTests.cs @@ -48,8 +48,8 @@ public async Task Create_Contains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -64,11 +64,11 @@ public async Task Create_Contains_Expression() id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -82,7 +82,7 @@ public async Task Create_Contains_Expression() id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( @@ -100,8 +100,8 @@ public async Task Create_NotContains_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -116,11 +116,11 @@ public async Task Create_NotContains_Expression() id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -135,7 +135,7 @@ public async Task Create_NotContains_Expression() id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorDistanceTests.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorDistanceTests.cs index 7c4ec999c9e..716b93d60bb 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorDistanceTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorDistanceTests.cs @@ -50,8 +50,8 @@ public async Task Create_Distance_Expression() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -67,11 +67,11 @@ public async Task Create_Distance_Expression() id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -87,7 +87,7 @@ public async Task Create_Distance_Expression() id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorIntersectTests.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorIntersectTests.cs index e96067a7128..d9e0533a99d 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorIntersectTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorIntersectTests.cs @@ -49,8 +49,8 @@ public async Task Create_Intersects_Query() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -73,11 +73,11 @@ [10 10] id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -100,7 +100,7 @@ [10 10] id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorOverlapsTests.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorOverlapsTests.cs index 3a3fe40a385..eb0bfd45262 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorOverlapsTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorOverlapsTests.cs @@ -50,8 +50,8 @@ public async Task Create_Overlaps_Query() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -76,11 +76,11 @@ [150 150] id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -105,7 +105,7 @@ [150 150] id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorTouchesTests.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorTouchesTests.cs index 94880ae4aed..271afe30bc5 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorTouchesTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorTouchesTests.cs @@ -49,8 +49,8 @@ public async Task Create_Touches_Query() // act // assert var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -73,11 +73,11 @@ [240 80] id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -100,7 +100,7 @@ [240 80] id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorWithinTests.cs b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorWithinTests.cs index 701fbca0f13..e0fb733c58b 100644 --- a/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorWithinTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorWithinTests.cs @@ -48,8 +48,8 @@ public async Task Create_Within_Query() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -72,11 +72,11 @@ [20 20] id } }") - .Create()); + .Build()); var res2 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root(where: { bar: { @@ -99,7 +99,7 @@ [20 20] id } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/FilterVisitorTestBase.cs index fa425a7879f..5a2aaf067cb 100644 --- a/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/FilterVisitorTestBase.cs @@ -80,10 +80,10 @@ protected async Task CreateSchemaAsync( if (context.ContextData.TryGetValue("sql", out var queryString)) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(context.Result!.ExpectQueryResult()) .SetContextData("sql", queryString) - .Create(); + .Build(); } }) .UseDefaultPipeline() diff --git a/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/QueryableFilterVisitorTests.cs b/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/QueryableFilterVisitorTests.cs index defbb88a308..dcaec723b14 100644 --- a/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/QueryableFilterVisitorTests.cs +++ b/src/HotChocolate/Spatial/test/Data.Projections.SqlServer.Tests/QueryableFilterVisitorTests.cs @@ -49,15 +49,15 @@ public async Task Create_Expression() // act var res1 = await tester.ExecuteAsync( - QueryRequestBuilder.New() - .SetQuery( + OperationRequestBuilder.Create() + .SetDocument( @"{ root { id bar { coordinates } } }") - .Create()); + .Build()); // assert await SnapshotExtensions.AddResult( diff --git a/src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/__snapshots__/IntrospectionClientTests.IntrospectServer.snap b/src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/__snapshots__/IntrospectionClientTests.IntrospectServer.snap index 124a5f9c64f..830ad6c967e 100644 --- a/src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/__snapshots__/IntrospectionClientTests.IntrospectServer.snap +++ b/src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/__snapshots__/IntrospectionClientTests.IntrospectServer.snap @@ -122,5 +122,3 @@ type FriendsEdge { "The `Long` scalar type represents non-fractional signed whole 64-bit numeric values. Long can represent values between -(2^63) and 2^63 - 1." scalar Long - -directive @export(as: String) on FIELD diff --git a/src/StrawberryShake/Client/src/Core/Serialization/BuiltInScalarNames.cs b/src/StrawberryShake/Client/src/Core/Serialization/BuiltInScalarNames.cs index 1bb8fb12c47..d7ec2380d16 100644 --- a/src/StrawberryShake/Client/src/Core/Serialization/BuiltInScalarNames.cs +++ b/src/StrawberryShake/Client/src/Core/Serialization/BuiltInScalarNames.cs @@ -22,6 +22,5 @@ public static class BuiltInScalarNames public const string DateTime = nameof(DateTime); public const string Date = nameof(Date); public const string TimeSpan = nameof(TimeSpan); - public const string MultiplierPath = nameof(MultiplierPath); public const string Name = nameof(Name); } diff --git a/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/IInMemoryRequestInterceptor.cs b/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/IInMemoryRequestInterceptor.cs index 4abc585ac6b..6af2c6f0e29 100644 --- a/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/IInMemoryRequestInterceptor.cs +++ b/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/IInMemoryRequestInterceptor.cs @@ -34,6 +34,6 @@ public interface IInMemoryRequestInterceptor ValueTask OnCreateAsync( IServiceProvider serviceProvider, OperationRequest request, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken); } diff --git a/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/InMemoryClient.cs b/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/InMemoryClient.cs index e8e63c34d7b..52151f71ef4 100644 --- a/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/InMemoryClient.cs +++ b/src/StrawberryShake/Client/src/Transport.InMemory/DependencyInjection/InMemoryClient.cs @@ -61,21 +61,21 @@ public async ValueTask ExecuteAsync( throw ThrowHelper.InMemoryClient_NoExecutorConfigured(_name); } - var requestBuilder = new QueryRequestBuilder(); + var requestBuilder = new OperationRequestBuilder(); if (request.Document.Body.Length > 0) { - requestBuilder.SetQuery(Utf8GraphQLParser.Parse(request.Document.Body)); + requestBuilder.SetDocument(Utf8GraphQLParser.Parse(request.Document.Body)); } else { - requestBuilder.SetQueryId(request.Id); + requestBuilder.SetDocumentId(request.Id); } - requestBuilder.SetOperation(request.Name); + requestBuilder.SetOperationName(request.Name); requestBuilder.SetVariableValues(CreateVariables(request)); requestBuilder.SetExtensions(request.GetExtensionsOrNull()); - requestBuilder.InitializeGlobalState(request.GetContextDataOrNull()); + requestBuilder.SetGlobalState(request.GetContextDataOrNull()); var applicationService = Executor.Services.GetApplicationServices(); foreach (var interceptor in RequestInterceptors) @@ -86,7 +86,7 @@ await interceptor } return await Executor - .ExecuteAsync(requestBuilder.Create(), cancellationToken) + .ExecuteAsync(requestBuilder.Build(), cancellationToken) .ConfigureAwait(false); } diff --git a/src/StrawberryShake/Client/src/Transport.InMemory/InMemoryConnection.cs b/src/StrawberryShake/Client/src/Transport.InMemory/InMemoryConnection.cs index bfd94a0ffb5..16cb664f3a2 100644 --- a/src/StrawberryShake/Client/src/Transport.InMemory/InMemoryConnection.cs +++ b/src/StrawberryShake/Client/src/Transport.InMemory/InMemoryConnection.cs @@ -82,7 +82,7 @@ private async IAsyncEnumerable> ProcessResultAsync( switch (executionResult) { - case IQueryResult queryResult: + case HotChocolate.Execution.IOperationResult queryResult: { queryResult.WriteTo(writer); yield return new Response(Parse(writer.GetWrittenMemory()), null); diff --git a/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientBuilderExtensionsTests.cs b/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientBuilderExtensionsTests.cs index c7f4db593eb..1bd4e38a97e 100644 --- a/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientBuilderExtensionsTests.cs +++ b/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientBuilderExtensionsTests.cs @@ -405,7 +405,7 @@ public class StubInterceptor : IInMemoryRequestInterceptor public ValueTask OnCreateAsync( IServiceProvider serviceProvider, OperationRequest request, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { return default; diff --git a/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientTests.cs b/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientTests.cs index 1e595228517..c904e0fe5f3 100644 --- a/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientTests.cs +++ b/src/StrawberryShake/Client/test/Transport.InMemory.Tests/InMemoryClientTests.cs @@ -83,9 +83,10 @@ public async Task ExecuteAsync_Default_ExecuteQuery() await client.ExecuteAsync(operationRequest); // assert - Assert.Equal(operationRequest.Name, executor.Request!.OperationName); - Assert.Equal(variables, executor.Request!.VariableValues); - Assert.Equal("{ foo }", Encoding.UTF8.GetString(executor.Request.Query!.AsSpan())); + var request = Assert.IsType(executor.Request); + Assert.Equal(operationRequest.Name, request.OperationName); + Assert.Equal(variables, request.VariableValues); + Assert.Equal("{ foo }", Encoding.UTF8.GetString(request.Document!.AsSpan())); } [Fact] @@ -105,7 +106,7 @@ public async Task ExecuteAsync_Default_CallInterceptor() .OnCreateAsync( StubExecutor.ApplicationServiceProvider, operationRequest, - It.IsAny(), + It.IsAny(), It.IsAny())); // act @@ -117,19 +118,19 @@ public async Task ExecuteAsync_Default_CallInterceptor() .OnCreateAsync( StubExecutor.ApplicationServiceProvider, operationRequest, - It.IsAny(), + It.IsAny(), It.IsAny()), Times.Exactly(2)); } private sealed class StubExecutor : IRequestExecutor { - public IQueryRequest? Request { get; private set; } + public IOperationRequest? Request { get; private set; } public ulong Version { get; } public Task ExecuteAsync( - IQueryRequest request, + IOperationRequest request, CancellationToken cancellationToken = default) { Request = request; @@ -137,7 +138,7 @@ public Task ExecuteAsync( } public Task ExecuteBatchAsync( - IReadOnlyList requestBatch, + OperationRequestBatch requestBatch, CancellationToken cancellationToken = default) => throw new NotImplementedException(); diff --git a/src/StrawberryShake/Client/test/Transport.InMemory.Tests/IntegrationTests.cs b/src/StrawberryShake/Client/test/Transport.InMemory.Tests/IntegrationTests.cs index f16d8dde734..185e3da8a4c 100644 --- a/src/StrawberryShake/Client/test/Transport.InMemory.Tests/IntegrationTests.cs +++ b/src/StrawberryShake/Client/test/Transport.InMemory.Tests/IntegrationTests.cs @@ -34,7 +34,6 @@ public async Task Simple_Request() serviceCollection .AddGraphQLServer() .AddStarWarsTypes() - .AddExportDirectiveType() .AddStarWarsRepositories() .AddInMemorySubscriptions(); @@ -52,8 +51,7 @@ public async Task Simple_Request() .GetRequiredService(); // act - var connection = - new InMemoryConnection(async abort => await factory.CreateAsync("Foo", abort)); + var connection = new InMemoryConnection(async abort => await factory.CreateAsync("Foo", abort)); await foreach (var response in connection.ExecuteAsync(request).WithCancellation(ct)) @@ -78,7 +76,6 @@ public async Task Configure_SchemaName() serviceCollection .AddGraphQLServer("Foo") .AddStarWarsTypes() - .AddExportDirectiveType() .AddStarWarsRepositories() .AddInMemorySubscriptions(); @@ -125,7 +122,6 @@ public async Task Interceptor_Set_ContextData() serviceCollection .AddGraphQLServer() .AddStarWarsTypes() - .AddExportDirectiveType() .AddStarWarsRepositories() .AddInMemorySubscriptions() .UseField(next => context => @@ -178,7 +174,6 @@ public async Task Subscription_Result() .AddGraphQLServer() .AddStarWarsTypes() .AddTypeExtension() - .AddExportDirectiveType() .AddStarWarsRepositories() .AddInMemorySubscriptions(); @@ -234,7 +229,7 @@ public class StubInterceptor : IInMemoryRequestInterceptor public ValueTask OnCreateAsync( IServiceProvider serviceProvider, OperationRequest request, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { requestBuilder.AddGlobalState("Foo", "bar"); diff --git a/src/StrawberryShake/Client/test/Transport.WebSocket.Tests/TestHelper/TestServerHelper.cs b/src/StrawberryShake/Client/test/Transport.WebSocket.Tests/TestHelper/TestServerHelper.cs index 4b431dc8e04..e9cd4dbf6ff 100644 --- a/src/StrawberryShake/Client/test/Transport.WebSocket.Tests/TestHelper/TestServerHelper.cs +++ b/src/StrawberryShake/Client/test/Transport.WebSocket.Tests/TestHelper/TestServerHelper.cs @@ -36,7 +36,6 @@ public static IWebHost CreateServer(Action configure, o builder .AddStarWarsTypes() - .AddExportDirectiveType() .AddStarWarsRepositories() .AddInMemorySubscriptions() .ModifyOptions( @@ -53,25 +52,25 @@ public static IWebHost CreateServer(Action configure, o nameof(HttpContext), out var value) && value is HttpContext httpContext && - context.Result is IQueryResult result) + context.Result is HotChocolate.Execution.IOperationResult result) { var headers = httpContext.Request.Headers; if (headers.ContainsKey("sendErrorStatusCode")) { context.Result = result = - QueryResultBuilder + OperationResultBuilder .FromResult(result) .SetContextData(HttpStatusCode, 403) - .Create(); + .Build(); } if (headers.ContainsKey("sendError")) { context.Result = - QueryResultBuilder + OperationResultBuilder .FromResult(result) .AddError(new Error("Some error!")) - .Create(); + .Build(); } } diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs index a6058dcfbc7..b34f61a3e14 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using HotChocolate; +using HotChocolate.Execution; using HotChocolate.Language; using HotChocolate.Validation; using Microsoft.CodeAnalysis; @@ -450,7 +451,7 @@ private static async ValueTask TryValidateRequestAsync( var validationResult = await validator.ValidateAsync( schema, document, - "dummy", + new OperationDocumentId("dummy"), new Dictionary(), false); diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/BuiltInScalarNames.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/BuiltInScalarNames.cs index 4dfee009a3a..2229b3449c9 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/BuiltInScalarNames.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/BuiltInScalarNames.cs @@ -25,7 +25,6 @@ public static class BuiltInScalarNames "Guid", ScalarNames.DateTime, ScalarNames.Date, - ScalarNames.MultiplierPath, ScalarNames.Name, ScalarNames.ByteArray, ScalarNames.Any, diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs index da94da7c4c6..df756446374 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using HotChocolate; +using HotChocolate.Execution; using HotChocolate.Language; using HotChocolate.Validation; using Microsoft.Extensions.DependencyInjection; @@ -51,7 +52,7 @@ public static async ValueTask CreateOperationDocumentsAsync( var result = await validator.ValidateAsync( schema, mergedDocument, - "dummy", + new OperationDocumentId("dummy"), new Dictionary(), false); diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap index 95806c93276..f4759207d86 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap @@ -2365,25 +2365,6 @@ "OnOperation": false, "OnFragment": true, "OnField": true - }, - { - "Name": "export", - "Description": null, - "Args": [ - { - "Name": "as", - "Description": null, - "Type": { - "Kind": "Scalar", - "Name": "String", - "OfType": null - }, - "DefaultValue": null - } - ], - "OnOperation": false, - "OnFragment": false, - "OnField": true } ] } @@ -6513,34 +6494,6 @@ "OnOperation": false, "OnFragment": true, "OnField": true - }, - { - "__typename": "__Directive", - "Name": "export", - "Description": null, - "Args": [ - { - "__typename": "__InputValue", - "Name": "as", - "Description": null, - "Type": { - "__typename": "__Type", - "Name": "String", - "Kind": "Scalar", - "Description": null, - "Fields": null, - "InputFields": null, - "Interfaces": null, - "EnumValues": null, - "PossibleTypes": null, - "OfType": null - }, - "DefaultValue": null - } - ], - "OnOperation": false, - "OnFragment": false, - "OnField": true } ] }, diff --git a/website/src/blog/2019-04-11-integration-tests.md b/website/src/blog/2019-04-11-integration-tests.md index f306b0eee93..f70cc707c3e 100644 --- a/website/src/blog/2019-04-11-integration-tests.md +++ b/website/src/blog/2019-04-11-integration-tests.md @@ -96,7 +96,7 @@ public async Task SayHello_HelloIsReturned() .MakeExecutable(); IReadOnlyQueryRequest request = - QueryRequestBuilder.New() + OperationRequestBuilder.New() .SetQuery("{ sayHello }") .SetServices(serviceProvider) .AddProperty("Key", "value") @@ -139,7 +139,7 @@ public async Task SayHello_HelloIsReturned() .MakeExecutable(); IReadOnlyQueryRequest request = - QueryRequestBuilder.New() + OperationRequestBuilder.New() .SetQuery("{ sayHello }") .SetServices(serviceProvider) .AddProperty("Key", "value") diff --git a/website/src/blog/2021-07-20-rider-language-injection/2021-07-20-rider-language-injection.md b/website/src/blog/2021-07-20-rider-language-injection/2021-07-20-rider-language-injection.md index 3a0cc13b0fa..b2da629f95e 100644 --- a/website/src/blog/2021-07-20-rider-language-injection/2021-07-20-rider-language-injection.md +++ b/website/src/blog/2021-07-20-rider-language-injection/2021-07-20-rider-language-injection.md @@ -134,7 +134,7 @@ public class PersonsIntegrationTests }"; IReadOnlyQueryRequest request = - QueryRequestBuilder.New().SetQuery(query).Create(); + OperationRequestBuilder.New().SetQuery(query).Create(); // act IExecutionResult result = await executor.ExecuteAsync(request); diff --git a/website/src/docs/hotchocolate/v10/execution-engine/custom-context-data.md b/website/src/docs/hotchocolate/v10/execution-engine/custom-context-data.md index b582d1b3885..c18f5084ec1 100644 --- a/website/src/docs/hotchocolate/v10/execution-engine/custom-context-data.md +++ b/website/src/docs/hotchocolate/v10/execution-engine/custom-context-data.md @@ -10,7 +10,7 @@ The global context data is a thread-safe dictionary that is available though the One common use case is to aggregate some state when the GraphQL request is created and use it in field middleware or in the resolver. -In order to intercept the request creation we can add an `IQueryRequestInterceptor` to our services and there build up our custom state. +In order to intercept the request creation we can add an `IOperationRequestInterceptor` to our services and there build up our custom state. ```csharp services.AddQueryRequestInterceptor((ctx, builder, ct) => diff --git a/website/src/docs/hotchocolate/v11/api-reference/aspnetcore.md b/website/src/docs/hotchocolate/v11/api-reference/aspnetcore.md index 6f0c2e5c82b..7f8adc6aa04 100644 --- a/website/src/docs/hotchocolate/v11/api-reference/aspnetcore.md +++ b/website/src/docs/hotchocolate/v11/api-reference/aspnetcore.md @@ -443,7 +443,7 @@ public class DefaultHttpRequestInterceptor : IHttpRequestInterceptor public virtual ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { requestBuilder.TrySetServices(context.RequestServices); @@ -513,7 +513,7 @@ public class DefaultSocketSessionInterceptor : ISocketSessionInterceptor public virtual ValueTask OnRequestAsync( ISocketConnection connection, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { HttpContext context = connection.HttpContext; diff --git a/website/src/docs/hotchocolate/v11/api-reference/custom-context-data.md b/website/src/docs/hotchocolate/v11/api-reference/custom-context-data.md index b582d1b3885..c18f5084ec1 100644 --- a/website/src/docs/hotchocolate/v11/api-reference/custom-context-data.md +++ b/website/src/docs/hotchocolate/v11/api-reference/custom-context-data.md @@ -10,7 +10,7 @@ The global context data is a thread-safe dictionary that is available though the One common use case is to aggregate some state when the GraphQL request is created and use it in field middleware or in the resolver. -In order to intercept the request creation we can add an `IQueryRequestInterceptor` to our services and there build up our custom state. +In order to intercept the request creation we can add an `IOperationRequestInterceptor` to our services and there build up our custom state. ```csharp services.AddQueryRequestInterceptor((ctx, builder, ct) => diff --git a/website/src/docs/hotchocolate/v11/api-reference/dependency-injection.md b/website/src/docs/hotchocolate/v11/api-reference/dependency-injection.md index fe04c2fdbc4..07ef0406133 100644 --- a/website/src/docs/hotchocolate/v11/api-reference/dependency-injection.md +++ b/website/src/docs/hotchocolate/v11/api-reference/dependency-injection.md @@ -120,7 +120,7 @@ public class CustomHttpRequestInterceptor : DefaultHttpRequestInterceptor public async override ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { await base.OnCreateAsync(context, requestExecutor, requestBuilder, cancellationToken); @@ -144,7 +144,7 @@ public class CustomSocketSessionInterceptor : DefaultSocketSessionInterceptor { public async override ValueTask OnRequestAsync( ISocketConnection connection, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { await OnRequestAsync(connection, requestBuilder, cancellationToken); diff --git a/website/src/docs/hotchocolate/v11/api-reference/migrate-from-10-to-11.md b/website/src/docs/hotchocolate/v11/api-reference/migrate-from-10-to-11.md index 195e363a935..3ef925eef75 100644 --- a/website/src/docs/hotchocolate/v11/api-reference/migrate-from-10-to-11.md +++ b/website/src/docs/hotchocolate/v11/api-reference/migrate-from-10-to-11.md @@ -56,7 +56,7 @@ services ... ``` -If you were using the `QueryRequestBuilder` to configure request options or change the request pipeline, you need to add those things to the configuration chain of the ```IRequestExecutorBuilder`. +If you were using the `OperationRequestBuilder` to configure request options or change the request pipeline, you need to add those things to the configuration chain of the ```IRequestExecutorBuilder`. ```csharp services @@ -99,7 +99,7 @@ public interface IHttpRequestInterceptor ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken); } ``` diff --git a/website/src/docs/hotchocolate/v11/distributed-schema/schema-configuration.md b/website/src/docs/hotchocolate/v11/distributed-schema/schema-configuration.md index 331ed9f3dae..42cad53df2b 100644 --- a/website/src/docs/hotchocolate/v11/distributed-schema/schema-configuration.md +++ b/website/src/docs/hotchocolate/v11/distributed-schema/schema-configuration.md @@ -363,7 +363,7 @@ public class RequestInterceptor : DefaultHttpRequestInterceptor public ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { string userId = context.GetLoggedInUserId(); diff --git a/website/src/docs/hotchocolate/v11/security/authorization.md b/website/src/docs/hotchocolate/v11/security/authorization.md index 677486322bd..dfa58ecde19 100644 --- a/website/src/docs/hotchocolate/v11/security/authorization.md +++ b/website/src/docs/hotchocolate/v11/security/authorization.md @@ -345,7 +345,7 @@ Hot Chocolate provides the ability to register an `IHttpRequestInterceptor`, all public class HttpRequestInterceptor : DefaultHttpRequestInterceptor { public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { var identity = new ClaimsIdentity(); diff --git a/website/src/docs/hotchocolate/v12/api-reference/custom-context-data.md b/website/src/docs/hotchocolate/v12/api-reference/custom-context-data.md index b582d1b3885..c18f5084ec1 100644 --- a/website/src/docs/hotchocolate/v12/api-reference/custom-context-data.md +++ b/website/src/docs/hotchocolate/v12/api-reference/custom-context-data.md @@ -10,7 +10,7 @@ The global context data is a thread-safe dictionary that is available though the One common use case is to aggregate some state when the GraphQL request is created and use it in field middleware or in the resolver. -In order to intercept the request creation we can add an `IQueryRequestInterceptor` to our services and there build up our custom state. +In order to intercept the request creation we can add an `IOperationRequestInterceptor` to our services and there build up our custom state. ```csharp services.AddQueryRequestInterceptor((ctx, builder, ct) => diff --git a/website/src/docs/hotchocolate/v12/api-reference/migrate-from-10-to-11.md b/website/src/docs/hotchocolate/v12/api-reference/migrate-from-10-to-11.md index a84b9eb4077..e4b7286b842 100644 --- a/website/src/docs/hotchocolate/v12/api-reference/migrate-from-10-to-11.md +++ b/website/src/docs/hotchocolate/v12/api-reference/migrate-from-10-to-11.md @@ -56,7 +56,7 @@ services ... ``` -If you were using the `QueryRequestBuilder` to configure request options or change the request pipeline, you need to add those things to the configuration chain of the ```IRequestExecutorBuilder`. +If you were using the `OperationRequestBuilder` to configure request options or change the request pipeline, you need to add those things to the configuration chain of the ```IRequestExecutorBuilder`. ```csharp services @@ -99,7 +99,7 @@ public interface IHttpRequestInterceptor ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken); } ``` diff --git a/website/src/docs/hotchocolate/v12/distributed-schema/schema-configuration.md b/website/src/docs/hotchocolate/v12/distributed-schema/schema-configuration.md index 331ed9f3dae..42cad53df2b 100644 --- a/website/src/docs/hotchocolate/v12/distributed-schema/schema-configuration.md +++ b/website/src/docs/hotchocolate/v12/distributed-schema/schema-configuration.md @@ -363,7 +363,7 @@ public class RequestInterceptor : DefaultHttpRequestInterceptor public ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { string userId = context.GetLoggedInUserId(); diff --git a/website/src/docs/hotchocolate/v12/security/authorization.md b/website/src/docs/hotchocolate/v12/security/authorization.md index 700be9ba944..2b34ec3ddc7 100644 --- a/website/src/docs/hotchocolate/v12/security/authorization.md +++ b/website/src/docs/hotchocolate/v12/security/authorization.md @@ -376,7 +376,7 @@ Hot Chocolate provides the ability to register an `IHttpRequestInterceptor`, all public class HttpRequestInterceptor : DefaultHttpRequestInterceptor { public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { var identity = new ClaimsIdentity(); diff --git a/website/src/docs/hotchocolate/v12/server/dependency-injection.md b/website/src/docs/hotchocolate/v12/server/dependency-injection.md index 11b30e3a5ce..7bdaf99c0b8 100644 --- a/website/src/docs/hotchocolate/v12/server/dependency-injection.md +++ b/website/src/docs/hotchocolate/v12/server/dependency-injection.md @@ -229,13 +229,13 @@ While Hot Chocolate's internals rely heavily on Microsoft's dependency injection You can switch out the service provider used for GraphQL requests, as long as your dependency injection container implements the [`IServiceProvider`](https://docs.microsoft.com/dotnet/api/system.iserviceprovider) interface. -To switch out the service provider you need to call [`SetServices`](/docs/hotchocolate/v12/server/interceptors#setservices) on the [`IQueryRequestBuilder`](/docs/hotchocolate/v12/server/interceptors#iqueryrequestbuilder) in both the [`IHttpRequestInterceptor`](/docs/hotchocolate/v12/server/interceptors#ihttprequestinterceptor) and the [`ISocketSessionInterceptor`](/docs/hotchocolate/v12/server/interceptors#isocketsessioninterceptor). +To switch out the service provider you need to call [`SetServices`](/docs/hotchocolate/v12/server/interceptors#setservices) on the [`OperationRequestBuilder`](/docs/hotchocolate/v12/server/interceptors#OperationRequestBuilder) in both the [`IHttpRequestInterceptor`](/docs/hotchocolate/v12/server/interceptors#ihttprequestinterceptor) and the [`ISocketSessionInterceptor`](/docs/hotchocolate/v12/server/interceptors#isocketsessioninterceptor). ```csharp public class HttpRequestInterceptor : DefaultHttpRequestInterceptor { public override async ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { // keeping this line is important! @@ -249,7 +249,7 @@ public class HttpRequestInterceptor : DefaultHttpRequestInterceptor public class SocketSessionInterceptor : DefaultSocketSessionInterceptor { public override async ValueTask OnRequestAsync(ISocketConnection connection, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { // keeping this line is important! diff --git a/website/src/docs/hotchocolate/v12/server/global-state.md b/website/src/docs/hotchocolate/v12/server/global-state.md index b4bbe71e2d0..1914799c7fd 100644 --- a/website/src/docs/hotchocolate/v12/server/global-state.md +++ b/website/src/docs/hotchocolate/v12/server/global-state.md @@ -6,7 +6,7 @@ Global State allows us to define properties on a per-request basis to be made av # Initializing Global State -We can add Global State using the `SetProperty` method on the `IQueryRequestBuilder`. This method takes a `key` and a `value` as an argument. While the `key` needs to be a `string` the value can be of any type. +We can add Global State using the `SetProperty` method on the `OperationRequestBuilder`. This method takes a `key` and a `value` as an argument. While the `key` needs to be a `string` the value can be of any type. Using an interceptor allows us to initialize the Global State before the request is being executed. @@ -14,7 +14,7 @@ Using an interceptor allows us to initialize the Global State before the request public class HttpRequestInterceptor : DefaultHttpRequestInterceptor { public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { string userId = diff --git a/website/src/docs/hotchocolate/v12/server/interceptors.md b/website/src/docs/hotchocolate/v12/server/interceptors.md index bb7288f0856..8d2c05b72fc 100644 --- a/website/src/docs/hotchocolate/v12/server/interceptors.md +++ b/website/src/docs/hotchocolate/v12/server/interceptors.md @@ -14,7 +14,7 @@ We can create a new class inheriting from `DefaultHttpRequestInterceptor` to pro public class HttpRequestInterceptor : DefaultHttpRequestInterceptor { public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { return base.OnCreateAsync(context, requestExecutor, requestBuilder, @@ -39,7 +39,7 @@ This method is invoked for **every** GraphQL request sent via HTTP. It is a grea ```csharp public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { return base.OnCreateAsync(context, requestExecutor, requestBuilder, @@ -49,9 +49,9 @@ public override ValueTask OnCreateAsync(HttpContext context, > Warning: `base.OnCreateAsync` should always be invoked, since the default implementation takes care of adding the dependency injection services as well as some important global state variables, such as the `ClaimsPrinicpal`. Not doing this can lead to unexpected issues. -Most of the configuration will be done through the `IQueryRequestBuilder`, injected as argument to this method. +Most of the configuration will be done through the `OperationRequestBuilder`, injected as argument to this method. -[Learn more about the IQueryRequestBuilder](#iqueryrequestbuilder) +[Learn more about the OperationRequestBuilder](#OperationRequestBuilder) If we want to fail the request, before it is being executed, we can throw a `GraphQLException`. The middleware will then translate this exception to a proper GraphQL error response for the client. @@ -72,7 +72,7 @@ public class SocketSessionInterceptor : DefaultSocketSessionInterceptor } public override ValueTask OnRequestAsync(ISocketConnection connection, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { return base.OnRequestAsync(connection, requestBuilder, @@ -139,7 +139,7 @@ This method is invoked for **every** GraphQL request a client sends using the al ```csharp public override ValueTask OnRequestAsync(ISocketConnection connection, - IQueryRequestBuilder requestBuilder, CancellationToken cancellationToken) + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { return base.OnRequestAsync(connection, requestBuilder, cancellationToken); } @@ -147,9 +147,9 @@ public override ValueTask OnRequestAsync(ISocketConnection connection, > Warning: `base.OnRequestAsync` should always be invoked, since the default implementation takes care of adding the dependency injection services as well as some important global state variables, such as the `ClaimsPrinicpal`. Not doing this can lead to unexpected issues. -Most of the configuration will be done through the `IQueryRequestBuilder`, injected as argument to this method. +Most of the configuration will be done through the `OperationRequestBuilder`, injected as argument to this method. -[Learn more about the IQueryRequestBuilder](#iqueryrequestbuilder) +[Learn more about the OperationRequestBuilder](#OperationRequestBuilder) If we want to fail the request, before it is being executed, we can throw a `GraphQLException`. The middleware will then translate this exception to a proper GraphQL error response for the client. @@ -157,15 +157,15 @@ If we want to fail the request, before it is being executed, we can throw a `Gra This method is invoked, once a client closes the WebSocket connection or the connection is terminated in any other way. -# IQueryRequestBuilder +# OperationRequestBuilder -The `IQueryRequestBuilder` allows us to influence the execution of a GraphQL request. +The `OperationRequestBuilder` allows us to influence the execution of a GraphQL request. It has many capabilities, but most of them are only used internally. In the following we are going to cover the methods that are most relevant to us as consumers. ## Properties -We can set `Properties`, also called Global State, on the `IQueryRequestBuilder`, which can then be referenced in middleware, field resolvers, etc. +We can set `Properties`, also called Global State, on the `OperationRequestBuilder`, which can then be referenced in middleware, field resolvers, etc. [Learn more about Global State](/docs/hotchocolate/v12/server/global-state) diff --git a/website/src/docs/hotchocolate/v12/server/introspection.md b/website/src/docs/hotchocolate/v12/server/introspection.md index 1c2593695d6..d2654b4735a 100644 --- a/website/src/docs/hotchocolate/v12/server/introspection.md +++ b/website/src/docs/hotchocolate/v12/server/introspection.md @@ -97,7 +97,7 @@ We can allow introspection on a per-request basis, while keeping it disabled for public class IntrospectionInterceptor : DefaultHttpRequestInterceptor { public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { if (context.Request.Headers.ContainsKey("X-Allow-Introspection")) @@ -155,7 +155,7 @@ If we need to customize the error message, we can do so in our request intercept public class IntrospectionInterceptor : DefaultHttpRequestInterceptor { public override ValueTask OnCreateAsync(HttpContext context, - IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder, + IRequestExecutor requestExecutor, OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { if (context.Request.Headers.ContainsKey("X-Allow-Introspection")) diff --git a/website/src/docs/hotchocolate/v13/api-reference/custom-context-data.md b/website/src/docs/hotchocolate/v13/api-reference/custom-context-data.md index b582d1b3885..c18f5084ec1 100644 --- a/website/src/docs/hotchocolate/v13/api-reference/custom-context-data.md +++ b/website/src/docs/hotchocolate/v13/api-reference/custom-context-data.md @@ -10,7 +10,7 @@ The global context data is a thread-safe dictionary that is available though the One common use case is to aggregate some state when the GraphQL request is created and use it in field middleware or in the resolver. -In order to intercept the request creation we can add an `IQueryRequestInterceptor` to our services and there build up our custom state. +In order to intercept the request creation we can add an `IOperationRequestInterceptor` to our services and there build up our custom state. ```csharp services.AddQueryRequestInterceptor((ctx, builder, ct) => diff --git a/website/src/docs/hotchocolate/v13/distributed-schema/schema-configuration.md b/website/src/docs/hotchocolate/v13/distributed-schema/schema-configuration.md index 40c382707b5..5da6418d0eb 100644 --- a/website/src/docs/hotchocolate/v13/distributed-schema/schema-configuration.md +++ b/website/src/docs/hotchocolate/v13/distributed-schema/schema-configuration.md @@ -363,7 +363,7 @@ public class RequestInterceptor : DefaultHttpRequestInterceptor public ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken) { string userId = context.GetLoggedInUserId(); diff --git a/website/src/docs/hotchocolate/v13/migrating/migrate-from-10-to-11.md b/website/src/docs/hotchocolate/v13/migrating/migrate-from-10-to-11.md index ee614acd5a4..e79bd414a17 100644 --- a/website/src/docs/hotchocolate/v13/migrating/migrate-from-10-to-11.md +++ b/website/src/docs/hotchocolate/v13/migrating/migrate-from-10-to-11.md @@ -56,7 +56,7 @@ services ... ``` -If you were using the `QueryRequestBuilder` to configure request options or change the request pipeline, you need to add those things to the configuration chain of the ```IRequestExecutorBuilder`. +If you were using the `OperationRequestBuilder` to configure request options or change the request pipeline, you need to add those things to the configuration chain of the ```IRequestExecutorBuilder`. ```csharp services @@ -99,7 +99,7 @@ public interface IHttpRequestInterceptor ValueTask OnCreateAsync( HttpContext context, IRequestExecutor requestExecutor, - IQueryRequestBuilder requestBuilder, + OperationRequestBuilder requestBuilder, CancellationToken cancellationToken); } ``` diff --git a/website/src/docs/hotchocolate/v13/migrating/migrate-from-12-to-13.md b/website/src/docs/hotchocolate/v13/migrating/migrate-from-12-to-13.md index f308b5046a2..3ffbab9fe47 100644 --- a/website/src/docs/hotchocolate/v13/migrating/migrate-from-12-to-13.md +++ b/website/src/docs/hotchocolate/v13/migrating/migrate-from-12-to-13.md @@ -501,13 +501,13 @@ We aligned the naming of state related APIs: - `IResolverContext.SetLocalValue` --> `IResolverContext.SetLocalState` - `IResolverContext.RemoveLocalValue` --> `IResolverContext.RemoveLocalState` -### IQueryRequestBuilder +### OperationRequestBuilder -- `IQueryRequestBuilder.SetProperties` --> `IQueryRequestBuilder.InitializeGlobalState` -- `IQueryRequestBuilder.SetProperty` --> `IQueryRequestBuilder.SetGlobalState` -- `IQueryRequestBuilder.AddProperty` --> `IQueryRequestBuilder.AddGlobalState` -- `IQueryRequestBuilder.TryAddProperty` --> `IQueryRequestBuilder.TryAddGlobalState` -- `IQueryRequestBuilder.TryRemoveProperty` --> `IQueryRequestBuilder.RemoveGlobalState` +- `OperationRequestBuilder.SetProperties` --> `OperationRequestBuilder.InitializeGlobalState` +- `OperationRequestBuilder.SetProperty` --> `OperationRequestBuilder.SetGlobalState` +- `OperationRequestBuilder.AddProperty` --> `OperationRequestBuilder.AddGlobalState` +- `OperationRequestBuilder.TryAddProperty` --> `OperationRequestBuilder.TryAddGlobalState` +- `OperationRequestBuilder.TryRemoveProperty` --> `OperationRequestBuilder.RemoveGlobalState`