Skip to content

Commit 957b092

Browse files
Andy2003jexp
authored andcommitted
fix tests for native id (#69)
1 parent 3c7b726 commit 957b092

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/main/kotlin/org/neo4j/graphql/Predicates.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ data class ExpressionPredicate(val name: String, val op: Operators, val value: A
7373
override fun toExpression(variable: String): Cypher {
7474
val paramName: String = ProjectionBase.FILTER + paramName(variable, name, value).capitalize()
7575
val query = if (fieldDefinition.isNativeId()) {
76-
"${not}ID($variable) ${op.op} toInteger(\$$paramName)"
76+
if (op.list){
77+
"${not}ID($variable) ${op.op} [id IN \$$paramName | toInteger(id)]"
78+
} else {
79+
"${not}ID($variable) ${op.op} toInteger(\$$paramName)"
80+
}
7781
} else {
7882
"$not$variable.${name.quote()} ${op.op} \$$paramName"
7983
}

src/main/kotlin/org/neo4j/graphql/SchemaBuilder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ object SchemaBuilder {
3434

3535
@JvmStatic
3636
@JvmOverloads
37-
fun buildSchema(typeDefinitionRegistry: TypeDefinitionRegistry , config: SchemaConfig = SchemaConfig(), dataFetchingInterceptor: DataFetchingInterceptor? = null): GraphQLSchema {
38-
val enhancedRegistry = typeDefinitionRegistry.merge(getNeo4jEnhancements())
37+
fun buildSchema(typeDefinitionRegistry: TypeDefinitionRegistry, config: SchemaConfig = SchemaConfig(), dataFetchingInterceptor: DataFetchingInterceptor? = null): GraphQLSchema {
38+
val enhancedRegistry = typeDefinitionRegistry.merge(getNeo4jEnhancements())
3939
if (!enhancedRegistry.getType(QUERY).isPresent) {
4040
enhancedRegistry.add(ObjectTypeDefinition.newObjectTypeDefinition().name(QUERY).build())
4141
}
4242

43-
val builder = RuntimeWiring.newRuntimeWiring() .scalar(DynamicProperties.INSTANCE)
43+
val builder = RuntimeWiring.newRuntimeWiring().scalar(DynamicProperties.INSTANCE)
4444

4545
enhancedRegistry
4646
.getTypes(InterfaceTypeDefinition::class.java)

src/test/resources/dynamic-property-tests.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ mutation {
207207
[source,cypher]
208208
----
209209
MATCH ()-[updateKnows:KNOWS]->()
210-
WHERE ID(updateKnows) = $updateKnows_id
210+
WHERE ID(updateKnows) = toInteger($updateKnows_id)
211211
SET updateKnows = { `prefix.foo`: $updateKnowsJsonFoo }
212212
WITH updateKnows
213213
RETURN updateKnows {
@@ -240,7 +240,7 @@ mutation {
240240
[source,cypher]
241241
----
242242
MATCH ()-[mergeKnows:KNOWS]->()
243-
WHERE ID(mergeKnows) = $mergeKnows_id
243+
WHERE ID(mergeKnows) = toInteger($mergeKnows_id)
244244
SET mergeKnows += { `prefix.foo`: $mergeKnowsJsonFoo }
245245
WITH mergeKnows RETURN mergeKnows {
246246
json:apoc.map.fromPairs([key IN keys(mergeKnows) WHERE key STARTS WITH 'prefix.'| [substring(key,7), mergeKnows[key]]])

src/test/resources/filter-tests.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ RETURN person { .name } AS person
386386
[source,cypher]
387387
----
388388
MATCH (company:Company)
389-
WHERE ID(company) = $filterCompany_id
389+
WHERE ID(company) = toInteger($filterCompany_id)
390390
RETURN company { .name, _id:ID(company) } AS company
391391
----
392392

@@ -408,7 +408,7 @@ RETURN company { .name, _id:ID(company) } AS company
408408
[source,cypher]
409409
----
410410
MATCH (company:Company)
411-
WHERE ID(company) IN $filterCompany_id
411+
WHERE ID(company) IN [id IN $filterCompany_id | toInteger(id)]
412412
RETURN company { .name, _id:ID(company) } AS company
413413
----
414414

@@ -430,7 +430,7 @@ RETURN company { .name, _id:ID(company) } AS company
430430
[source,cypher]
431431
----
432432
MATCH (company:Company)
433-
WHERE NOT ID(company) IN $filterCompany_id
433+
WHERE NOT ID(company) IN [id IN $filterCompany_id | toInteger(id)]
434434
RETURN company { .name, _id:ID(company) } AS company
435435
----
436436

@@ -452,7 +452,7 @@ RETURN company { .name, _id:ID(company) } AS company
452452
[source,cypher]
453453
----
454454
MATCH (company:Company)
455-
WHERE NOT ID(company) = $filterCompany_id
455+
WHERE NOT ID(company) = toInteger($filterCompany_id)
456456
RETURN company { .name, _id:ID(company) } AS company
457457
----
458458

src/test/resources/movie-tests.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ ORDER BY movie.year DESC LIMIT $movieFirst
878878
[source,cypher]
879879
----
880880
MATCH ()-[rated:RATED]->()
881-
WHERE ID(rated) = $rated_id
881+
WHERE ID(rated) = toInteger($rated_id)
882882
RETURN rated { .rating } AS rated
883883
----
884884

@@ -939,7 +939,7 @@ mutation {
939939
[source,cypher]
940940
----
941941
MATCH ()-[updateRated:RATED]->()
942-
WHERE ID(updateRated) = $updateRated_id
942+
WHERE ID(updateRated) = toInteger($updateRated_id)
943943
SET updateRated = { rating: $updateRatedRating }
944944
WITH updateRated
945945
RETURN updateRated { .rating } AS updateRated

0 commit comments

Comments
 (0)