예제 #1
0
        private static ITypeReference RewriteTypeToNullableType(
            FilterFieldDefinition definition,
            ITypeInspector typeInspector)
        {
            ITypeReference reference = definition.Type;

            if (reference is ExtendedTypeReference extendedTypeRef)
            {
                return(extendedTypeRef.Type.IsNullable
                    ? extendedTypeRef
                    : extendedTypeRef.WithType(typeInspector.ChangeNullability(extendedTypeRef.Type, true)));
            }

            if (reference is SchemaTypeReference schemaRef)
            {
                return(schemaRef.Type is NonNullType nnt
                    ? schemaRef.WithType(nnt.Type)
                    : schemaRef);
            }

            if (reference is SyntaxTypeReference syntaxRef)
            {
                return(syntaxRef.Type is NonNullTypeNode nnt
                    ? syntaxRef.WithType(nnt.Type)
                    : syntaxRef);
            }

            throw new NotSupportedException();
        }
예제 #2
0
        public bool TryGetHandler(
            ITypeDiscoveryContext context,
            FilterInputTypeDefinition typeDefinition,
            FilterFieldDefinition fieldDefinition,
            [NotNullWhen(true)] out IFilterFieldHandler?handler)
        {
            foreach (IFilterFieldHandler filterFieldHandler in _provider.FieldHandlers)
            {
                if (filterFieldHandler.CanHandle(context, typeDefinition, fieldDefinition))
                {
                    handler = filterFieldHandler;
                    return(true);
                }
            }

            handler = null;
            return(false);
        }
예제 #3
0
 internal FilterField(FilterFieldDefinition definition)
     : base(definition)
 {
     Member = definition.Member;
 }
예제 #4
0
 internal FilterField(FilterFieldDefinition definition)
     : base(definition, default)
 {
     Member  = definition.Member;
     Handler = definition.Handler;
 }
 /// <inheritdoc />
 public abstract bool CanHandle(
     ITypeDiscoveryContext context,
     FilterInputTypeDefinition typeDefinition,
     FilterFieldDefinition fieldDefinition);
 public override bool CanHandle(
     ITypeDiscoveryContext context,
     FilterInputTypeDefinition typeDefinition,
     FilterFieldDefinition fieldDefinition) => true;