Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #363 from neo4j-graphql/4.0
Browse files Browse the repository at this point in the history
Initial support for Neo4j v4.0
  • Loading branch information
johnymontana authored Dec 18, 2019
2 parents f3144ce + c187701 commit bbd705f
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 31 deletions.
58 changes: 58 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ references:
NEO4J_VERSION: '3.5.4'
APOC_VERSION: '3.5.0.2'
DATASTORE_VERSION: '3_5'
env_neo4j40ce: &env_neo4j40ce
NEO4J_DIST: 'community'
NEO4J_VERSION: '4.0.0'
APOC_VERSION: '4.0.0-rc01'
DATASTORE_VERSION: '4_0'
env_neo4j40ee: &env_neo4j40ee
NEO4J_DIST: 'enterprise'
NEO4J_VERSION: '4.0.0'
APOC_VERSION: '4.0.0-rc01'
DATASTORE_VERSION: '4_0'

install_neo4j_steps: &install_neo4j_steps
- checkout
Expand Down Expand Up @@ -165,6 +175,16 @@ jobs:
environment: *env_neo4j35ee
steps: *install_neo4j_steps

install_neo4j40ce:
docker: *node10
environment: *env_neo4j40ce
steps: *install_neo4j_steps

install_neo4j40ee:
docker: *node10
environment: *env_neo4j40ee
steps: *install_neo4j_steps

# Node 8
install_for_node8:
docker: *node8
Expand All @@ -190,6 +210,16 @@ jobs:
environment: *env_neo4j35ee
steps: *run_tests_steps

neo4j40ce_node8:
docker: *node8
environment: *env_neo4j40ce
steps: *run_tests_steps

neo4j40ee_node8:
docker: *node8
environment: *env_neo4j40ee
steps: *run_tests_steps

# Node 10
install_for_node10:
docker: *node10
Expand All @@ -215,6 +245,16 @@ jobs:
environment: *env_neo4j35ee
steps: *run_tests_steps

neo4j40ce_node10:
docker: *node10
environment: *env_neo4j40ce
steps: *run_tests_steps

neo4j40ee_node10:
docker: *node10
environment: *env_neo4j40ee
steps: *run_tests_steps

workflows:
version: 2
integration_test:
Expand All @@ -225,6 +265,8 @@ workflows:
- install_neo4j34ce
- install_neo4j35ce
- install_neo4j35ee
- install_neo4j40ce
- install_neo4j40ee

- neo4j34ee_node8:
requires:
Expand All @@ -242,6 +284,14 @@ workflows:
requires:
- install_neo4j35ee
- install_for_node8
- neo4j40ce_node8:
requires:
- install_neo4j40ce
- install_for_node8
- neo4j40ee_node8:
requires:
- install_neo4j40ee
- install_for_node8

- neo4j34ee_node10:
requires:
Expand All @@ -259,3 +309,11 @@ workflows:
requires:
- install_neo4j35ee
- install_for_node10
- neo4j40ce_node10:
requires:
- install_neo4j40ce
- install_for_node10
- neo4j40ee_node10:
requires:
- install_neo4j40ee
- install_for_node10
2 changes: 1 addition & 1 deletion example/apollo-server/movies-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makeAugmentedSchema } from '../../src/index';
import { ApolloServer } from 'apollo-server-express';
import express from 'express';
import bodyParser from 'body-parser';
import { v1 as neo4j } from 'neo4j-driver';
import neo4j from 'neo4j-driver';
import { typeDefs, resolvers } from './movies-schema';

