diff --git a/package.json b/package.json index 41d19daf..ccf6aa19 100755 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "test-all": "nyc ava --verbose", "test-isolated": "nyc ava test/**/*.test.js --verbose --match='!*not-isolated*'", "test-gateway": "nyc --reporter=lcov ava --fail-fast test/integration/gateway.test.js", + "test-infer": "nyc --reporter=lcov ava --fail-fast test/unit/neo4j-schema/*.js", "debug": "nodemon ./example/apollo-server/movies.js --exec babel-node --inspect-brk=9229 --nolazy", "debug-typedefs": "nodemon ./example/apollo-server/movies-typedefs.js --exec babel-node --inspect-brk=9229 --nolazy", "debug-interface": "nodemon ./example/apollo-server/interfaceError.js --exec babel-node --inspect-brk=9229 --nolazy", diff --git a/src/inferSchema.js b/src/inferSchema.js index 0ffbea77..aa4b21d5 100644 --- a/src/inferSchema.js +++ b/src/inferSchema.js @@ -57,7 +57,7 @@ const generateGraphQLTypeForTreeEntry = (tree, key) => { const tag = `@relation(name: "${extractRelationshipType( relId - )}", direction: "OUT")`; + )}", direction: OUT)`; const targetTypeName = allTargetLabels[0]; return ` ${targetTypeName.toLowerCase()}s: [${targetTypeName}] ${tag}\n`; diff --git a/src/neo4j-schema/graphQLMapper.js b/src/neo4j-schema/graphQLMapper.js index 8dcd12be..f61c5554 100644 --- a/src/neo4j-schema/graphQLMapper.js +++ b/src/neo4j-schema/graphQLMapper.js @@ -6,7 +6,7 @@ import Debug from 'debug'; const debug = Debug('neo4j-graphql-js'); const relationDirective = (relType, direction) => - `@relation(name: "${relType}", direction: "${direction}")`; + `@relation(name: "${relType}", direction: ${direction})`; const mapOutboundRels = (tree, node, config) => { const labels = node.getLabels(); @@ -25,9 +25,7 @@ const mapOutboundRels = (tree, node, config) => { // (:Customer)-[:BUYS]->(:Service) // In this case, without type unions the destination type for :BUYS is ambiguous. console.warn( - `RelID ${ - rel.id - } for label set ${labels} has > 1 target type (${targetLabels}); skipping` + `RelID ${rel.id} for label set ${labels} has > 1 target type (${targetLabels}); skipping` ); return null; } @@ -79,9 +77,7 @@ const mapInboundRels = (tree, node, config) => { if (originLabels.length > 1) { console.warn( - `RelID ${ - rel.id - } for label set ${labels} has > 1 origin type (${originLabels}); skipping` + `RelID ${rel.id} for label set ${labels} has > 1 origin type (${originLabels}); skipping` ); return null; } diff --git a/test/unit/neo4j-schema/graphQLMapperTest.test.js b/test/unit/neo4j-schema/graphQLMapperTest.test.js index 1374144c..6a9417e9 100644 --- a/test/unit/neo4j-schema/graphQLMapperTest.test.js +++ b/test/unit/neo4j-schema/graphQLMapperTest.test.js @@ -107,12 +107,12 @@ test('Defines properties with correct types', t => { test('Defines relationships BOTH WAYS with right order and @relation directive', t => { t.true( typeDefs.indexOf( - 'lives_in: [State] @relation(name: "LIVES_IN", direction: "OUT")' + 'lives_in: [State] @relation(name: "LIVES_IN", direction: OUT)' ) > -1 ); t.true( typeDefs.indexOf( - 'customers: [Customer] @relation(name: "LIVES_IN", direction: "IN")' + 'customers: [Customer] @relation(name: "LIVES_IN", direction: IN)' ) > -1 ); }); @@ -123,13 +123,13 @@ test('Deconflicts names for multi-targeted relationships by using relationship l // conflict. This tests that the module has worked around this. t.true( typeDefs.indexOf( - 'customers_buys: [Customer] @relation(name: "BUYS", direction: "IN")' + 'customers_buys: [Customer] @relation(name: "BUYS", direction: IN)' ) > -1 ); t.true( typeDefs.indexOf( - 'customers_reviewed: [Customer] @relation(name: "REVIEWED", direction: "IN")' + 'customers_reviewed: [Customer] @relation(name: "REVIEWED", direction: IN)' ) > -1 ); });