コード例 #1
0
        public ExecutionContext(
            ISchema schema,
            DirectiveLookup directiveLookup,
            DocumentNode queryDocument,
            OperationDefinitionNode operation,
            OperationRequest request,
            VariableCollection variables,
            CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            Schema = schema
                     ?? throw new ArgumentNullException(nameof(schema));
            _directiveLookup = directiveLookup
                               ?? throw new ArgumentNullException(nameof(directiveLookup));
            QueryDocument = queryDocument
                            ?? throw new ArgumentNullException(nameof(queryDocument));
            Operation = operation
                        ?? throw new ArgumentNullException(nameof(operation));
            Variables = variables
                        ?? throw new ArgumentNullException(nameof(variables));

            Services       = _serviceFactory.Services = request.Services;
            _session       = request.Session;
            _resolverCache = request.Session?.CustomContexts
                             .GetCustomContext <IResolverCache>();

            Fragments       = new FragmentCollection(schema, queryDocument);
            _fieldCollector = new FieldCollector(variables, Fragments);
            OperationType   = schema.GetOperationType(operation.Operation);
            RootValue       = ResolveRootValue(request.Services, schema,
                                               OperationType, request.InitialValue);

            if (RootValue == null)
            {
                RootValue         = CreateRootValue(Services, schema, OperationType);
                _disposeRootValue = true;
            }

            CancellationToken = cancellationToken;
            _clone            = c => new ExecutionContext(
                schema, directiveLookup, queryDocument,
                operation, CreateOperationRequest(
                    schema, request.VariableValues,
                    request.InitialValue),
                variables, c);
        }
コード例 #2
0
        public ExecutionContext(
            ISchema schema,
            DirectiveLookup directiveLookup,
            DocumentNode queryDocument,
            OperationDefinitionNode operation,
            OperationRequest request,
            VariableCollection variables,
            CancellationToken requestAborted)
        {
            Schema = schema
                     ?? throw new ArgumentNullException(nameof(schema));
            _directiveLookup = directiveLookup
                               ?? throw new ArgumentNullException(nameof(directiveLookup));
            QueryDocument = queryDocument
                            ?? throw new ArgumentNullException(nameof(queryDocument));
            Operation = operation
                        ?? throw new ArgumentNullException(nameof(operation));
            Variables = variables
                        ?? throw new ArgumentNullException(nameof(variables));
            _request = request
                       ?? throw new ArgumentNullException(nameof(request));

            Services       = _serviceFactory.Services = request.Services;
            _resolverCache = request.Session?.CustomContexts
                             .GetCustomContext <IResolverCache>();
            ErrorHandler = Services.GetRequiredService <IErrorHandler>();

            Fragments       = new FragmentCollection(schema, queryDocument);
            _fieldCollector = new FieldCollector(variables, Fragments);
            OperationType   = schema.GetOperationType(operation.Operation);
            RootValue       = ResolveRootValue(request.Services, schema,
                                               OperationType, request.InitialValue);

            if (RootValue == null)
            {
                RootValue         = CreateRootValue(Services, schema, OperationType);
                _disposeRootValue = true;
            }

            RequestAborted = requestAborted;
        }