protected FieldBase( FieldDescriptionBase description, DirectiveLocation location) { if (description == null) { throw new ArgumentNullException(nameof(description)); } if (string.IsNullOrEmpty(description.Name)) { throw new ArgumentException( "The name of a field mustn't be null or empty.", nameof(description)); } Name = description.Name; Description = description.Description; TypeReference = description.TypeReference; var directives = new DirectiveCollection( this, location, description.Directives); RegisterForInitialization(directives); Directives = directives; }
internal static void AcquireNonNullStatus( this FieldDescriptionBase fieldDescription, MemberInfo member) { if (member.IsDefined(typeof(GraphQLNonNullTypeAttribute))) { var attribute = member.GetCustomAttribute <GraphQLNonNullTypeAttribute>(); fieldDescription.IsNullable = attribute.IsNullable; fieldDescription.IsElementNullable = attribute.IsElementNullable; } }
internal static void RewriteClrType( this FieldDescriptionBase fieldDescription, Func <Type, TypeReference> createContext) { if (fieldDescription.IsNullable.HasValue && fieldDescription.TypeReference.IsClrTypeReference()) { fieldDescription.TypeReference = createContext( DotNetTypeInfoFactory.Rewrite( fieldDescription.TypeReference.ClrType, !fieldDescription.IsNullable.Value, !fieldDescription.IsElementNullable.Value)); } }
protected FieldBase(FieldDescriptionBase description) { if (description == null) { throw new ArgumentNullException(nameof(description)); } if (string.IsNullOrEmpty(description.Name)) { throw new ArgumentException( "The name of a field mustn't be null or empty.", nameof(description)); } Name = description.Name; Description = description.Description; TypeReference = description.TypeReference; }