const schema = makeAugmentedSchema({
Expand Down
10 changes: 5 additions & 5 deletions example/apollo-server/movies-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ type Movie {
imdbRating: Float
ratings: [Rated]
genres: [Genre] @relation(name: "IN_GENRE", direction: "OUT")
similar(first: Int = 3, offset: Int = 0, limit: Int = 5): [Movie] @cypher(statement: "WITH {this} AS this MATCH (this)--(:Genre)--(o:Movie) RETURN o LIMIT {limit}")
mostSimilar: Movie @cypher(statement: "WITH {this} AS this RETURN this")
degree: Int @cypher(statement: "WITH {this} AS this RETURN SIZE((this)--())")
similar(first: Int = 3, offset: Int = 0, limit: Int = 5): [Movie] @cypher(statement: "MATCH (this)--(:Genre)--(o:Movie) RETURN o LIMIT $limit")
mostSimilar: Movie @cypher(statement: "RETURN this")
degree: Int @cypher(statement: "RETURN SIZE((this)--())")
actors(first: Int = 3, offset: Int = 0): [Actor] @relation(name: "ACTED_IN", direction:"IN")
avgStars: Float
filmedIn: State @relation(name: "FILMED_IN", direction: "OUT")
location: Point
locations: [Point]
scaleRating(scale: Int = 3): Float @cypher(statement: "WITH $this AS this RETURN $scale * this.imdbRating")
scaleRatingFloat(scale: Float = 1.5): Float @cypher(statement: "WITH $this AS this RETURN $scale * this.imdbRating")
scaleRating(scale: Int = 3): Float @cypher(statement: "RETURN $scale * this.imdbRating")
scaleRatingFloat(scale: Float = 1.5): Float @cypher(statement: "RETURN $scale * this.imdbRating")
_id: ID
}
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"graphql": "^14.2.1",
"graphql-auth-directives": "^2.1.0",
"lodash": "^4.17.15",
"neo4j-driver": "^1.7.3"
"neo4j-driver": "^4.0.1"
},
"ava": {
"require": [
Expand Down
1 change: 1 addition & 0 deletions scripts/start-neo4j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if [ ! -d "neo4j/data/databases/graph.db" ]; then
exit 1
else
echo "dbms.allow_upgrade=true" >> ./neo4j/conf/neo4j.conf
echo "dbms.recovery.fail_on_missing_files=false" >> ./neo4j/conf/neo4j.conf
# Set initial and max heap to workaround JVM in docker issues
dbms_memory_heap_initial_size="2048m" dbms_memory_heap_max_size="2048m" ./neo4j/bin/neo4j start
echo "Waiting up to 2 minutes for neo4j bolt port ($BOLT_PORT)"
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ instead: \`DEBUG=neo4j-graphql-js\`.
debug('%s', query);
debug('%s', JSON.stringify(cypherParams, null, 2));

// TODO: Is this a 4.0 driver instance? Check bolt path for default database name and use that when creating the session
const session = context.driver.session();
let result;

Expand Down
2 changes: 1 addition & 1 deletion src/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
} from 'graphql';
import { buildCypherSelection } from './selections';
import _ from 'lodash';
import { v1 as neo4j } from 'neo4j-driver';
import neo4j from 'neo4j-driver';

const derivedTypesParamName = interfaceName => `${interfaceName}_derivedTypes`;

Expand Down
6 changes: 4 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isObjectType, parse, GraphQLInt } from 'graphql';
import { v1 as neo4j } from 'neo4j-driver';
import neo4j from 'neo4j-driver';
import _ from 'lodash';
import filter from 'lodash/filter';
import { Neo4jTypeName } from './augment/types/types';
Expand Down Expand Up @@ -809,7 +809,9 @@ export const initializeMutationParams = ({
};

export const getOuterSkipLimit = (first, offset) =>
`${offset > 0 ? ` SKIP $offset` : ''}${first > -1 ? ' LIMIT $first' : ''}`;
`${offset > 0 ? ` SKIP toInteger($offset)` : ''}${
first > -1 ? ' LIMIT toInteger($first)' : ''
}`;

export const getPayloadSelections = resolveInfo => {
const filteredFieldNodes = filter(
Expand Down
18 changes: 9 additions & 9 deletions test/integration/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ test.serial('Create node mutation (not-isolated)', async t => {
imdbRating: 1,
location: {
__typename: '_Neo4jPoint',
longitude: 46.870035,
latitude: -113.990976,
longitude: -113.990976,
latitude: 46.870035,
height: 12.3
}
}
Expand All @@ -246,8 +246,8 @@ test.serial('Create node mutation (not-isolated)', async t => {
poster: "www.movieposter.com/img.png"
imdbRating: 1.0
location: {
longitude: 46.870035
latitude: -113.990976
latitude: 46.870035
longitude: -113.990976
height: 12.3
}
) {
Expand Down Expand Up @@ -287,8 +287,8 @@ test.serial('Merge node mutation (not-isolated)', async t => {
imdbRating: 1,
location: {
__typename: '_Neo4jPoint',
longitude: 46.870035,
latitude: -113.990976,
latitude: 46.870035,
longitude: -113.990976,
height: 12.3
}
}
Expand All @@ -307,8 +307,8 @@ test.serial('Merge node mutation (not-isolated)', async t => {
poster: "www.movieposter.com/img.png"
imdbRating: 1.0
location: {
longitude: 46.870035
latitude: -113.990976
latitude: 46.870035
longitude: -113.990976
height: 12.3
}
) {
Expand All @@ -318,8 +318,8 @@ test.serial('Merge node mutation (not-isolated)', async t => {
poster
imdbRating
location {
longitude
latitude
longitude
height
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cypherTest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('Simple skip limit', t => {
}
}
`,
expectedCypherQuery = `MATCH (\`movie\`:\`Movie\`${ADDITIONAL_MOVIE_LABELS} {title:$title}) RETURN \`movie\` { .title , .year } AS \`movie\` SKIP $offset LIMIT $first`;
expectedCypherQuery = `MATCH (\`movie\`:\`Movie\`${ADDITIONAL_MOVIE_LABELS} {title:$title}) RETURN \`movie\` { .title , .year } AS \`movie\` SKIP toInteger($offset) LIMIT toInteger($first)`;

t.plan(3);
return Promise.all([
Expand Down Expand Up @@ -1748,7 +1748,7 @@ test('orderBy test - descending, top level - augmented schema', t => {
}
}
`,
expectedCypherQuery = `MATCH (\`movie\`:\`Movie\`${ADDITIONAL_MOVIE_LABELS} {year:$year}) WITH \`movie\` ORDER BY movie.title DESC RETURN \`movie\` { .title ,actors: [(\`movie\`)<-[:\`ACTED_IN\`]-(\`movie_actors\`:\`Actor\`) | movie_actors { .name }][..3] } AS \`movie\` LIMIT $first`;
expectedCypherQuery = `MATCH (\`movie\`:\`Movie\`${ADDITIONAL_MOVIE_LABELS} {year:$year}) WITH \`movie\` ORDER BY movie.title DESC RETURN \`movie\` { .title ,actors: [(\`movie\`)<-[:\`ACTED_IN\`]-(\`movie_actors\`:\`Actor\`) | movie_actors { .name }][..3] } AS \`movie\` LIMIT toInteger($first)`;

t.plan(1);

Expand Down

0 comments on commit bbd705f

Please sign in to comment.