# IsConnectionAllowed(IPort, IPort)

> Determines whether a connection between the specified output and input ports is allowed.

## Definition

* **Type:** Method
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.7/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor

```csharp
public virtual bool IsConnectionAllowed(IPort output, IPort input)
```

### Parameters

**** (\[IPort]\(/engine/6000.7/script-reference/unity/graphtoolkit/editor/iport)): The output port from which the connection originates.**** (\[IPort]\(/engine/6000.7/script-reference/unity/graphtoolkit/editor/iport)): The input port to which the connection is being made.

### Returns

| Type                                                          | Description                                                                        |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if a connection between the specified ports is allowed; otherwise, `false`. |

### Remarks

The default implementation checks type compatibility by verifying that the input port's [IPort.DataType](/engine/6000.7/script-reference/unity/graphtoolkit/editor/iport/datatype.md) is assignable from the output port's [IPort.DataType](/engine/6000.7/script-reference/unity/graphtoolkit/editor/iport/datatype.md). This allows connections between ports of the same type or where the output type is derived from the input type.

Override this method in derived graph classes to implement custom connection validation logic, such as additional type constraints, node-specific rules, or graph-level restrictions.

### Examples

```csharp
public override bool IsConnectionAllowed(IPort output, IPort input)
{
    // Allow connection if the output is a string and the input is an int
    if (output.DataType == typeof(string) && input.DataType == typeof(int))
        return true;

    // Fallback on the default behaviour
    return base.IsConnectionAllowed(output, input);
}
```
