Пример #1
0
        /// <summary>
        /// Inspects the arguments supplied on the user's query document, merges them with those defaulted from the graph field itself
        /// and applies variable data as necessary to generate a single unified set of input arguments to be used when resolving a field of data.
        /// </summary>
        /// <param name="argumentContainer">The field selection.</param>
        /// <param name="querySuppliedArguments">The supplied argument collection parsed from the user query document.</param>
        /// <returns>Task&lt;IInputArgumentCollection&gt;.</returns>
        private IInputArgumentCollection CreateArgumentList(
            IGraphFieldArgumentContainer argumentContainer,
            IQueryInputArgumentCollection querySuppliedArguments)
        {
            var collection   = new InputArgumentCollection();
            var argGenerator = new ArgumentGenerator(_schema, querySuppliedArguments);

            foreach (var argument in argumentContainer.Arguments)
            {
                var argResult = argGenerator.CreateInputArgument(argument);
                if (argResult.IsValid)
                {
                    collection.Add(new InputArgument(argument, argResult.Argument));
                }
                else
                {
                    _messages.Add(argResult.Message);
                }
            }

            return(collection);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArgumentGenerator" /> class.
 /// </summary>
 /// <param name="schema">The schema.</param>
 /// <param name="suppliedArguments">A collection of arguments passed on a user's query
 /// to be used first in the chain of object resolution for any created arguments.</param>
 public ArgumentGenerator(ISchema schema, IQueryInputArgumentCollection suppliedArguments)
 {
     _suppliedArguments      = Validation.ThrowIfNullOrReturn(suppliedArguments, nameof(suppliedArguments));
     _schema                 = Validation.ThrowIfNullOrReturn(schema, nameof(schema));
     _inputResolverGenerator = new InputResolverMethodGenerator(_schema);
 }