public void Get_ExtensionScope_by_type() { /* Given */ var expected = Substitute.For <IExtensionScope>(); var sut = new ExtensionsRunner(new[] { expected }); /* When */ var actual = sut.Extension(expected.GetType()); /* Then */ Assert.Same(expected, actual); }
public QueryContext( Func <Exception, ExecutionError> formatError, ExecutableDocument document, OperationDefinition operation, ISchema schema, IReadOnlyDictionary <string, object?> coercedVariableValues, object initialValue, ExtensionsRunner extensionsRunner) { FormatError = formatError ?? throw new ArgumentNullException(nameof(formatError)); Document = document ?? throw new ArgumentNullException(nameof(document)); OperationDefinition = operation ?? throw new ArgumentNullException(nameof(operation)); Schema = schema ?? throw new ArgumentNullException(nameof(schema)); CoercedVariableValues = coercedVariableValues; InitialValue = initialValue; ExtensionsRunner = extensionsRunner; }
public ExecutorContext(ISchema schema, ExecutableDocument document, ExtensionsRunner extensionsRunner, IExecutionStrategy strategy, OperationDefinition operation, IDictionary <string, FragmentDefinition>?fragments, IReadOnlyDictionary <string, object?> coercedVariableValues) { Schema = schema ?? throw new ArgumentNullException(nameof(schema)); Document = document ?? throw new ArgumentNullException(nameof(document)); ExtensionsRunner = extensionsRunner ?? throw new ArgumentNullException(nameof(extensionsRunner)); Strategy = strategy ?? throw new ArgumentNullException(nameof(strategy)); Operation = operation; Fragments = fragments ?? new Dictionary <string, FragmentDefinition>(); CoercedVariableValues = coercedVariableValues; _errors = new List <Exception>(); }
BuildQueryContextAsync( ExecutionOptions options, ExtensionsRunner extensionsRunner, ILogger logger) { await extensionsRunner.BeginParseDocumentAsync(); var document = options.Document; await extensionsRunner.EndParseDocumentAsync(document); var operation = Operations.GetOperation(document, options.OperationName); logger.Operation(operation); var coercedVariableValues = Variables.CoerceVariableValues( options.Schema, operation, options.VariableValues); var queryContext = new QueryContext( options.FormatError, document, operation, options.Schema, coercedVariableValues, options.InitialValue, extensionsRunner); logger.Validate(options.Validate != null); var validationResult = ValidationResult.Success; if (options.Validate != null) { await extensionsRunner.BeginValidationAsync(); validationResult = await options.Validate( options.Schema, document, coercedVariableValues); logger.ValidationResult(validationResult); await extensionsRunner.EndValidationAsync(validationResult); } return(queryContext, validationResult); }