Example #1
0
        public new void Accept(ObjectField field)
        {
            IOutputType      type         = field.Type;
            SelectionSetNode selectionSet = Context.FieldSelection.SelectionSet;

            (type, selectionSet) = UnwrapOffsetBasedPaging(type, selectionSet);
            IType elementType = type.IsListType() ? type.ElementType() : type;

            Closures.Push(new SelectionClosure(elementType.ToClrType(), "e"));
            VisitSelections(type, selectionSet);
        }
Example #2
0
        public void Accept(IObjectField field)
        {
            IOutputType      type         = field.Type;
            SelectionSetNode?selectionSet = Context.FieldSelection.SelectionSet;

            (type, selectionSet) = UnwrapPaging(type, selectionSet);
            IType elementType = type.IsListType() ? type.ElementType() : type;

            Closures.Push(new SelectionClosure(elementType.ToRuntimeType(), "e"));
            VisitSelections(type, selectionSet);
        }
Example #3
0
    private static bool IsValidImplementationFieldType(
        IOutputType fieldType,
        IOutputType implementedType)
    {
        if (fieldType.IsNonNullType())
        {
            fieldType = (IOutputType)fieldType.InnerType();

            if (implementedType.IsNonNullType())
            {
                implementedType = (IOutputType)implementedType.InnerType();
            }

            return(IsValidImplementationFieldType(fieldType, implementedType));
        }

        if (fieldType.IsListType() && implementedType.IsListType())
        {
            return(IsValidImplementationFieldType(
                       (IOutputType)fieldType.ElementType(),
                       (IOutputType)implementedType.ElementType()));
        }

        if (ReferenceEquals(fieldType, implementedType))
        {
            return(true);
        }

        if (fieldType is ObjectType objectType &&
            implementedType is UnionType unionType &&
            unionType.IsAssignableFrom(objectType))
        {
            return(true);
        }

        if (fieldType is IComplexOutputType complexType &&
            implementedType is InterfaceType interfaceType &&
            complexType.IsImplementing(interfaceType))
        {
            return(true);
        }

        return(false);
    }