/// <summary> /// Creates a scalar containing field /// </summary> /// <param name="name">The field name</param> /// <param name="type">The field type</param> /// <param name="flags">The field flags</param> /// <param name="arguments"> /// The arguments (if is set - this field becomes a method) /// </param> /// <param name="description"> /// The field description /// </param> /// <returns>The new field</returns> public static ApiField Scalar( [NotNull] string name, EnScalarType type, EnFieldFlags flags = EnFieldFlags.Queryable, IEnumerable <ApiField> arguments = null, string description = null) { if (type == EnScalarType.None) { throw new ArgumentException("Type cannot be None"); } if (flags.HasFlag(EnFieldFlags.IsConnection)) { throw new ArgumentException("Scalar field can't be used as connected objects"); } return(new ApiField(name, flags) { ScalarType = type, Description = description, Arguments = arguments != null ? new List <ApiField>(arguments) : new List <ApiField>() }); }
/// <summary> /// Creates an object containing field /// </summary> /// <param name="name"> /// The field name /// </param> /// <param name="typeName"> /// The field type name /// </param> /// <param name="flags"> /// The field flags /// </param> /// <param name="arguments"> /// The arguments (if is set - this field becomes a method) /// </param> /// <param name="description"> /// The field description /// </param> /// <returns> /// The new field /// </returns> public static ApiField Object( [NotNull] string name, [NotNull] string typeName, EnFieldFlags flags = EnFieldFlags.Queryable, IEnumerable <ApiField> arguments = null, string description = null) { if (flags.HasFlag(EnFieldFlags.IsKey)) { throw new ArgumentException("Object field can't be used as key"); } return(new ApiField(name, flags) { TypeName = typeName, ScalarType = EnScalarType.None, Description = description, Arguments = arguments != null ? new List <ApiField>(arguments) : new List <ApiField>() }); }