示例#1
0
        /// <summary>
        /// Attempts to deserialize a parameter value from the graph ql context supplied.
        /// </summary>
        /// <param name="argDefinition">The argument definition.</param>
        /// <returns>System.Object.</returns>
        private object ResolveParameterFromArgumentTemplate(IGraphFieldArgumentTemplate argDefinition)
        {
            if (argDefinition == null)
            {
                return(null);
            }

            if (argDefinition.ArgumentModifiers.IsSourceParameter())
            {
                return(this.SourceData);
            }

            return(this.ContainsKey(argDefinition.DeclaredArgumentName)
                ? this[argDefinition.DeclaredArgumentName].Value
                : argDefinition.DefaultValue);
        }
示例#2
0
        /// <summary>
        /// Creates a single graph field from the provided template using hte rules of this maker and the contained schema.
        /// </summary>
        /// <param name="template">The template to generate a field from.</param>
        /// <returns>IGraphField.</returns>
        public GraphArgumentCreationResult CreateArgument(IGraphFieldArgumentTemplate template)
        {
            var formatter = _schema.Configuration.DeclarationOptions.GraphNamingFormatter;

            var argument = new GraphFieldArgument(
                formatter.FormatFieldName(template.Name),
                template.TypeExpression.CloneTo(formatter.FormatGraphTypeName(template.TypeExpression.TypeName)),
                template.ArgumentModifiers,
                template.DeclaredArgumentName,
                template.InternalFullName,
                template.ObjectType,
                template.DefaultValue);

            var result = new GraphArgumentCreationResult();

            result.Argument = argument;

            result.AddDependentRange(template.RetrieveRequiredTypes());

            return(result);
        }