示例#1
0
    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);
    }
示例#2
0
 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;
 }
示例#3
0
 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>();
 }
示例#4
0
    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);
    }