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