Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 3
0
 internal FilterField(FilterFieldDefinition definition)
     : base(definition)
 {
     Member = definition.Member;
 }
Esempio n. 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;