Skip to content

Commit 92bf74f

Browse files
authored
Merge pull request #2769 from angrykoala/remove-run-first-column
Remove run first column
2 parents 1e4e5e7 + f2bd09c commit 92bf74f

File tree

70 files changed

+568
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+568
-563
lines changed

.changeset/orange-bats-add.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
"@neo4j/graphql": major
3+
---
4+
5+
`@cypher` directive now requires the parameter `columnName`.
6+
7+
This requires all cypher queries to be made with a valid alias that must be referred in this new parameter.
8+
9+
For Example:
10+
11+
**@neo4j/graphql@3**
12+
13+
```
14+
@cypher(statement: "MATCH (i:Item) WHERE i.public=true RETURN i.name")
15+
```
16+
17+
**@neo4j/graphql@4**
18+
19+
```
20+
@cypher(statement: "MATCH (i:Item) WHERE i.public=true RETURN i.name as result", columnName: "result")
21+
```

docs/contributing/DEVELOPING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ run the following from `packages/graphql`:
113113
yarn test:tck
114114
```
115115

116+
### Verify TCK Tests
117+
118+
You can run all the TCK tests against the database to check that the Cypher generated is valid. This can be done with the env variable `VERIFY_TCK`
119+
120+
```bash
121+
VERIFY_TCK yarn test:tck
122+
```
123+
116124
### Testing using docker
117125

118126
```bash

examples/neo-place/typedefs.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Query {
1212
ORDER BY p.position ASC
1313
RETURN collect(color) as canvas
1414
"""
15+
columnName: "canvas"
1516
)
1617
@auth(rules: [{ isAuthenticated: true }])
1718
}

examples/neo-push/server/src/gql/Blog.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const typeDefs = gql`
1414
WITH creator IS NOT NULL AS isCreator
1515
RETURN isCreator
1616
"""
17+
columnName: "isCreator"
1718
)
1819
isAuthor: Boolean
1920
@cypher(
@@ -22,6 +23,7 @@ export const typeDefs = gql`
2223
WITH author IS NOT NULL AS isAuthor
2324
RETURN isAuthor
2425
"""
26+
columnName: "isAuthor"
2527
)
2628
createdAt: DateTime @timestamp(operations: [CREATE])
2729
updatedAt: DateTime @timestamp(operations: [UPDATE])

examples/neo-push/server/src/gql/Comment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const typeDefs = gql`
2121
) AS canDelete
2222
RETURN canDelete
2323
"""
24+
columnName: "canDelete"
2425
)
2526
createdAt: DateTime @timestamp(operations: [CREATE])
2627
updatedAt: DateTime @timestamp(operations: [UPDATE])

examples/neo-push/server/src/gql/Post.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const typeDefs = gql`
2222
) AS canEdit
2323
RETURN canEdit
2424
"""
25+
columnName: "canEdit"
2526
)
2627
canDelete: Boolean
2728
@cypher(
@@ -35,6 +36,7 @@ export const typeDefs = gql`
3536
) AS canDelete
3637
RETURN canDelete
3738
"""
39+
columnName: "canDelete"
3840
)
3941
createdAt: DateTime @timestamp(operations: [CREATE])
4042
updatedAt: DateTime @timestamp(operations: [UPDATE])

examples/subscriptions/apollo_rabbitmq/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const plugin = new Neo4jGraphQLSubscriptionsAMQPPlugin({
4040
});
4141

4242
//Alternatively, we can remove the AMQP server if we are only using a development server
43-
// const plugin = new new Neo4jGraphQLSubscriptionsSingleInstancePlugin();
43+
// const plugin = new Neo4jGrapghQLSubscriptionsSingleInstancePlugin();
4444

4545
if (!process.argv[2]) throw new Error("Usage node server.js [port]");
4646

packages/graphql/src/constants.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ const DEBUG_PREFIX = "@neo4j/graphql";
2222
export const AUTH_FORBIDDEN_ERROR = "@neo4j/graphql/FORBIDDEN";
2323
export const AUTH_UNAUTHENTICATED_ERROR = "@neo4j/graphql/UNAUTHENTICATED";
2424
export const MIN_VERSIONS = [{ majorMinor: "4.3", neo4j: "4.3.2" }];
25-
export const REQUIRED_APOC_FUNCTIONS = [
26-
"apoc.util.validatePredicate",
27-
"apoc.cypher.runFirstColumnSingle",
28-
"apoc.cypher.runFirstColumnMany",
29-
"apoc.date.convertFormat",
30-
];
25+
export const REQUIRED_APOC_FUNCTIONS = ["apoc.util.validatePredicate", "apoc.date.convertFormat"];
3126
export const REQUIRED_APOC_PROCEDURES = ["apoc.util.validate", "apoc.do.when", "apoc.cypher.doIt"];
3227
export const DEBUG_ALL = `${DEBUG_PREFIX}:*`;
3328
export const DEBUG_AUTH = `${DEBUG_PREFIX}:auth`;

packages/graphql/src/graphql/directives/cypher.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export const cypherDirective = new GraphQLDirective({
3131
type: new GraphQLNonNull(GraphQLString),
3232
},
3333
columnName: {
34-
description:
35-
"[Experimental] Name of the returned variable from the Cypher statement, if provided, the query will be optimized to improve performance.",
36-
type: GraphQLString,
34+
description: "Name of the returned variable from the Cypher statement.",
35+
type: new GraphQLNonNull(GraphQLString),
3736
},
3837
},
3938
});

packages/graphql/src/schema/make-augmented-schema.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ describe("makeAugmentedSchema", () => {
182182
}
183183
184184
type Query {
185-
movies: [Movie!]! @cypher(statement: "")
185+
movies: [Movie!]! @cypher(statement: "RETURN 5 as a", columnName: "a")
186186
}
187187
`;
188188

@@ -225,7 +225,7 @@ describe("makeAugmentedSchema", () => {
225225
name: String
226226
}
227227
228-
interface ActedIn @cypher(statement: "RETURN rand()") {
228+
interface ActedIn @cypher(statement: "RETURN rand() as rand", columnName: "rand") {
229229
screenTime: Int
230230
}
231231
`;
@@ -282,7 +282,7 @@ describe("makeAugmentedSchema", () => {
282282
}
283283
284284
interface ActedIn {
285-
id: ID @cypher(statement: "RETURN id(this)")
285+
id: ID @cypher(statement: "RETURN id(this) as id", columnName: "id")
286286
roles: [String]
287287
}
288288
`;

0 commit comments

Comments
 (0)