From a58c840d2108d950f3abf64309139ae871db9db4 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Wed, 20 Nov 2024 12:22:54 -0800 Subject: [PATCH 01/14] fixing Case01.04 --- package.json | 2 +- src/resolverJS.js | 2 +- ...solverOCHTTPSTemplate.js => JSResolverOCHTTPSTemplate.mjs} | 4 ++-- test/TestCases/Case01/Case01.03.test.js | 2 +- test/TestCases/Case01/Case01.04.test.js | 2 +- test/TestCases/Case01/case.json | 2 +- ...utput.resolver.graphql.cjs => output.resolver.graphql.mjs} | 0 test/TestCases/Case01/queries/Query0007.json | 2 +- test/TestCases/Case02/case.json | 2 +- test/TestCases/Case05/case02.json | 2 +- test/{testLib.js => testLib.mjs} | 0 11 files changed, 10 insertions(+), 10 deletions(-) rename templates/{JSResolverOCHTTPSTemplate.js => JSResolverOCHTTPSTemplate.mjs} (99%) rename test/TestCases/Case01/outputReference/{output.resolver.graphql.cjs => output.resolver.graphql.mjs} (100%) rename test/{testLib.js => testLib.mjs} (100%) diff --git a/package.json b/package.json index d7a7a7e..fe08fe4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "files": [ "neptune-for-graphql.mjs", "./templates/CDKTemplate.js", - "./templates/JSResolverOCHTTPSTemplate.js", + "./templates/JSResolverOCHTTPSTemplate.mjs", "./templates/Lambda4AppSyncHTTP/index.mjs", "./templates/Lambda4AppSyncHTTP/package.json", "./templates/Lambda4AppSyncSDK/index.mjs", diff --git a/src/resolverJS.js b/src/resolverJS.js index 0b229ba..6c8d431 100644 --- a/src/resolverJS.js +++ b/src/resolverJS.js @@ -19,7 +19,7 @@ function resolverJS (schemaModel, queryLanguage, queryClient, __dirname) { if (queryLanguage == 'opencypher') { try { - code = readFileSync(__dirname + '/../templates/JSResolverOCHTTPSTemplate.js'); + code = readFileSync(__dirname + '/../templates/JSResolverOCHTTPSTemplate.mjs'); code = code.toString().replace('TIMESTAMP HERE', (new Date()).toISOString()); code = code.toString().replace('INSERT SCHEMA DATA MODEL HERE', queryDataModelJSON); } catch (err) { diff --git a/templates/JSResolverOCHTTPSTemplate.js b/templates/JSResolverOCHTTPSTemplate.mjs similarity index 99% rename from templates/JSResolverOCHTTPSTemplate.js rename to templates/JSResolverOCHTTPSTemplate.mjs index 683893f..73912b4 100644 --- a/templates/JSResolverOCHTTPSTemplate.js +++ b/templates/JSResolverOCHTTPSTemplate.mjs @@ -10,7 +10,7 @@ express or implied. See the License for the specific language governing permissions and limitations under the License. */ -const gql = require('graphql-tag'); // GraphQL library to parse the GraphQL query +import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; @@ -1048,4 +1048,4 @@ function resolveGraphDBQuery(query) { } -module.exports = { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; +export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; diff --git a/test/TestCases/Case01/Case01.03.test.js b/test/TestCases/Case01/Case01.03.test.js index 69b12c7..2527bbc 100644 --- a/test/TestCases/Case01/Case01.03.test.js +++ b/test/TestCases/Case01/Case01.03.test.js @@ -3,4 +3,4 @@ import { jest } from '@jest/globals'; import { testResolverQueries } from '../../testLib'; -await testResolverQueries('./TestCases/Case01/output/output.resolver.graphql.cjs', './test/TestCases/Case01/queries'); \ No newline at end of file +await testResolverQueries('./TestCases/Case01/output/output.resolver.graphql.mjs', './test/TestCases/Case01/queries'); \ No newline at end of file diff --git a/test/TestCases/Case01/Case01.04.test.js b/test/TestCases/Case01/Case01.04.test.js index ae10316..81720bc 100644 --- a/test/TestCases/Case01/Case01.04.test.js +++ b/test/TestCases/Case01/Case01.04.test.js @@ -1,6 +1,6 @@ import { jest } from '@jest/globals'; -import { readJSONFile, testResolverQueriesResults } from '../../testLib'; +import { readJSONFile, testResolverQueriesResults } from '../../testLib.mjs'; const casetest = readJSONFile('./test/TestCases/Case01/case.json'); diff --git a/test/TestCases/Case01/case.json b/test/TestCases/Case01/case.json index a592867..796be49 100644 --- a/test/TestCases/Case01/case.json +++ b/test/TestCases/Case01/case.json @@ -4,7 +4,7 @@ "argv":["--quiet", "--input-schema-file", "./test/TestCases/airports.source.schema.graphql", "--input-schema-changes-file", "./test/TestCases/Case01/input/changesAirport.json", - "--output-js-resolver-file", "./test/TestCases/Case01/output/output.resolver.graphql.cjs", + "--output-js-resolver-file", "./test/TestCases/Case01/output/output.resolver.graphql.mjs", "--output-folder-path", "./test/TestCases/Case01/output", "--output-no-lambda-zip"], "host": "", diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.cjs b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs similarity index 100% rename from test/TestCases/Case01/outputReference/output.resolver.graphql.cjs rename to test/TestCases/Case01/outputReference/output.resolver.graphql.mjs diff --git a/test/TestCases/Case01/queries/Query0007.json b/test/TestCases/Case01/queries/Query0007.json index f41436d..a31e3d9 100644 --- a/test/TestCases/Case01/queries/Query0007.json +++ b/test/TestCases/Case01/queries/Query0007.json @@ -1,6 +1,6 @@ { "name": "graphQuery type", - "description": "Query using a graphQuery returing a type", + "description": "Query using a graphQuery returning a type", "graphql": "query MyQuery {\n getAirportConnection(fromCode: \"SEA\", toCode: \"BLQ\") {\n city\n code\n }\n }\n", "parameters": {}, "resolved": "MATCH (:airport{code: 'SEA'})-[:route]->(getAirportConnection_Airport:airport)-[:route]->(:airport{code:'BLQ'})\nRETURN {city: getAirportConnection_Airport.`city`, code: getAirportConnection_Airport.`code`} LIMIT 1", diff --git a/test/TestCases/Case02/case.json b/test/TestCases/Case02/case.json index 7c06259..114be21 100644 --- a/test/TestCases/Case02/case.json +++ b/test/TestCases/Case02/case.json @@ -3,7 +3,7 @@ "description":"Start from graph db json, from Air Routes db", "argv":[ "--quiet", "--input-graphdb-schema-file", "./test/TestCases/Case02/input/airports.graphdb.json", - "--output-js-resolver-file", "./test/TestCases/Case02/output/output.resolver.graphql.cjs", + "--output-js-resolver-file", "./test/TestCases/Case02/output/output.resolver.graphql.mjs", "--output-folder-path", "./test/TestCases/Case02/output", "--output-no-lambda-zip"], "host": "", diff --git a/test/TestCases/Case05/case02.json b/test/TestCases/Case05/case02.json index 006bc71..87b63fc 100644 --- a/test/TestCases/Case05/case02.json +++ b/test/TestCases/Case05/case02.json @@ -5,7 +5,7 @@ "--remove-aws-pipeline-name", "AirportsJestTest", "--output-folder-path", "./test/TestCases/Case05/output"], "host": "", - "port": "", + "port": "", "testOutputFilesSize": ["output.resolver.graphql.js", "output.schema.graphql", "output.source.schema.graphql"], "testOutputFilesContent": ["output.schema.graphql", "output.source.schema.graphql"] } \ No newline at end of file diff --git a/test/testLib.js b/test/testLib.mjs similarity index 100% rename from test/testLib.js rename to test/testLib.mjs From 51f10d55720da2511d4293852c60186e044d5453 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Wed, 20 Nov 2024 12:24:57 -0800 Subject: [PATCH 02/14] fix file path for testLib --- test/TestCases/Case01/Case01.04.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestCases/Case01/Case01.04.test.js b/test/TestCases/Case01/Case01.04.test.js index 81720bc..ae10316 100644 --- a/test/TestCases/Case01/Case01.04.test.js +++ b/test/TestCases/Case01/Case01.04.test.js @@ -1,6 +1,6 @@ import { jest } from '@jest/globals'; -import { readJSONFile, testResolverQueriesResults } from '../../testLib.mjs'; +import { readJSONFile, testResolverQueriesResults } from '../../testLib'; const casetest = readJSONFile('./test/TestCases/Case01/case.json'); From 586fb358ad98cfe3cfa4bc4520e85476c53807bf Mon Sep 17 00:00:00 2001 From: sophiadt Date: Thu, 21 Nov 2024 12:48:31 -0800 Subject: [PATCH 03/14] fix test output ref and move import all tests pass except 01.04 but at least it runs --- templates/JSResolverOCHTTPSTemplate.mjs | 3 +-- .../Case01/outputReference/output.resolver.graphql.js | 7 +++---- .../Case01/outputReference/output.resolver.graphql.mjs | 7 +++---- .../Case07/outputReference/output.resolver.graphql.js | 7 +++---- test/testLib.mjs | 8 +++++--- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/templates/JSResolverOCHTTPSTemplate.mjs b/templates/JSResolverOCHTTPSTemplate.mjs index 73912b4..8bb7132 100644 --- a/templates/JSResolverOCHTTPSTemplate.mjs +++ b/templates/JSResolverOCHTTPSTemplate.mjs @@ -1017,7 +1017,6 @@ function resolveGremlinQuery(obj, querySchemaInfo) { return gremlinQuery; } - // Function takes the graphql query and output the graphDB query function resolveGraphDBQuery(query) { let executeQuery = { query:'', parameters: {}, language: 'opencypher', refactorOutput: null }; @@ -1048,4 +1047,4 @@ function resolveGraphDBQuery(query) { } -export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.js b/test/TestCases/Case01/outputReference/output.resolver.graphql.js index 21d16ba..bae3228 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.js @@ -10,11 +10,11 @@ express or implied. See the License for the specific language governing permissions and limitations under the License. */ -const gql = require('graphql-tag'); // GraphQL library to parse the GraphQL query +import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-19T00:06:35.400Z +// 2024-11-21T20:36:02.331Z const schemaDataModelJSON = `{ "kind": "Document", @@ -4468,7 +4468,6 @@ function resolveGremlinQuery(obj, querySchemaInfo) { return gremlinQuery; } - // Function takes the graphql query and output the graphDB query function resolveGraphDBQuery(query) { let executeQuery = { query:'', parameters: {}, language: 'opencypher', refactorOutput: null }; @@ -4499,4 +4498,4 @@ function resolveGraphDBQuery(query) { } -module.exports = { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs index 21d16ba..bae3228 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs @@ -10,11 +10,11 @@ express or implied. See the License for the specific language governing permissions and limitations under the License. */ -const gql = require('graphql-tag'); // GraphQL library to parse the GraphQL query +import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-19T00:06:35.400Z +// 2024-11-21T20:36:02.331Z const schemaDataModelJSON = `{ "kind": "Document", @@ -4468,7 +4468,6 @@ function resolveGremlinQuery(obj, querySchemaInfo) { return gremlinQuery; } - // Function takes the graphql query and output the graphDB query function resolveGraphDBQuery(query) { let executeQuery = { query:'', parameters: {}, language: 'opencypher', refactorOutput: null }; @@ -4499,4 +4498,4 @@ function resolveGraphDBQuery(query) { } -module.exports = { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case07/outputReference/output.resolver.graphql.js b/test/TestCases/Case07/outputReference/output.resolver.graphql.js index 0ec193c..0ba42c5 100644 --- a/test/TestCases/Case07/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case07/outputReference/output.resolver.graphql.js @@ -10,11 +10,11 @@ express or implied. See the License for the specific language governing permissions and limitations under the License. */ -const gql = require('graphql-tag'); // GraphQL library to parse the GraphQL query +import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-19T00:07:26.413Z +// 2024-11-21T20:36:37.948Z const schemaDataModelJSON = `{ "kind": "Document", @@ -4500,7 +4500,6 @@ function resolveGremlinQuery(obj, querySchemaInfo) { return gremlinQuery; } - // Function takes the graphql query and output the graphDB query function resolveGraphDBQuery(query) { let executeQuery = { query:'', parameters: {}, language: 'opencypher', refactorOutput: null }; @@ -4531,4 +4530,4 @@ function resolveGraphDBQuery(query) { } -module.exports = { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/testLib.mjs b/test/testLib.mjs index b4b67ed..b302993 100644 --- a/test/testLib.mjs +++ b/test/testLib.mjs @@ -128,11 +128,13 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, const query = JSON.parse(fs.readFileSync(queriesReferenceFolder + "/" +queryFile)); if (query.graphql != "") { const result = resolverModule.resolveGraphDBQuery(query.graphql); + const httpResult = await queryNeptune(query.resolved, result.language, host, port, result.parameters); - + let data = null; - if (result.language == 'opencypher') + if (result.language == 'opencypher') { data = httpResult.results[0][Object.keys(httpResult.results[0])[0]]; + } else { const input = httpResult.result.data; data = JSON.parse(resolverModule.refactorGremlinqueryOutput(input, result.fieldsAlias)); @@ -149,4 +151,4 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, } -export { readJSONFile, checkFileContains, checkOutputFilesSize, checkOutputFilesContent, testResolverQueries, testResolverQueriesResults, checkOutputZipLambdaUsesSdk }; +export { readJSONFile, checkFileContains, checkOutputFilesSize, checkOutputFilesContent, testResolverQueries, testResolverQueriesResults, checkOutputZipLambdaUsesSdk }; \ No newline at end of file From ebe95343b559c2bffce41bda49e793995586ac0d Mon Sep 17 00:00:00 2001 From: sophiadt Date: Fri, 22 Nov 2024 13:32:29 -0800 Subject: [PATCH 04/14] add different matchers for unit test all tests passed except 7 and 12 --- test/testLib.mjs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/testLib.mjs b/test/testLib.mjs index b302993..d37fbfb 100644 --- a/test/testLib.mjs +++ b/test/testLib.mjs @@ -143,8 +143,17 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, if (JSON.stringify(data, null, 2) != JSON.stringify(query.result, null, 2)) console.log(JSON.stringify(data, null, 2)); - test(`Resolver Neptune result, ${queryFile}: ${query.name}`, async () => { - expect(JSON.stringify(data, null, 2)).toBe(JSON.stringify(query.result, null, 2)); + test(`Resolver Neptune result, ${queryFile}: ${query.name}`, async () => { + if(typeof query.result === 'number') { // if number + expect(JSON.stringify(data, null, 2)).toBe(JSON.stringify(query.result, null, 2)); + } + else if (Object.keys(query.result).length === 1 && Array.isArray(Object.values(query.result)[0])) { // if ONLY single array of objects + expect(data.airportRoutesOut).toEqual(expect.arrayContaining(query.result.airportRoutesOut)); + } + else { // if objects + expect(data).toEqual(query.result); + expect(data).toEqual(expect.objectContaining(query.result)); + } }); } } From c4c88bfe43bfeaf0d2623060093b747eb925783a Mon Sep 17 00:00:00 2001 From: sophiadt Date: Fri, 22 Nov 2024 17:19:16 -0800 Subject: [PATCH 05/14] fixed Query0007 --- .../Case01/outputReference/output.resolver.graphql.js | 6 +++--- .../Case01/outputReference/output.resolver.graphql.mjs | 6 +++--- .../Case01/outputReference/output.source.schema.graphql | 2 +- test/TestCases/Case01/queries/Query0007.json | 8 ++++---- test/TestCases/airports.source.schema.graphql | 2 +- test/testLib.mjs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.js b/test/TestCases/Case01/outputReference/output.resolver.graphql.js index bae3228..ea7f0bd 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.js @@ -14,7 +14,7 @@ import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-21T20:36:02.331Z +// 2024-11-23T01:16:20.126Z const schemaDataModelJSON = `{ "kind": "Document", @@ -2000,7 +2000,7 @@ const schemaDataModelJSON = `{ }, "value": { "kind": "StringValue", - "value": "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})", + "value": "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport{country:'$country'})-[:route]->(:airport{code:'$toCode'})", "block": false } } @@ -3465,7 +3465,7 @@ const schemaDataModelJSON = `{ ], "loc": { "start": 0, - "end": 4710 + "end": 4730 } }`; diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs index bae3228..ea7f0bd 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs @@ -14,7 +14,7 @@ import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-21T20:36:02.331Z +// 2024-11-23T01:16:20.126Z const schemaDataModelJSON = `{ "kind": "Document", @@ -2000,7 +2000,7 @@ const schemaDataModelJSON = `{ }, "value": { "kind": "StringValue", - "value": "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})", + "value": "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport{country:'$country'})-[:route]->(:airport{code:'$toCode'})", "block": false } } @@ -3465,7 +3465,7 @@ const schemaDataModelJSON = `{ ], "loc": { "start": 0, - "end": 4710 + "end": 4730 } }`; diff --git a/test/TestCases/Case01/outputReference/output.source.schema.graphql b/test/TestCases/Case01/outputReference/output.source.schema.graphql index 127e262..acdea60 100644 --- a/test/TestCases/Case01/outputReference/output.source.schema.graphql +++ b/test/TestCases/Case01/outputReference/output.source.schema.graphql @@ -107,7 +107,7 @@ input Options { type Query { getAirport(code: String): Airport - getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})") + getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport{country:'$country'})-[:route]->(:airport{code:'$toCode'})") getAirportWithGremlin(code: String): Airport @graphQuery(statement: "g.V().has('airport', 'code', '$code').elementMap()") getContinentsWithGremlin: [Continent] @graphQuery(statement: "g.V().hasLabel('continent').elementMap().fold()") getCountriesCountGremlin: Int @graphQuery(statement: "g.V().hasLabel('country').count()") diff --git a/test/TestCases/Case01/queries/Query0007.json b/test/TestCases/Case01/queries/Query0007.json index a31e3d9..cbd4d24 100644 --- a/test/TestCases/Case01/queries/Query0007.json +++ b/test/TestCases/Case01/queries/Query0007.json @@ -1,11 +1,11 @@ { "name": "graphQuery type", "description": "Query using a graphQuery returning a type", - "graphql": "query MyQuery {\n getAirportConnection(fromCode: \"SEA\", toCode: \"BLQ\") {\n city\n code\n }\n }\n", + "graphql": "query MyQuery {\n getAirportConnection(fromCode: \"SEA\", country: \"US\", toCode: \"BLQ\") {\n city\n code\n }\n }\n", "parameters": {}, - "resolved": "MATCH (:airport{code: 'SEA'})-[:route]->(getAirportConnection_Airport:airport)-[:route]->(:airport{code:'BLQ'})\nRETURN {city: getAirportConnection_Airport.`city`, code: getAirportConnection_Airport.`code`} LIMIT 1", + "resolved": "MATCH (:airport{code: 'SEA'})-[:route]->(getAirportConnection_Airport:airport{country:'US'})-[:route]->(:airport{code:'BLQ'})\nRETURN {city: getAirportConnection_Airport.`city`, code: getAirportConnection_Airport.`code`} LIMIT 1", "result":{ - "code": "LHR", - "city": "London" + "code": "PHL", + "city": "Philadelphia" } } \ No newline at end of file diff --git a/test/TestCases/airports.source.schema.graphql b/test/TestCases/airports.source.schema.graphql index 35e3768..5b90341 100644 --- a/test/TestCases/airports.source.schema.graphql +++ b/test/TestCases/airports.source.schema.graphql @@ -106,7 +106,7 @@ input Options { type Query { getAirport(code: String): Airport - getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})") + getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport{country:'$country'})-[:route]->(:airport{code:'$toCode'})") getAirportWithGremlin(code:String): Airport @graphQuery(statement: "g.V().has('airport', 'code', '$code').elementMap()") getContinentsWithGremlin: [Continent] @graphQuery(statement: "g.V().hasLabel('continent').elementMap().fold()") getCountriesCountGremlin: Int @graphQuery(statement: "g.V().hasLabel('country').count()") diff --git a/test/testLib.mjs b/test/testLib.mjs index d37fbfb..325db5c 100644 --- a/test/testLib.mjs +++ b/test/testLib.mjs @@ -150,7 +150,7 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, else if (Object.keys(query.result).length === 1 && Array.isArray(Object.values(query.result)[0])) { // if ONLY single array of objects expect(data.airportRoutesOut).toEqual(expect.arrayContaining(query.result.airportRoutesOut)); } - else { // if objects + else { // if objects or array + objects expect(data).toEqual(query.result); expect(data).toEqual(expect.objectContaining(query.result)); } From c91863e74e24101dfec536671d2c6fffa68d0c96 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Thu, 28 Nov 2024 17:22:36 -0800 Subject: [PATCH 06/14] remove second check --- test/testLib.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/testLib.mjs b/test/testLib.mjs index 325db5c..e07e311 100644 --- a/test/testLib.mjs +++ b/test/testLib.mjs @@ -152,7 +152,6 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, } else { // if objects or array + objects expect(data).toEqual(query.result); - expect(data).toEqual(expect.objectContaining(query.result)); } }); } From c8f0a17ca32b8d4b138109dd96eaaf746536727c Mon Sep 17 00:00:00 2001 From: sophiadt Date: Thu, 28 Nov 2024 17:29:54 -0800 Subject: [PATCH 07/14] Object.keys(result)[0] instead of hardcoding --- test/testLib.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testLib.mjs b/test/testLib.mjs index e07e311..739f3f7 100644 --- a/test/testLib.mjs +++ b/test/testLib.mjs @@ -148,7 +148,7 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, expect(JSON.stringify(data, null, 2)).toBe(JSON.stringify(query.result, null, 2)); } else if (Object.keys(query.result).length === 1 && Array.isArray(Object.values(query.result)[0])) { // if ONLY single array of objects - expect(data.airportRoutesOut).toEqual(expect.arrayContaining(query.result.airportRoutesOut)); + expect(data[Object.keys(query.result)[0]]).toEqual(expect.arrayContaining(query.result[Object.keys(query.result)[0]])); } else { // if objects or array + objects expect(data).toEqual(query.result); From 7d214077641749ab2915d65382dd485b599264c9 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Thu, 28 Nov 2024 17:33:34 -0800 Subject: [PATCH 08/14] remove JSON.stringify because number --- test/testLib.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testLib.mjs b/test/testLib.mjs index 739f3f7..b95dcc7 100644 --- a/test/testLib.mjs +++ b/test/testLib.mjs @@ -145,7 +145,7 @@ async function testResolverQueriesResults(resolverFile, queriesReferenceFolder, test(`Resolver Neptune result, ${queryFile}: ${query.name}`, async () => { if(typeof query.result === 'number') { // if number - expect(JSON.stringify(data, null, 2)).toBe(JSON.stringify(query.result, null, 2)); + expect(data).toBe(query.result); } else if (Object.keys(query.result).length === 1 && Array.isArray(Object.values(query.result)[0])) { // if ONLY single array of objects expect(data[Object.keys(query.result)[0]]).toEqual(expect.arrayContaining(query.result[Object.keys(query.result)[0]])); From f1c1b29c1e4e11d8a37ec00cfdf492648c7446a1 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Mon, 2 Dec 2024 11:02:22 -0800 Subject: [PATCH 09/14] queries work with appsync now --- templates/JSResolverOCHTTPSTemplate.mjs | 2 +- templates/Lambda4AppSyncHTTP/index.mjs | 3 ++- templates/Lambda4AppSyncHTTP/package.json | 1 + templates/Lambda4AppSyncSDK/index.mjs | 3 ++- templates/Lambda4AppSyncSDK/package.json | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/JSResolverOCHTTPSTemplate.mjs b/templates/JSResolverOCHTTPSTemplate.mjs index 8bb7132..b580a39 100644 --- a/templates/JSResolverOCHTTPSTemplate.mjs +++ b/templates/JSResolverOCHTTPSTemplate.mjs @@ -1047,4 +1047,4 @@ function resolveGraphDBQuery(query) { } -export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/templates/Lambda4AppSyncHTTP/index.mjs b/templates/Lambda4AppSyncHTTP/index.mjs index 8b5ef39..9d2f922 100644 --- a/templates/Lambda4AppSyncHTTP/index.mjs +++ b/templates/Lambda4AppSyncHTTP/index.mjs @@ -1,7 +1,8 @@ import axios from "axios"; import * as rax from 'retry-axios'; import { aws4Interceptor } from "aws4-axios"; -import {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} from './output.resolver.graphql.js'; +import pkg from './output.resolver.graphql.js'; +const {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} = pkg; const LOGGING_ENABLED = process.env.LOGGING_ENABLED; diff --git a/templates/Lambda4AppSyncHTTP/package.json b/templates/Lambda4AppSyncHTTP/package.json index 81e0f77..acd9acc 100644 --- a/templates/Lambda4AppSyncHTTP/package.json +++ b/templates/Lambda4AppSyncHTTP/package.json @@ -8,6 +8,7 @@ }, "author": "", "license": "ISC", + "type": "module", "dependencies": { "aws4-axios": "3.3.0", "axios": "1.7.4", diff --git a/templates/Lambda4AppSyncSDK/index.mjs b/templates/Lambda4AppSyncSDK/index.mjs index e73e55f..0506d7a 100644 --- a/templates/Lambda4AppSyncSDK/index.mjs +++ b/templates/Lambda4AppSyncSDK/index.mjs @@ -1,5 +1,6 @@ import { NeptunedataClient, ExecuteOpenCypherQueryCommand, ExecuteGremlinQueryCommand } from "@aws-sdk/client-neptunedata"; -import {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} from './output.resolver.graphql.js'; +import pkg from './output.resolver.graphql.js'; +const {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} = pkg; const LOGGING_ENABLED = process.env.LOGGING_ENABLED; diff --git a/templates/Lambda4AppSyncSDK/package.json b/templates/Lambda4AppSyncSDK/package.json index d566cc8..48cfac0 100644 --- a/templates/Lambda4AppSyncSDK/package.json +++ b/templates/Lambda4AppSyncSDK/package.json @@ -8,6 +8,7 @@ }, "author": "AWS", "license": "Apache-2.0", + "type": "module", "dependencies": { "@aws-sdk/client-neptunedata": "3.403.0", "graphql-tag": "2.12.6" From a78ca20c80d8554570edf09767452ba18ff62ab5 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Tue, 3 Dec 2024 16:53:47 -0800 Subject: [PATCH 10/14] fix exports to work with unit tests --- templates/JSResolverOCHTTPSTemplate.mjs | 3 ++- .../Case01/outputReference/output.resolver.graphql.js | 5 +++-- .../Case01/outputReference/output.resolver.graphql.mjs | 5 +++-- .../Case07/outputReference/output.resolver.graphql.js | 9 +++++---- .../Case07/outputReference/output.source.schema.graphql | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/templates/JSResolverOCHTTPSTemplate.mjs b/templates/JSResolverOCHTTPSTemplate.mjs index b580a39..acff45a 100644 --- a/templates/JSResolverOCHTTPSTemplate.mjs +++ b/templates/JSResolverOCHTTPSTemplate.mjs @@ -1047,4 +1047,5 @@ function resolveGraphDBQuery(query) { } -export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; +export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.js b/test/TestCases/Case01/outputReference/output.resolver.graphql.js index ea7f0bd..f293e07 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.js @@ -14,7 +14,7 @@ import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-23T01:16:20.126Z +// 2024-12-04T00:38:40.575Z const schemaDataModelJSON = `{ "kind": "Document", @@ -4498,4 +4498,5 @@ function resolveGraphDBQuery(query) { } -export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; +export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs index ea7f0bd..f293e07 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs @@ -14,7 +14,7 @@ import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-23T01:16:20.126Z +// 2024-12-04T00:38:40.575Z const schemaDataModelJSON = `{ "kind": "Document", @@ -4498,4 +4498,5 @@ function resolveGraphDBQuery(query) { } -export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; +export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case07/outputReference/output.resolver.graphql.js b/test/TestCases/Case07/outputReference/output.resolver.graphql.js index 0ba42c5..36ddb39 100644 --- a/test/TestCases/Case07/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case07/outputReference/output.resolver.graphql.js @@ -14,7 +14,7 @@ import gql from 'graphql-tag'; // GraphQL library to parse the GraphQL query const useCallSubquery = false; -// 2024-11-21T20:36:37.948Z +// 2024-12-04T00:39:19.017Z const schemaDataModelJSON = `{ "kind": "Document", @@ -1962,7 +1962,7 @@ const schemaDataModelJSON = `{ }, "value": { "kind": "StringValue", - "value": "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})", + "value": "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport{country:'$country'})-[:route]->(:airport{code:'$toCode'})", "block": false } } @@ -3497,7 +3497,7 @@ const schemaDataModelJSON = `{ ], "loc": { "start": 0, - "end": 4915 + "end": 4935 } }`; @@ -4530,4 +4530,5 @@ function resolveGraphDBQuery(query) { } -export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; +export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case07/outputReference/output.source.schema.graphql b/test/TestCases/Case07/outputReference/output.source.schema.graphql index 21ebf4b..878103b 100644 --- a/test/TestCases/Case07/outputReference/output.source.schema.graphql +++ b/test/TestCases/Case07/outputReference/output.source.schema.graphql @@ -106,7 +106,7 @@ input Options { type Query { getAirport(code: String): Airport - getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})") + getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: "MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport{country:'$country'})-[:route]->(:airport{code:'$toCode'})") getAirportWithGremlin(code: String): Airport @graphQuery(statement: "g.V().has('airport', 'code', '$code').elementMap()") getContinentsWithGremlin: [Continent] @graphQuery(statement: "g.V().hasLabel('continent').elementMap().fold()") getCountriesCountGremlin: Int @graphQuery(statement: "g.V().hasLabel('country').count()") From dcb417a42d365173a21ac2a15263319e5dca3d54 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Tue, 10 Dec 2024 15:55:44 -0800 Subject: [PATCH 11/14] remove default and pkg --- templates/JSResolverOCHTTPSTemplate.mjs | 3 +-- templates/Lambda4AppSyncHTTP/index.mjs | 3 +-- templates/Lambda4AppSyncSDK/index.mjs | 3 +-- .../Case01/outputReference/output.resolver.graphql.js | 3 +-- .../Case01/outputReference/output.resolver.graphql.mjs | 3 +-- .../Case07/outputReference/output.resolver.graphql.js | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/templates/JSResolverOCHTTPSTemplate.mjs b/templates/JSResolverOCHTTPSTemplate.mjs index acff45a..8bb7132 100644 --- a/templates/JSResolverOCHTTPSTemplate.mjs +++ b/templates/JSResolverOCHTTPSTemplate.mjs @@ -1047,5 +1047,4 @@ function resolveGraphDBQuery(query) { } -export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; -export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/templates/Lambda4AppSyncHTTP/index.mjs b/templates/Lambda4AppSyncHTTP/index.mjs index 9d2f922..8b5ef39 100644 --- a/templates/Lambda4AppSyncHTTP/index.mjs +++ b/templates/Lambda4AppSyncHTTP/index.mjs @@ -1,8 +1,7 @@ import axios from "axios"; import * as rax from 'retry-axios'; import { aws4Interceptor } from "aws4-axios"; -import pkg from './output.resolver.graphql.js'; -const {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} = pkg; +import {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} from './output.resolver.graphql.js'; const LOGGING_ENABLED = process.env.LOGGING_ENABLED; diff --git a/templates/Lambda4AppSyncSDK/index.mjs b/templates/Lambda4AppSyncSDK/index.mjs index 0506d7a..e73e55f 100644 --- a/templates/Lambda4AppSyncSDK/index.mjs +++ b/templates/Lambda4AppSyncSDK/index.mjs @@ -1,6 +1,5 @@ import { NeptunedataClient, ExecuteOpenCypherQueryCommand, ExecuteGremlinQueryCommand } from "@aws-sdk/client-neptunedata"; -import pkg from './output.resolver.graphql.js'; -const {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} = pkg; +import {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} from './output.resolver.graphql.js'; const LOGGING_ENABLED = process.env.LOGGING_ENABLED; diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.js b/test/TestCases/Case01/outputReference/output.resolver.graphql.js index f293e07..165d228 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.js @@ -4498,5 +4498,4 @@ function resolveGraphDBQuery(query) { } -export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; -export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs index f293e07..165d228 100644 --- a/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs +++ b/test/TestCases/Case01/outputReference/output.resolver.graphql.mjs @@ -4498,5 +4498,4 @@ function resolveGraphDBQuery(query) { } -export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; -export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file diff --git a/test/TestCases/Case07/outputReference/output.resolver.graphql.js b/test/TestCases/Case07/outputReference/output.resolver.graphql.js index 36ddb39..339aa5e 100644 --- a/test/TestCases/Case07/outputReference/output.resolver.graphql.js +++ b/test/TestCases/Case07/outputReference/output.resolver.graphql.js @@ -4530,5 +4530,4 @@ function resolveGraphDBQuery(query) { } -export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent }; -export { resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file +export { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent, resolveGraphDBQuery, refactorGremlinqueryOutput }; \ No newline at end of file From 86f6a1294a06ca6fcdaec28e7cd651c8753d6af1 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Wed, 11 Dec 2024 16:36:06 -0800 Subject: [PATCH 12/14] change require and export.module works with appsync and tests --- templates/CDKTemplate.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/CDKTemplate.js b/templates/CDKTemplate.js index 2647274..22639e4 100644 --- a/templates/CDKTemplate.js +++ b/templates/CDKTemplate.js @@ -10,11 +10,11 @@ express or implied. See the License for the specific language governing permissions and limitations under the License. */ -const { Stack, Duration, App } = require('aws-cdk-lib'); -const lambda = require( 'aws-cdk-lib/aws-lambda'); -const iam = require( 'aws-cdk-lib/aws-iam'); -const ec2 = require( 'aws-cdk-lib/aws-ec2'); -const { CfnGraphQLApi, CfnApiKey, CfnGraphQLSchema, CfnDataSource, CfnResolver, CfnFunctionConfiguration } = require( 'aws-cdk-lib/aws-appsync'); +import { Stack, Duration, App } from 'aws-cdk-lib'; +import lambda from 'aws-cdk-lib/aws-lambda'; +import iam from 'aws-cdk-lib/aws-iam'; +import ec2 from 'aws-cdk-lib/aws-ec2'; +import { CfnGraphQLApi, CfnApiKey, CfnGraphQLSchema, CfnDataSource, CfnResolver, CfnFunctionConfiguration } from 'aws-cdk-lib/aws-appsync'; const NAME = ''; const REGION = ''; @@ -290,4 +290,4 @@ export function response(ctx) { } -module.exports = { AppSyncNeptuneStack } \ No newline at end of file +export { AppSyncNeptuneStack }; \ No newline at end of file From 90f1aea4ce917c8fbd9ee6c33d395516fd71a583 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Fri, 13 Dec 2024 10:40:08 -0800 Subject: [PATCH 13/14] trying to jest file and revert to old file types doesn't work so far --- .jest.js | 6 ++++-- package.json | 2 +- src/resolverJS.js | 2 +- ...lverOCHTTPSTemplate.mjs => JSResolverOCHTTPSTemplate.js} | 0 test/TestCases/Case01/Case01.03.test.js | 2 +- test/TestCases/Case01/case.json | 2 +- test/TestCases/Case02/case.json | 2 +- test/{testLib.mjs => testLib.js} | 0 8 files changed, 9 insertions(+), 7 deletions(-) rename templates/{JSResolverOCHTTPSTemplate.mjs => JSResolverOCHTTPSTemplate.js} (100%) rename test/{testLib.mjs => testLib.js} (100%) diff --git a/.jest.js b/.jest.js index 283dceb..18f3a6a 100644 --- a/.jest.js +++ b/.jest.js @@ -1,5 +1,7 @@ export default { - 'transform': {}, + transform: { + '\\.[jt]sx?$': 'babel-jest', + }, 'verbose': true, 'testSequencer': './test/jestTestSequencer.js', 'globals': { @@ -8,5 +10,5 @@ export default { 'AIR_ROUTES_DB_HOST': process.env.AIR_ROUTES_DB_HOST, // ex. 8182 'AIR_ROUTES_DB_PORT': process.env.AIR_ROUTES_DB_PORT - } + }, }; diff --git a/package.json b/package.json index fe08fe4..d7a7a7e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "files": [ "neptune-for-graphql.mjs", "./templates/CDKTemplate.js", - "./templates/JSResolverOCHTTPSTemplate.mjs", + "./templates/JSResolverOCHTTPSTemplate.js", "./templates/Lambda4AppSyncHTTP/index.mjs", "./templates/Lambda4AppSyncHTTP/package.json", "./templates/Lambda4AppSyncSDK/index.mjs", diff --git a/src/resolverJS.js b/src/resolverJS.js index 6c8d431..0b229ba 100644 --- a/src/resolverJS.js +++ b/src/resolverJS.js @@ -19,7 +19,7 @@ function resolverJS (schemaModel, queryLanguage, queryClient, __dirname) { if (queryLanguage == 'opencypher') { try { - code = readFileSync(__dirname + '/../templates/JSResolverOCHTTPSTemplate.mjs'); + code = readFileSync(__dirname + '/../templates/JSResolverOCHTTPSTemplate.js'); code = code.toString().replace('TIMESTAMP HERE', (new Date()).toISOString()); code = code.toString().replace('INSERT SCHEMA DATA MODEL HERE', queryDataModelJSON); } catch (err) { diff --git a/templates/JSResolverOCHTTPSTemplate.mjs b/templates/JSResolverOCHTTPSTemplate.js similarity index 100% rename from templates/JSResolverOCHTTPSTemplate.mjs rename to templates/JSResolverOCHTTPSTemplate.js diff --git a/test/TestCases/Case01/Case01.03.test.js b/test/TestCases/Case01/Case01.03.test.js index 2527bbc..69b12c7 100644 --- a/test/TestCases/Case01/Case01.03.test.js +++ b/test/TestCases/Case01/Case01.03.test.js @@ -3,4 +3,4 @@ import { jest } from '@jest/globals'; import { testResolverQueries } from '../../testLib'; -await testResolverQueries('./TestCases/Case01/output/output.resolver.graphql.mjs', './test/TestCases/Case01/queries'); \ No newline at end of file +await testResolverQueries('./TestCases/Case01/output/output.resolver.graphql.cjs', './test/TestCases/Case01/queries'); \ No newline at end of file diff --git a/test/TestCases/Case01/case.json b/test/TestCases/Case01/case.json index 796be49..a592867 100644 --- a/test/TestCases/Case01/case.json +++ b/test/TestCases/Case01/case.json @@ -4,7 +4,7 @@ "argv":["--quiet", "--input-schema-file", "./test/TestCases/airports.source.schema.graphql", "--input-schema-changes-file", "./test/TestCases/Case01/input/changesAirport.json", - "--output-js-resolver-file", "./test/TestCases/Case01/output/output.resolver.graphql.mjs", + "--output-js-resolver-file", "./test/TestCases/Case01/output/output.resolver.graphql.cjs", "--output-folder-path", "./test/TestCases/Case01/output", "--output-no-lambda-zip"], "host": "", diff --git a/test/TestCases/Case02/case.json b/test/TestCases/Case02/case.json index 114be21..7c06259 100644 --- a/test/TestCases/Case02/case.json +++ b/test/TestCases/Case02/case.json @@ -3,7 +3,7 @@ "description":"Start from graph db json, from Air Routes db", "argv":[ "--quiet", "--input-graphdb-schema-file", "./test/TestCases/Case02/input/airports.graphdb.json", - "--output-js-resolver-file", "./test/TestCases/Case02/output/output.resolver.graphql.mjs", + "--output-js-resolver-file", "./test/TestCases/Case02/output/output.resolver.graphql.cjs", "--output-folder-path", "./test/TestCases/Case02/output", "--output-no-lambda-zip"], "host": "", diff --git a/test/testLib.mjs b/test/testLib.js similarity index 100% rename from test/testLib.mjs rename to test/testLib.js From 80602c5b3d23081e37d68d0091adacfa1146cc31 Mon Sep 17 00:00:00 2001 From: sophiadt Date: Mon, 16 Dec 2024 10:27:33 -0800 Subject: [PATCH 14/14] revert back to .mjs --- .jest.js | 2 +- package.json | 2 +- src/resolverJS.js | 2 +- ...ResolverOCHTTPSTemplate.js => JSResolverOCHTTPSTemplate.mjs} | 0 test/TestCases/Case01/Case01.03.test.js | 2 +- test/TestCases/Case01/case.json | 2 +- test/{testLib.js => testLib.mjs} | 0 7 files changed, 5 insertions(+), 5 deletions(-) rename templates/{JSResolverOCHTTPSTemplate.js => JSResolverOCHTTPSTemplate.mjs} (100%) rename test/{testLib.js => testLib.mjs} (100%) diff --git a/.jest.js b/.jest.js index 18f3a6a..6c15308 100644 --- a/.jest.js +++ b/.jest.js @@ -10,5 +10,5 @@ export default { 'AIR_ROUTES_DB_HOST': process.env.AIR_ROUTES_DB_HOST, // ex. 8182 'AIR_ROUTES_DB_PORT': process.env.AIR_ROUTES_DB_PORT - }, + } }; diff --git a/package.json b/package.json index d7a7a7e..fe08fe4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "files": [ "neptune-for-graphql.mjs", "./templates/CDKTemplate.js", - "./templates/JSResolverOCHTTPSTemplate.js", + "./templates/JSResolverOCHTTPSTemplate.mjs", "./templates/Lambda4AppSyncHTTP/index.mjs", "./templates/Lambda4AppSyncHTTP/package.json", "./templates/Lambda4AppSyncSDK/index.mjs", diff --git a/src/resolverJS.js b/src/resolverJS.js index 0b229ba..6c8d431 100644 --- a/src/resolverJS.js +++ b/src/resolverJS.js @@ -19,7 +19,7 @@ function resolverJS (schemaModel, queryLanguage, queryClient, __dirname) { if (queryLanguage == 'opencypher') { try { - code = readFileSync(__dirname + '/../templates/JSResolverOCHTTPSTemplate.js'); + code = readFileSync(__dirname + '/../templates/JSResolverOCHTTPSTemplate.mjs'); code = code.toString().replace('TIMESTAMP HERE', (new Date()).toISOString()); code = code.toString().replace('INSERT SCHEMA DATA MODEL HERE', queryDataModelJSON); } catch (err) { diff --git a/templates/JSResolverOCHTTPSTemplate.js b/templates/JSResolverOCHTTPSTemplate.mjs similarity index 100% rename from templates/JSResolverOCHTTPSTemplate.js rename to templates/JSResolverOCHTTPSTemplate.mjs diff --git a/test/TestCases/Case01/Case01.03.test.js b/test/TestCases/Case01/Case01.03.test.js index 69b12c7..2527bbc 100644 --- a/test/TestCases/Case01/Case01.03.test.js +++ b/test/TestCases/Case01/Case01.03.test.js @@ -3,4 +3,4 @@ import { jest } from '@jest/globals'; import { testResolverQueries } from '../../testLib'; -await testResolverQueries('./TestCases/Case01/output/output.resolver.graphql.cjs', './test/TestCases/Case01/queries'); \ No newline at end of file +await testResolverQueries('./TestCases/Case01/output/output.resolver.graphql.mjs', './test/TestCases/Case01/queries'); \ No newline at end of file diff --git a/test/TestCases/Case01/case.json b/test/TestCases/Case01/case.json index a592867..796be49 100644 --- a/test/TestCases/Case01/case.json +++ b/test/TestCases/Case01/case.json @@ -4,7 +4,7 @@ "argv":["--quiet", "--input-schema-file", "./test/TestCases/airports.source.schema.graphql", "--input-schema-changes-file", "./test/TestCases/Case01/input/changesAirport.json", - "--output-js-resolver-file", "./test/TestCases/Case01/output/output.resolver.graphql.cjs", + "--output-js-resolver-file", "./test/TestCases/Case01/output/output.resolver.graphql.mjs", "--output-folder-path", "./test/TestCases/Case01/output", "--output-no-lambda-zip"], "host": "", diff --git a/test/testLib.js b/test/testLib.mjs similarity index 100% rename from test/testLib.js rename to test/testLib.mjs