|
| 1 | +:toc: |
| 2 | + |
| 3 | += Field aliasing does not work if using DataFetchingInterceptor |
| 4 | + |
| 5 | +== Issue |
| 6 | + |
| 7 | +https://github.com/neo4j-graphql/neo4j-graphql-java/issues/267 |
| 8 | + |
| 9 | +== Schema |
| 10 | + |
| 11 | +[source,graphql,schema=true] |
| 12 | +---- |
| 13 | +type Movie { |
| 14 | + query: Int @cypher(statement: "RETURN 42", passThrough:true) |
| 15 | + title: String |
| 16 | + actors: [Actor!] @relation(name: "ACTED_IN", direction:IN) |
| 17 | +} |
| 18 | +type Actor { |
| 19 | + name: String |
| 20 | +} |
| 21 | +---- |
| 22 | + |
| 23 | +.Test-Data |
| 24 | +[source,cypher,test-data=true] |
| 25 | +---- |
| 26 | +CREATE (m:Movie{ title: 'movie 1' }), |
| 27 | + (max:Actor{ name: 'Max' }), |
| 28 | + (marie:Actor{ name: 'Marie' }), |
| 29 | + (max)-[:ACTED_IN]->(m), |
| 30 | + (marie)-[:ACTED_IN]->(m); |
| 31 | +---- |
| 32 | + |
| 33 | +== Queries |
| 34 | + |
| 35 | +.GraphQL-Query |
| 36 | +[source,graphql] |
| 37 | +---- |
| 38 | +query { |
| 39 | + movieAlias: movie { |
| 40 | + title |
| 41 | + title1: title |
| 42 | + title2: title |
| 43 | + query |
| 44 | + number1: query |
| 45 | + number2: query |
| 46 | + actors(orderBy: [ name_asc ]) { name } |
| 47 | + allMax: actors(filter: { name: "Max" }) { name } |
| 48 | + allMarie: actors(filter: { name: "Marie" }) { name } |
| 49 | + } |
| 50 | +} |
| 51 | +---- |
| 52 | + |
| 53 | +.GraphQL-Response |
| 54 | +[source,json,response=true] |
| 55 | +---- |
| 56 | +{ |
| 57 | + "movieAlias" : [ { |
| 58 | + "title" : "movie 1", |
| 59 | + "title1" : "movie 1", |
| 60 | + "title2" : "movie 1", |
| 61 | + "query" : 42, |
| 62 | + "number1" : 42, |
| 63 | + "number2" : 42, |
| 64 | + "actors" : [ { |
| 65 | + "name" : "Marie" |
| 66 | + }, { |
| 67 | + "name" : "Max" |
| 68 | + } ], |
| 69 | + "allMax" : [ { |
| 70 | + "name" : "Max" |
| 71 | + } ], |
| 72 | + "allMarie" : [ { |
| 73 | + "name" : "Marie" |
| 74 | + } ] |
| 75 | + } ] |
| 76 | +} |
| 77 | +---- |
| 78 | + |
| 79 | +.Cypher Params |
| 80 | +[source,json] |
| 81 | +---- |
| 82 | +{ |
| 83 | + "filterMovieAliasAllMarieName" : "Marie", |
| 84 | + "filterMovieAliasAllMaxName" : "Max" |
| 85 | +} |
| 86 | +---- |
| 87 | + |
| 88 | +.Cypher |
| 89 | +[source,cypher] |
| 90 | +---- |
| 91 | +MATCH (movieAlias:Movie) |
| 92 | +CALL { |
| 93 | + WITH movieAlias |
| 94 | + WITH movieAlias AS this |
| 95 | + RETURN 42 AS movieAliasQuery LIMIT 1 |
| 96 | +} |
| 97 | +CALL { |
| 98 | + WITH movieAlias |
| 99 | + WITH movieAlias AS this |
| 100 | + RETURN 42 AS movieAliasNumber1 LIMIT 1 |
| 101 | +} |
| 102 | +CALL { |
| 103 | + WITH movieAlias |
| 104 | + WITH movieAlias AS this |
| 105 | + RETURN 42 AS movieAliasNumber2 LIMIT 1 |
| 106 | +} |
| 107 | +CALL { |
| 108 | + WITH movieAlias |
| 109 | + MATCH (movieAlias)<-[:ACTED_IN]-(movieAliasActors:Actor) |
| 110 | + WITH movieAliasActors ORDER BY movieAliasActors.name ASC |
| 111 | + RETURN collect(movieAliasActors { |
| 112 | + .name |
| 113 | + }) AS movieAliasActors |
| 114 | +} |
| 115 | +CALL { |
| 116 | + WITH movieAlias |
| 117 | + MATCH (movieAlias)<-[:ACTED_IN]-(movieAliasAllMax:Actor) |
| 118 | + WHERE movieAliasAllMax.name = $filterMovieAliasAllMaxName |
| 119 | + RETURN collect(movieAliasAllMax { |
| 120 | + .name |
| 121 | + }) AS movieAliasAllMax |
| 122 | +} |
| 123 | +CALL { |
| 124 | + WITH movieAlias |
| 125 | + MATCH (movieAlias)<-[:ACTED_IN]-(movieAliasAllMarie:Actor) |
| 126 | + WHERE movieAliasAllMarie.name = $filterMovieAliasAllMarieName |
| 127 | + RETURN collect(movieAliasAllMarie { |
| 128 | + .name |
| 129 | + }) AS movieAliasAllMarie |
| 130 | +} |
| 131 | +RETURN movieAlias { |
| 132 | + .title, |
| 133 | + title1: movieAlias.title, |
| 134 | + title2: movieAlias.title, |
| 135 | + query: movieAliasQuery, |
| 136 | + number1: movieAliasNumber1, |
| 137 | + number2: movieAliasNumber2, |
| 138 | + actors: movieAliasActors, |
| 139 | + allMax: movieAliasAllMax, |
| 140 | + allMarie: movieAliasAllMarie |
| 141 | +} AS movieAlias |
| 142 | +---- |
| 143 | + |
| 144 | +''' |
0 commit comments