Source: https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/data-types/graph-element-reference-type/ Documentation version: v5.3.2 # Graph element reference types Graph element reference types represent references to nodes or edges in a graph: - `NODE`: Node reference value type. - `EDGE`: Edge reference value type. A reference value identifies a graph element; it is not a copy of the graph element's properties. You can access the properties of the referenced node or edge through the reference value. `NODE` and `EDGE` cannot be used as node or edge property types. ## Get graph element reference values Variables in graph element patterns hold references to the matched graph elements. For example: ```` ''' USE movie MATCH (a@Actor)-[e@Act]->(m@Movie) RETURN a, e, a.name LIMIT 1 ''' ```` In this query: - `a` and `m` hold node reference values. - `e` holds an edge reference value. - `a.name` accesses the `name` property of the referenced node. ## View graph element reference types The `typeof()` function returns the complete type of a reference value: ```` ''' USE movie MATCH (a@Actor)-[e]->(m@Movie) RETURN typeof(a) AS node_type, typeof(e) AS edge_type LIMIT 1 ''' ```` Return: ```` +---------------+------------------------------+ | node_type | edge_type | +---------------+------------------------------+ | Node<(Actor)> | Edge<(Actor)-[Act]->(Movie)> | +---------------+------------------------------+ ```` `NODE` and `EDGE` are generic reference value types. `Node<(Actor)>` includes the referenced node type. `Edge<(Actor)-[Act]->(Movie)>` includes the referenced edge type and its source and destination node types. ## Difference from graph element types Reference value types are different from the node and edge types defined in a graph type. | Term | Example | Meaning | Node reference value type | `NODE`, `Node<(Actor)>` | Value type of a query variable or parameter | Node type | `NODE TYPE Actor` | A category of nodes defined in a graph type | Edge reference value type | `EDGE`, `Edge<(Actor)-[Act]->(Movie)>` | Value type of a query variable or parameter | Edge type | `EDGE TYPE Act` | A category of edges defined in a graph type ## Use as procedure parameter types When you define a user-defined procedure (UDP), you can declare an input parameter as `NODE` or `EDGE`: ```` parameter_name NODE parameter_name EDGE ```` A `NODE` parameter accepts a node reference value, and an `EDGE` parameter accepts an edge reference value. For the complete syntax, see [CREATE PROCEDURE](https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/procedures/create/#parameter_type). ## Limitations - `NODE` and `EDGE` cannot be used as node or edge property types. - Reference equality means that two references identify the same graph element, not that two distinct graph elements happen to have identical property values.