From dd205f80a136fa5ae9710bb2e078701bdab8b879 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 18:31:27 +0530 Subject: [PATCH 1/8] Update index.js --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index b462f81..30fb721 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,7 @@ export const neo4jAssertConstraints = async ({ driver, typeDefs, log }) => { const constraints = buildAssertionArguments(typeDefs); const session = driver.session(); return await session - .run(`CALL apoc.schema.assert({indexes}, {constraints}) YIELD label, key, unique, action RETURN { label: label, key: key, unique: unique, action: action }`, { + .run(`CALL apoc.schema.assert($indexes, $constraints) YIELD label, key, unique, action RETURN { label: label, key: key, unique: unique, action: action }`, { indexes: {}, constraints: constraints }) @@ -33,7 +33,7 @@ export const neo4jIDL = async ({ driver, typeDefs, log }) => { }); const session = driver.session(); return await session - .run(`CALL graphql.idl({schema}) YIELD value RETURN value`, {schema: remoteTypeDefs}) + .run(`CALL graphql.idl($schema) YIELD value RETURN value`, {schema: remoteTypeDefs}) .then(function (result) { if(log) logIDLResult(result); return result; From a6a0c909aa9c8cab90f2bd35bd20d61f2a6b14c4 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 18:43:44 +0530 Subject: [PATCH 2/8] updated package.json --- package.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/package.json b/package.json index 82561d9..f893c67 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,10 @@ "name": "neo4j-graphql-binding", "version": "1.2.0", "description": "A GraphQL binding for your Neo4j GraphQL API.", - "main": "dist/index.js", + "main": "src/index.js", "author": "Michael D Graham (michaeldgrahams@gmail.com)", "repository": "michaeldgraham/neo4j-graphql-binding", "scripts": { - "build": "babel src --out-dir dist" }, "keywords": [ "neo4j", @@ -22,14 +21,9 @@ "license": "MIT", "dependencies": { "apollo-link": "^1.2.2", - "babel-runtime": "^6.26.0", "cuid": "^2.1.1", "graphql": "^0.13.2", "graphql-binding": "^2.1.1", "graphql-tools": "^3.0.4" }, - "devDependencies": { - "babel-cli": "^6.26.0", - "babel-plugin-transform-runtime": "^6.23.0" - } } From 095eda95a2a12a2f5313dd1ed922c99b4d9e5bb0 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 18:54:13 +0530 Subject: [PATCH 3/8] updated package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f893c67..6625667 100644 --- a/package.json +++ b/package.json @@ -25,5 +25,5 @@ "graphql": "^0.13.2", "graphql-binding": "^2.1.1", "graphql-tools": "^3.0.4" - }, + } } From f4de014d8694e9de18fca3c3cd9315c6c076f089 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 19:09:19 +0530 Subject: [PATCH 4/8] fixed imports to require --- .idea/.gitignore | 2 ++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/neo4j-graphql-binding.iml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ src/binding.js | 9 ++++----- src/index.js | 8 ++++---- src/link.js | 10 +++++----- src/typedefs.js | 20 ++++++++++---------- 9 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/neo4j-graphql-binding.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a34d7aa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/neo4j-graphql-binding.iml b/.idea/neo4j-graphql-binding.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/neo4j-graphql-binding.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/binding.js b/src/binding.js index 210a6ea..7769f7d 100644 --- a/src/binding.js +++ b/src/binding.js @@ -1,9 +1,8 @@ -import { Binding } from 'graphql-binding'; -import { makeRemoteExecutableSchema } from 'graphql-tools'; -import { neo4jGraphQLLink } from './link.js'; -import { buildTypeDefs } from './typedefs.js'; +const{ Binding } = require('graphql-binding'); +const { makeRemoteExecutableSchema } = require('graphql-tools'); +const { neo4jGraphQLLink } = require('./link.js'); -export const Neo4jGraphQLBinding = class Neo4jGraphQLBinding extends Binding { +exports.Neo4jGraphQLBinding = class Neo4jGraphQLBinding extends Binding { constructor({ typeDefs, driver, log, indexConfig }) { super({ schema: makeRemoteExecutableSchema({ diff --git a/src/index.js b/src/index.js index 30fb721..a2237d2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ -import { parse, print } from 'graphql'; -import { getModelFieldMaps } from './link.js'; -import { Neo4jGraphQLBinding } from './binding.js'; -import { buildTypeDefs, buildOperationMap, buildTypeMaps, buildResolvers } from './typedefs.js'; +const { parse, print } = require('graphql'); +const { getModelFieldMaps } = require('./link.js'); +const { Neo4jGraphQLBinding } = require('./binding.js'); +const { buildTypeDefs, buildOperationMap, buildTypeMaps, buildResolvers } = require('./typedefs.js'); export const neo4jAssertConstraints = async ({ driver, typeDefs, log }) => { if(driver && typeDefs) { diff --git a/src/link.js b/src/link.js index c926caa..136ed0e 100644 --- a/src/link.js +++ b/src/link.js @@ -1,9 +1,9 @@ -import { ApolloLink, Observable } from 'apollo-link'; -import { print, parse } from 'graphql'; -import { buildTypeMaps, buildOperationMap, getFieldType } from './typedefs.js'; +const { ApolloLink, Observable } = require('apollo-link'); +const { print, parse } = require('graphql'); +const { buildTypeMaps, buildOperationMap, getFieldType } = require('./typedefs.js'); const cuid = require('cuid'); -export const neo4jGraphQLLink = ({ typeDefs, driver, log=false, indexConfig }) => { +exports.neo4jGraphQLLink = ({ typeDefs, driver, log=false, indexConfig }) => { const parsed = parse(typeDefs); const generatedMutations = getGeneratedMutations(parsed); const modelMap = buildModelMap(parsed); @@ -25,7 +25,7 @@ export const neo4jGraphQLLink = ({ typeDefs, driver, log=false, indexConfig }) = }); }); }; -export const getModelFieldMaps = (fields) => { +exports.getModelFieldMaps = (fields) => { let relationMap = {}; let propertyMap = {}; let listMap = {}; diff --git a/src/typedefs.js b/src/typedefs.js index 4bce3dd..e8f7f10 100644 --- a/src/typedefs.js +++ b/src/typedefs.js @@ -1,6 +1,6 @@ -import { parse, print } from 'graphql'; +const { parse, print } = require('graphql'); -export const buildTypeDefs = ({ +exports.buildTypeDefs = ({ typeDefs, query=true, mutation=true, @@ -98,7 +98,7 @@ export const buildTypeDefs = ({ }); return print(parsed); } -export const buildResolvers = ({ typeDefs, resolvers, query, mutation, bindingKey="neo4j" }) => { +exports.buildResolvers = ({ typeDefs, resolvers, query, mutation, bindingKey="neo4j" }) => { if(typeDefs === undefined) { throw Error(`buildNeo4jResolvers: typeDefs are undefined.`); } if(resolvers === undefined) { throw Error(`buildNeo4jResolvers: resolvers are undefined.`); } let augmentedResolvers = {}; @@ -140,7 +140,7 @@ export const buildResolvers = ({ typeDefs, resolvers, query, mutation, bindingKe } return augmentedResolvers; } -export const getOperationTypes = (parsed) => { +exports.getOperationTypes = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; let i = 0; @@ -163,7 +163,7 @@ export const getOperationTypes = (parsed) => { mutation: mutation }; }; -export const buildRelationalFieldNestedInputTypes = ({ action, modelName, isForRemote }) => { +exports.buildRelationalFieldNestedInputTypes = ({ action, modelName, isForRemote }) => { const inputs = []; // TODO only add those you need, check the arity of the value... switch(action) { @@ -374,7 +374,7 @@ export const buildRelationalFieldNestedInputTypes = ({ action, modelName, isForR } return inputs; }; -export const buildNestedMutationInputType = ({ action, modelName, modelAST, mutations, isForRemote }) => { +exports.buildNestedMutationInputType = ({ action, modelName, modelAST, mutations, isForRemote }) => { // Prevent overwriting any existing mutation of the same name if(mutations.fieldMap[`${action}${modelName}`] === undefined) { const inputFields = []; @@ -486,7 +486,7 @@ export const buildNestedMutationInputType = ({ action, modelName, modelAST, muta } return undefined; } -export const buildTypeMaps = (parsed) => { +exports.buildTypeMaps = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; let i = 0; @@ -521,7 +521,7 @@ export const buildTypeMaps = (parsed) => { types: types }; }; -export const buildOperationMap = (parsed) => { +exports.buildOperationMap = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; let i = 0; @@ -551,12 +551,12 @@ export const buildOperationMap = (parsed) => { mutations: mutations }; }; -export const getNamedType = (definition) => { +exports.getNamedType = (definition) => { let type = definition.type; while(type.kind !== "NamedType") type = type.type; return type; } -export const getFieldType = (field) => { +exports.getFieldType = (field) => { return field ? getNamedType(field).name.value : undefined; } From 2c0199d8f1c2bff257f16bdd48dd30eb08f57136 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 19:16:46 +0530 Subject: [PATCH 5/8] fixed imports to require --- src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index a2237d2..81452c2 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ const { getModelFieldMaps } = require('./link.js'); const { Neo4jGraphQLBinding } = require('./binding.js'); const { buildTypeDefs, buildOperationMap, buildTypeMaps, buildResolvers } = require('./typedefs.js'); -export const neo4jAssertConstraints = async ({ driver, typeDefs, log }) => { +exports.neo4jAssertConstraints = async ({ driver, typeDefs, log }) => { if(driver && typeDefs) { const constraints = buildAssertionArguments(typeDefs); const session = driver.session(); @@ -22,7 +22,7 @@ export const neo4jAssertConstraints = async ({ driver, typeDefs, log }) => { }); } }; -export const neo4jIDL = async ({ driver, typeDefs, log }) => { +exports.neo4jIDL = async ({ driver, typeDefs, log }) => { if(driver && typeDefs) { const cleanedTypeDefs = cleanCypherStatements(typeDefs); const remoteTypeDefs = buildTypeDefs({ @@ -44,10 +44,10 @@ export const neo4jIDL = async ({ driver, typeDefs, log }) => { }); } }; -export const neo4jGraphQLBinding = (config) => { +exports.neo4jGraphQLBinding = (config) => { return new Neo4jGraphQLBinding(config); }; -export const neo4jExecute = (params, ctx, info, binding) => { +exports.neo4jExecute = (params, ctx, info, binding) => { if(typeof binding !== "string") binding = "neo4j"; switch(info.parentType.name) { case "Query": { @@ -62,8 +62,8 @@ export const neo4jExecute = (params, ctx, info, binding) => { } throw Error(`Unsupported value for parentType.name`); } -export const buildNeo4jTypeDefs = buildTypeDefs; -export const buildNeo4jResolvers = buildResolvers; +exports.buildNeo4jTypeDefs = buildTypeDefs; +exports.buildNeo4jResolvers = buildResolvers; const buildAssertionArguments = (typeDefs) => { const parsed = parse(typeDefs); const models = buildTypeMaps(parsed).models; From 388af0a29921bac23bba1292e2ac5702540e0ecb Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 19:28:03 +0530 Subject: [PATCH 6/8] fixed imports to require --- src/typedefs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/typedefs.js b/src/typedefs.js index e8f7f10..b33dd87 100644 --- a/src/typedefs.js +++ b/src/typedefs.js @@ -486,7 +486,7 @@ exports.buildNestedMutationInputType = ({ action, modelName, modelAST, mutations } return undefined; } -exports.buildTypeMaps = (parsed) => { +const buildTypeMaps = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; let i = 0; @@ -521,6 +521,7 @@ exports.buildTypeMaps = (parsed) => { types: types }; }; +exports.buildTypeMaps = buildTypeMaps; exports.buildOperationMap = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; From 1207e164267211cd20be499f4c2f77fef5e04f22 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 19:34:44 +0530 Subject: [PATCH 7/8] fixed imports to require --- src/typedefs.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/typedefs.js b/src/typedefs.js index b33dd87..5fd4179 100644 --- a/src/typedefs.js +++ b/src/typedefs.js @@ -140,7 +140,7 @@ exports.buildResolvers = ({ typeDefs, resolvers, query, mutation, bindingKey="ne } return augmentedResolvers; } -exports.getOperationTypes = (parsed) => { +const getOperationTypes = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; let i = 0; @@ -163,7 +163,8 @@ exports.getOperationTypes = (parsed) => { mutation: mutation }; }; -exports.buildRelationalFieldNestedInputTypes = ({ action, modelName, isForRemote }) => { +exports.getOperationTypes = getOperationTypes; +const buildRelationalFieldNestedInputTypes = ({ action, modelName, isForRemote }) => { const inputs = []; // TODO only add those you need, check the arity of the value... switch(action) { @@ -374,7 +375,8 @@ exports.buildRelationalFieldNestedInputTypes = ({ action, modelName, isForRemote } return inputs; }; -exports.buildNestedMutationInputType = ({ action, modelName, modelAST, mutations, isForRemote }) => { +exports.buildRelationalFieldNestedInputTypes = buildRelationalFieldNestedInputTypes +const buildNestedMutationInputType = ({ action, modelName, modelAST, mutations, isForRemote }) => { // Prevent overwriting any existing mutation of the same name if(mutations.fieldMap[`${action}${modelName}`] === undefined) { const inputFields = []; @@ -486,6 +488,7 @@ exports.buildNestedMutationInputType = ({ action, modelName, modelAST, mutations } return undefined; } +exports.buildNestedMutationInputType = buildNestedMutationInputType; const buildTypeMaps = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; @@ -522,7 +525,7 @@ const buildTypeMaps = (parsed) => { }; }; exports.buildTypeMaps = buildTypeMaps; -exports.buildOperationMap = (parsed) => { +const buildOperationMap = (parsed) => { const arr = parsed ? parsed.definitions : []; const len = arr.length; let i = 0; @@ -552,14 +555,17 @@ exports.buildOperationMap = (parsed) => { mutations: mutations }; }; -exports.getNamedType = (definition) => { +exports.buildOperationMap = buildOperationMap; +const getNamedType = (definition) => { let type = definition.type; while(type.kind !== "NamedType") type = type.type; return type; -} -exports.getFieldType = (field) => { +}; +exports.getNamedType = getNamedType; +const getFieldType = (field) => { return field ? getNamedType(field).name.value : undefined; -} +}; +exports.getFieldType = getFieldType; const hasDirective = (field, match) => { const directives = field.directives; From e2a916de58039ebe5cd582ded6e047d635ed7ca3 Mon Sep 17 00:00:00 2001 From: Vishal Dubey Date: Tue, 31 Mar 2020 19:36:49 +0530 Subject: [PATCH 8/8] fixed imports to require --- src/link.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/link.js b/src/link.js index 136ed0e..e7c1622 100644 --- a/src/link.js +++ b/src/link.js @@ -25,7 +25,7 @@ exports.neo4jGraphQLLink = ({ typeDefs, driver, log=false, indexConfig }) => { }); }); }; -exports.getModelFieldMaps = (fields) => { +const getModelFieldMaps = (fields) => { let relationMap = {}; let propertyMap = {}; let listMap = {}; @@ -54,7 +54,8 @@ exports.getModelFieldMaps = (fields) => { uniqueProperties: uniqueProperties, listMap: listMap }; -} +}; +exports.getModelFieldMaps = getModelFieldMaps; const getOperationType = (operation) => { // After the binding delegates, the operation definition