protected override void OnCompleteField( ITypeCompletionContext context, ITypeSystemMember declaringMember, TDefinition definition) { base.OnCompleteField(context, declaringMember, definition); Type = context.GetType <IOutputType>(definition.Type !); _runtimeType = CompleteRuntimeType(Type, null); Arguments = OnCompleteFields(context, definition); }
protected override void OnCompleteField( ITypeCompletionContext context, ITypeSystemMember declaringMember, InputFieldDefinition definition) { definition.Type = TypeReference.Parse( $"[{context.Type.Name}!]", TypeContext.Input, context.Type.Scope); base.OnCompleteField(context, declaringMember, definition); }
protected override void OnCompleteField( ITypeCompletionContext context, ITypeSystemMember declaringMember, InputFieldDefinition definition) { base.OnCompleteField(context, declaringMember, definition); if (Member?.DeclaringType is not null) { RuntimeType = context.TypeInspector.GetReturnType(Member); } }
protected override void OnCompleteField( ITypeCompletionContext context, ITypeSystemMember declaringMember, InputFieldDefinition definition) { base.OnCompleteField(context, declaringMember, definition); Type = context.GetType <IInputType>(definition.Type !); _runtimeType = definition.Property?.PropertyType !; _runtimeType = CompleteRuntimeType(Type, _runtimeType, out var isOptional); DefaultValue = CompleteDefaultValue(context, definition, Type, Coordinate); IsOptional = isOptional; }
public SchemaTypeReference WithType(ITypeSystemMember type) { if (type is null) { throw new ArgumentNullException(nameof(type)); } return(new SchemaTypeReference( type, Context, Scope, Nullable)); }
protected override void OnCompleteField( ITypeCompletionContext context, ITypeSystemMember declaringMember, InputFieldDefinition definition) { definition.Type = TypeReference.Create( new ListTypeNode( new NonNullTypeNode( new NamedTypeNode(context.Type.Name))), TypeContext.Input, context.Type.Scope); base.OnCompleteField(context, declaringMember, definition); }
public SchemaTypeReference( ITypeSystemMember type, bool?isTypeNullable, bool?isElementTypeNullable) : base(InferTypeContext(type), isTypeNullable, isElementTypeNullable) { if (type == null) { throw new ArgumentNullException(nameof(type)); } Type = type; }
public static IObjectFieldDescriptor UseSorting( this IObjectFieldDescriptor descriptor, Type sortType, ITypeSystemMember sortTypeInstance = null) { FieldMiddleware placeholder = next => context => Task.CompletedTask; descriptor .Use(placeholder) .Extend() .OnBeforeCreate(definition => { Type argumentType = GetArgumentType(definition, sortType); ITypeReference argumentTypeReference = sortTypeInstance is null ? (ITypeReference) new ClrTypeReference( argumentType, TypeContext.Input) : new SchemaTypeReference(sortTypeInstance); var argumentDefinition = new ArgumentDefinition { Name = OrderByArgumentName, Type = new ClrTypeReference( argumentType, TypeContext.Input) }; definition.Arguments.Add(argumentDefinition); ILazyTypeConfiguration lazyConfiguration = LazyTypeConfigurationBuilder .New <ObjectFieldDefinition>() .Definition(definition) .Configure((context, defintion) => CompileMiddleware( context, definition, argumentTypeReference, placeholder)) .On(ApplyConfigurationOn.Completion) .DependsOn(argumentTypeReference, true) .Build(); definition.Configurations.Add(lazyConfiguration); }); return(descriptor); }
public static FieldCollection <TField> CompleteFields <TFieldDefinition, TField>( ITypeCompletionContext context, ITypeSystemMember declaringMember, IEnumerable <TFieldDefinition> fieldDefs, Func <TFieldDefinition, int, TField> fieldFactory, int maxFieldCount) where TFieldDefinition : FieldDefinitionBase, IHasSyntaxNode where TField : class, IField { if (context is null) { throw new ArgumentNullException(nameof(context)); } if (declaringMember is null) { throw new ArgumentNullException(nameof(declaringMember)); } if (fieldDefs is null) { throw new ArgumentNullException(nameof(fieldDefs)); } if (fieldFactory is null) { throw new ArgumentNullException(nameof(fieldDefs)); } if (maxFieldCount < 1) { throw new ArgumentOutOfRangeException( paramName: nameof(maxFieldCount), actualValue: maxFieldCount, message: TypeResources.FieldInitHelper_CompleteFields_MaxFieldCountToSmall); } return(CompleteFieldsInternal( context, declaringMember, fieldDefs, fieldFactory, maxFieldCount)); }
protected override void OnCompleteField( ITypeCompletionContext context, ITypeSystemMember declaringMember, ObjectFieldDefinition definition) { base.OnCompleteField(context, declaringMember, definition); CompleteExecutableDirectives(context); CompleteResolver(context, definition); // going forward we should rework the list detection in the ExtendedType to already // provide us with the info if a type is an async enumerable. if (Type.IsListType() && definition.ResultType is { IsGenericType : true } resultType&& context.TypeInspector.GetType(resultType).Definition == typeof(IAsyncEnumerable <>)) { MaybeStream = true; } }
public void Handle(ITypeRegistrar typeRegistrar, ITypeReference typeReference) { var typeRef = (SchemaTypeReference)typeReference; if (!typeRegistrar.IsResolved(typeReference)) { ITypeSystemMember tsm = typeRef.Type; // if it is a type object we will make sure it is unwrapped. if (typeRef.Type is IType type) { tsm = type.NamedType(); } if (tsm is TypeSystemObjectBase tso) { typeRegistrar.Register(tso, typeReference.Scope); } } }
public static FieldCollection <TField> CompleteFields <TField>( ITypeCompletionContext context, ITypeSystemMember declaringMember, TField[] fields) where TField : class, IField { if (context is null) { throw new ArgumentNullException(nameof(context)); } if (declaringMember is null) { throw new ArgumentNullException(nameof(declaringMember)); } if (fields is null) { throw new ArgumentNullException(nameof(fields)); } return(CompleteFieldsInternal(context, declaringMember, fields)); }
public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (SchemaTypeReference typeReference in typeReferences.OfType <SchemaTypeReference>()) { if (!typeRegistrar.IsResolved(typeReference)) { ITypeSystemMember tsm = typeReference.Type; // if it is a type object we will make sure it is unwrapped. if (typeReference.Type is IType type) { tsm = type.NamedType(); } if (tsm is TypeSystemObjectBase tso) { typeRegistrar.Register(tso, typeReference.Scope); } } } }
private static IObjectFieldDescriptor UseFiltering( IObjectFieldDescriptor descriptor, Type filterType, ITypeSystemMember filterTypeInstance = null) { FieldMiddleware placeholder = next => context => Task.CompletedTask; descriptor .Use(placeholder) .Extend() .OnBeforeCreate(definition => { Type argumentType = filterType; if (filterType == null) { if (!TypeInspector.Default.TryCreate( definition.ResultType, out TypeInfo typeInfo)) { // TODO : resources throw new ArgumentException( "Cannot handle the specified type.", nameof(descriptor)); } argumentType = typeof(FilterInputType <>).MakeGenericType( typeInfo.ClrType); } var argumentTypeReference = filterTypeInstance is null ? (ITypeReference) new ClrTypeReference( argumentType, TypeContext.Input) : new SchemaTypeReference(filterTypeInstance); if (argumentType == typeof(object)) { // TODO : resources throw new SchemaException( SchemaErrorBuilder.New() .SetMessage( "The filter type cannot be " + "infered from `System.Object`.") .SetCode(ErrorCodes.Filtering.FilterObjectType) .Build()); } var argumentDefinition = new ArgumentDefinition(); argumentDefinition.Name = _whereArgumentName; argumentDefinition.Type = new ClrTypeReference( argumentType, TypeContext.Input); definition.Arguments.Add(argumentDefinition); ILazyTypeConfiguration lazyConfiguration = LazyTypeConfigurationBuilder .New <ObjectFieldDefinition>() .Definition(definition) .Configure((context, defintion) => CompileMiddleware( context, definition, argumentTypeReference, placeholder)) .On(ApplyConfigurationOn.Completion) .DependsOn(argumentTypeReference, true) .Build(); definition.Configurations.Add(lazyConfiguration); }); return(descriptor); }
public SchemaTypeReference(ITypeSystemMember type) : this(type, null, null) { }