Ejemplo n.º 1
0
        public OperationExecuter(
            ISchema schema,
            DocumentNode queryDocument,
            OperationDefinitionNode operation)
        {
            _schema = schema
                      ?? throw new ArgumentNullException(nameof(schema));
            _queryDocument = queryDocument
                             ?? throw new ArgumentNullException(nameof(queryDocument));
            _operation = operation
                         ?? throw new ArgumentNullException(nameof(operation));

            _executionTimeout = schema.Options.ExecutionTimeout;

            _variableValueBuilder = new VariableValueBuilder(schema, _operation);

            if (!_executionStrategy.TryGetValue(_operation.Operation,
                                                out IExecutionStrategy strategy))
            {
                throw new NotSupportedException();
            }
            _strategy = strategy;

            var directiveCollector = new DirectiveCollector(_schema);

            directiveCollector.VisitDocument(_queryDocument);
            _directiveLookup = directiveCollector.CreateLookup();
        }
Ejemplo n.º 2
0
        private DirectiveLookup CreateLookup(
            ISchema schema,
            DocumentNode document)
        {
            var directiveCollector = new DirectiveCollector(schema);

            directiveCollector.VisitDocument(document);
            return(directiveCollector.CreateLookup());
        }
Ejemplo n.º 3
0
        private DirectiveLookup GetOrCreateDirectiveLookup(
            IQueryContext context)
        {
            return(_directiveCache.GetOrCreate(
                       context.Request.Query,
                       () =>
            {
                var directiveCollector = new DirectiveCollector(
                    context.Schema);

                directiveCollector.VisitDocument(context.Document);

                return directiveCollector.CreateLookup();
            }));
        }