Skip to content

Commit d533deb

Browse files
committed
Enhanced Testing Infrastructure and Query Coverage:
- Added test query files (air-routes-queries.json, custom-air-routes-queries.json) with GraphQL queries covering filters, sorting, pagination, variables, fragments, and custom directives - Added manual integration test files for AppSync and Apollo Server validation which can be executed against an airports API that was deployed using the graphQL utility Additional change to fix the existing Case01 queries which were using the old method of filtering to use the enhanced string comparison filtering. Added changelog.
1 parent 5b4a58f commit d533deb

15 files changed

+985
-5
lines changed

.jest.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ export default {
22
'transform': {},
33
'verbose': true,
44
'testSequencer': './test/jestTestSequencer.js',
5+
'testPathIgnorePatterns': [
6+
'/node_modules/',
7+
// tests below are intended to be executed manually
8+
'appSyncAirRoutesQueries.test.js',
9+
'appSyncCustomAirRoutesQueries.test.js',
10+
'apolloAirRoutesQueries.test.js',
11+
'apolloCustomAirRoutesQueries.test.js'
12+
],
513
'globals': {
614
// neptune db that has pre-loaded air routes sample data host and port
715
// ex. db-neptune-foo-bar.cluster-abc.us-west-2.neptune.amazonaws.com

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ permissions and limitations under the License.
7878
* Allow credentials to be refreshed at Apollo runtime by passing the credential
7979
provider to the
8080
interceptor ([#134](https://github.com/aws/amazon-neptune-for-graphql/pull/134))
81+
* Added manually executed query integration test suites for App Sync and
82+
Apollo ([#138](https://github.com/aws/amazon-neptune-for-graphql/pull/138))
8183

8284
### Bug Fixes
8385

TESTING.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the following command:
1919
npm run test:unit
2020
```
2121

22-
## Integration Tests
22+
## Automated Integration Tests
2323

2424
Integration tests execute against a live neptune db cluster or graph and require
2525
the following prerequisites to run:
@@ -54,6 +54,66 @@ To execute the integration tests use the following command:
5454
npm run test:integration
5555
```
5656

57+
## Manual Integration Tests
58+
59+
In addition to the automated integration tests, there are manual integration
60+
tests that can be run against live AWS AppSync APIs and Apollo Server instances
61+
that were deployed via the Amazon Neptune Utility for GraphQL. These tests are
62+
useful for validating deployed GraphQL APIs that are interfacing Neptune db or
63+
analytics graphs loaded with the airports sample data.
64+
65+
### AppSync Manual Tests
66+
67+
These tests execute queries against a deployed AWS AppSync API:
68+
69+
#### Standard AppSync Queries
70+
71+
```
72+
node --experimental-vm-modules node_modules/jest/bin/jest.js test/appSyncAirRoutesQueries.test.js
73+
```
74+
75+
#### Custom AppSync Queries
76+
77+
```
78+
node --experimental-vm-modules node_modules/jest/bin/jest.js test/appSyncCustomAirRoutesQueries.test.js
79+
```
80+
81+
**Prerequisites for AppSync tests:**
82+
83+
- Set environment variables:
84+
```
85+
export APP_SYNC_API_ID=your-appsync-api-id
86+
export APP_SYNC_API_KEY=your-api-key
87+
export APP_SYNC_REGION=your-aws-region
88+
```
89+
90+
### Apollo Server Manual Tests
91+
92+
These tests execute queries against a local Apollo Server instance:
93+
94+
#### Standard Apollo Queries
95+
96+
```
97+
node --experimental-vm-modules node_modules/jest/bin/jest.js test/apolloAirRoutesQueries.test.js
98+
```
99+
100+
#### Custom Apollo Queries
101+
102+
```
103+
node --experimental-vm-modules node_modules/jest/bin/jest.js test/apolloCustomAirRoutesQueries.test.js
104+
```
105+
106+
### Test Query Suites
107+
108+
Both test suites use JSON files containing GraphQL queries and expected results:
109+
110+
- **`air-routes-queries.json`**: Standard queries including filters, sorting,
111+
pagination, variables, and fragments
112+
- **`custom-air-routes-queries.json`**: Custom queries using `@graphQuery`
113+
directives, Gremlin queries, and custom field resolvers. These queries assume
114+
that the utility was executed with option
115+
`--input-schema-changes-file ./test/air-routes-changes.json`
116+
57117
## Loading Airports Sample Data Into Neptune
58118

59119
The easiest way to load the airports sample data into Neptune is using

test/TestCases/Case01/queries/Query0002.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "getAirport _id",
33
"description": "Get neptune _id",
4-
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n code\n }\n }",
4+
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"SEA\"}}) {\n code\n }\n }",
55
"result":{
66
"code": "SEA"
77
}

test/TestCases/Case01/queries/Query0003.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "3",
33
"name": "getAirport nested type",
44
"description": "Nested types single and array, references in and out",
5-
"graphql": "query MyQuery {\n getAirport(code: \"YKM\") {\n city\n continentContainsIn {\n desc\n }\n countryContainsIn {\n desc\n }\n airportRoutesOut {\n code\n }\n }\n }",
5+
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"YKM\"}}) {\n city\n continentContainsIn {\n desc\n }\n countryContainsIn {\n desc\n }\n airportRoutesOut {\n code\n }\n }\n }",
66
"result":{
77
"airportRoutesOut": [
88
{

test/TestCases/Case01/queries/Query0004.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Edge properties 2",
33
"description": "Get edge properties in nested array",
4-
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n airportRoutesOut {\n code\n route {\n dist\n }\n }\n }\n }\n",
4+
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"SEA\"}}) {\n airportRoutesOut {\n code\n route {\n dist\n }\n }\n }\n }\n",
55
"result": {
66
"airportRoutesOut": [
77
{

test/TestCases/Case01/queries/Query0005.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Type graph query 1",
33
"description": "Type with graph query returning a scalar",
4-
"graphql": "query MyQuery {\n getAirport(code: \"YYZ\") {\n outboundRoutesCount\n }\n }\n",
4+
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"YYZ\"}}) {\n outboundRoutesCount\n }\n }\n",
55
"result": {
66
"outboundRoutesCount": 195
77
}

test/air-routes-changes.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"type": "Airport",
4+
"field": "outboundRoutesCount",
5+
"action": "add",
6+
"value": "outboundRoutesCount: Int @graphQuery(statement: \"MATCH (this)-[r:route]->(a) RETURN count(r)\")"
7+
},
8+
{
9+
"type": "Query",
10+
"field": "getAirportWithGremlin",
11+
"action": "add",
12+
"value": "getAirportWithGremlin(code:String): Airport @graphQuery(statement: \"g.V().has('airport', 'code', '$code').elementMap()\")"
13+
},
14+
{
15+
"type": "Query",
16+
"field": "getContinentsWithGremlin",
17+
"action": "add",
18+
"value": "getContinentsWithGremlin: [Continent] @cypher(statement: \"g.V().hasLabel('continent').order().elementMap().fold()\")"
19+
},
20+
{
21+
"type": "Query",
22+
"field": "getAirportByCode",
23+
"action": "add",
24+
"value": "getAirportByCode(code:String): Airport @graphQuery(statement: \"MATCH (this: airport {code: '$code'})\")"
25+
},
26+
{
27+
"type": "Query",
28+
"field": "getCountriesCountGremlin",
29+
"action": "add",
30+
"value": "getCountriesCountGremlin: Int @graphQuery(statement: \"g.V().hasLabel('country').count()\")"
31+
},
32+
{
33+
"type": "Query",
34+
"field": "getAirportConnection",
35+
"action": "add",
36+
"value": "getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: \"MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})\")"
37+
}
38+
]

0 commit comments

Comments
 (0)