/// <summary> /// Initializes a new instance of the <see cref="IntrospectedInputValueType" /> class. /// </summary> /// <param name="argument">The field argument used to populate this input value.</param> /// <param name="introspectedGraphType">The meta data representing the type of this argument.</param> public IntrospectedInputValueType(IGraphFieldArgument argument, IntrospectedType introspectedGraphType) { this.IntrospectedGraphType = Validation.ThrowIfNullOrReturn(introspectedGraphType, nameof(introspectedGraphType)); Validation.ThrowIfNull(argument, nameof(argument)); this.Name = argument.Name; this.Description = argument.Description; _rawDefaultValue = argument.DefaultValue; }
/// <summary> /// Adds the <see cref="IGraphFieldArgument" /> to the collection. /// </summary> /// <param name="argument">The argument to add.</param> /// <returns>IArgument.</returns> public IGraphFieldArgument AddArgument(IGraphFieldArgument argument) { Validation.ThrowIfNull(argument, nameof(argument)); _arguments.Add(argument.Name, argument); if (argument.ArgumentModifiers.IsSourceParameter() && _sourceArgument == null) { _sourceArgument = argument; } return(argument); }
/// <summary> /// Attempts to create a qualified input argument for the supplied schema field. /// </summary> /// <param name="argument">The argument defined on schema that needs to have /// an input value created fro.</param> /// <returns>Task.</returns> public ArgumentGenerationResult CreateInputArgument(IGraphFieldArgument argument) { Validation.ThrowIfNull(argument, nameof(argument)); if (!_suppliedArguments.ContainsKey(argument.Name)) { return(new ArgumentGenerationResult(new ResolvedInputArgumentValue(argument.Name, argument.DefaultValue))); } var coreValue = _suppliedArguments[argument.Name].Value; var resolver = _inputResolverGenerator.CreateResolver(coreValue.OwnerArgument.TypeExpression); if (this.ShouldDeferResolution(coreValue)) { return(new ArgumentGenerationResult(new DeferredInputArgumentValue(coreValue, resolver))); } try { var data = resolver.Resolve(coreValue); return(new ArgumentGenerationResult(new ResolvedInputArgumentValue(coreValue.OwnerArgument.Name, data))); } catch (UnresolvedValueException svce) { var message = new GraphExecutionMessage( GraphMessageSeverity.Critical, svce.Message, Constants.ErrorCodes.INVALID_ARGUMENT, coreValue.OwnerArgument.Value.ValueNode.Location.AsOrigin(), exception: svce.InnerException); return(new ArgumentGenerationResult(message)); } catch (Exception ex) { var message = new GraphExecutionMessage( GraphMessageSeverity.Critical, "Invalid argument value.", Constants.ErrorCodes.INVALID_ARGUMENT, coreValue.OwnerArgument.Value.ValueNode.Location.AsOrigin(), ex); return(new ArgumentGenerationResult(message)); } }
/// <summary> /// Initializes a new instance of the <see cref="ExecutionArgument" /> class. /// </summary> /// <param name="argument">The argument.</param> /// <param name="value">The value.</param> public ExecutionArgument(IGraphFieldArgument argument, object value) { this.Argument = Validation.ThrowIfNullOrReturn(argument, nameof(argument)); this.Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="InputArgument" /> class. /// </summary> /// <param name="argument">The field argument defined in a schema.</param> /// <param name="value">The value representing this field argument as its defined in a query document.</param> public InputArgument(IGraphFieldArgument argument, IInputArgumentValue value) { this.Argument = Validation.ThrowIfNullOrReturn(argument, nameof(argument)); this.Value = Validation.ThrowIfNullOrReturn(value, nameof(value)); }