INNER CODE UNIT · Kotlin

relationship

neo4j-graphql/neo4j-graphql · src/main/kotlin/org/neo4j/graphql/CypherGenerator.kt:235

        val relationship = md.relationshipFor(field) // todo correct medatadata of

        val expectMultipleValues = md.properties[field]?.type?.array ?: true

        return if (!cypherStatement.isNullOrEmpty()) {

            val arguments = f.arguments.associate { it.name to it.value.cypherValue() }

            val params = (mapOf("this" to "`$variable`") + arguments).entries
                    .joinToString(",", "{", "}") { "`${it.key}`:${it.value}" }

            val prefix  = if (!cypherStatement.contains(Regex("this\\s*\\}?\\s+AS\\s+",RegexOption.IGNORE_CASE))) "WITH {this} AS this " else ""
            val runType = if (expectMultipleValues) "Many" else "Single"
            val cypherFragment = "graphql.run${runType}('${prefix}${cypherStatement}', $params)"

            if (relationship != null) {
                val (patternComp, _) = formatCypherDirectivePatternComprehension(md, cypherFragment, f, ctx.copy(orderBys = mutableListOf()))
                Pair(field, if (relationship.multi) patternComp else "head(${patternComp})")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…