-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from danstarns/alias-fix
Alias fix
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
## Cypher Alias | ||
|
||
Tests to ensure when using aliases that the cypher is correct. | ||
|
||
Schema: | ||
|
||
```schema | ||
type Actor { | ||
name: String | ||
} | ||
type Movie { | ||
id: ID | ||
actors: [Actor] @relationship(type: "ACTED_IN", direction: "IN") | ||
custom: [Movie] @cypher(statement: """ | ||
MATCH (m:Movie) | ||
RETURN m | ||
""") | ||
} | ||
``` | ||
|
||
--- | ||
|
||
### Alias | ||
|
||
**GraphQL input** | ||
|
||
```graphql | ||
{ | ||
movies { | ||
movieId: id | ||
actors { | ||
aliasActorsName: name | ||
} | ||
custom { | ||
aliasCustomId: id | ||
} | ||
} | ||
} | ||
``` | ||
|
||
**Expected Cypher output** | ||
|
||
```cypher | ||
MATCH (this:Movie) | ||
RETURN this { | ||
.id, | ||
actors: [ (this)<-[:ACTED_IN]-(this_actors:Actor) | this_actors { .name } ], | ||
custom: [this_custom IN apoc.cypher.runFirstColumn("MATCH (m:Movie) RETURN m", {this: this, jwt: $jwt}, true) | this_custom { .id }] | ||
} as this | ||
``` | ||
|
||
**Expected Cypher params** | ||
|
||
```cypher-params | ||
{ | ||
"jwt": {} | ||
} | ||
``` |