Skip to content

Commit 64a6af9

Browse files
Increase graphdb.js test coverage using sample data (#53)
Increased test coverage of logic in graphdb.js which converts a given neptune schema into a graphql schema using various sample data. Test files were added for input neptune schemas (.json) and also for expected graphql schema output (.graphql). --------- Co-authored-by: Sophia Don Tranho <66497192+sophiadt@users.noreply.github.com>
1 parent 4dda1c7 commit 64a6af9

16 files changed

+3051
-259
lines changed

src/test/airports-neptune-schema.json

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{
2+
"nodeStructures": [
3+
{
4+
"label": "continent",
5+
"properties": [
6+
{
7+
"name": "type",
8+
"type": "String"
9+
},
10+
{
11+
"name": "code",
12+
"type": "String"
13+
},
14+
{
15+
"name": "desc",
16+
"type": "String"
17+
}
18+
]
19+
},
20+
{
21+
"label": "country",
22+
"properties": [
23+
{
24+
"name": "type",
25+
"type": "String"
26+
},
27+
{
28+
"name": "code",
29+
"type": "String"
30+
},
31+
{
32+
"name": "desc",
33+
"type": "String"
34+
}
35+
]
36+
},
37+
{
38+
"label": "version",
39+
"properties": [
40+
{
41+
"name": "date",
42+
"type": "String"
43+
},
44+
{
45+
"name": "desc",
46+
"type": "String"
47+
},
48+
{
49+
"name": "author",
50+
"type": "String"
51+
},
52+
{
53+
"name": "type",
54+
"type": "String"
55+
},
56+
{
57+
"name": "code",
58+
"type": "String"
59+
}
60+
]
61+
},
62+
{
63+
"label": "airport",
64+
"properties": [
65+
{
66+
"name": "type",
67+
"type": "String"
68+
},
69+
{
70+
"name": "city",
71+
"type": "String"
72+
},
73+
{
74+
"name": "icao",
75+
"type": "String"
76+
},
77+
{
78+
"name": "code",
79+
"type": "String"
80+
},
81+
{
82+
"name": "country",
83+
"type": "String"
84+
},
85+
{
86+
"name": "lat",
87+
"type": "Float"
88+
},
89+
{
90+
"name": "longest",
91+
"type": "Float"
92+
},
93+
{
94+
"name": "runways",
95+
"type": "Float"
96+
},
97+
{
98+
"name": "desc",
99+
"type": "String"
100+
},
101+
{
102+
"name": "lon",
103+
"type": "Float"
104+
},
105+
{
106+
"name": "region",
107+
"type": "String"
108+
},
109+
{
110+
"name": "elev",
111+
"type": "Float"
112+
}
113+
]
114+
}
115+
],
116+
"edgeStructures": [
117+
{
118+
"label": "contains",
119+
"properties": [],
120+
"directions": [
121+
{
122+
"from": "continent",
123+
"to": "airport",
124+
"relationship": "ONE-MANY"
125+
},
126+
{
127+
"from": "country",
128+
"to": "airport",
129+
"relationship": "ONE-MANY"
130+
}
131+
]
132+
},
133+
{
134+
"label": "route",
135+
"properties": [
136+
{
137+
"name": "dist",
138+
"type": "Float"
139+
}
140+
],
141+
"directions": [
142+
{
143+
"from": "airport",
144+
"to": "airport",
145+
"relationship": "MANY-MANY"
146+
}
147+
]
148+
}
149+
]
150+
}

src/test/airports.graphql

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
type Continent @alias(property:"continent") {
2+
_id: ID! @id
3+
type: String
4+
code: String
5+
desc: String
6+
airportContainssOut(filter: AirportInput, options: Options): [Airport] @relationship(edgeType:"contains", direction:OUT)
7+
contains:Contains
8+
}
9+
10+
input ContinentInput {
11+
_id: ID @id
12+
type: String
13+
code: String
14+
desc: String
15+
}
16+
17+
type Country @alias(property:"country") {
18+
_id: ID! @id
19+
type: String
20+
code: String
21+
desc: String
22+
airportContainssOut(filter: AirportInput, options: Options): [Airport] @relationship(edgeType:"contains", direction:OUT)
23+
contains:Contains
24+
}
25+
26+
input CountryInput {
27+
_id: ID @id
28+
type: String
29+
code: String
30+
desc: String
31+
}
32+
33+
type Version @alias(property:"version") {
34+
_id: ID! @id
35+
date: String
36+
desc: String
37+
author: String
38+
type: String
39+
code: String
40+
}
41+
42+
input VersionInput {
43+
_id: ID @id
44+
date: String
45+
desc: String
46+
author: String
47+
type: String
48+
code: String
49+
}
50+
51+
type Airport @alias(property:"airport") {
52+
_id: ID! @id
53+
type: String
54+
city: String
55+
icao: String
56+
code: String
57+
country: String
58+
lat: Float
59+
longest: Float
60+
runways: Float
61+
desc: String
62+
lon: Float
63+
region: String
64+
elev: Float
65+
continentContainsIn: Continent @relationship(edgeType:"contains", direction:IN)
66+
countryContainsIn: Country @relationship(edgeType:"contains", direction:IN)
67+
airportRoutesOut(filter: AirportInput, options: Options): [Airport] @relationship(edgeType:"route", direction:OUT)
68+
airportRoutesIn(filter: AirportInput, options: Options): [Airport] @relationship(edgeType:"route", direction:IN)
69+
contains:Contains
70+
route:Route
71+
}
72+
73+
input AirportInput {
74+
_id: ID @id
75+
type: String
76+
city: String
77+
icao: String
78+
code: String
79+
country: String
80+
lat: Float
81+
longest: Float
82+
runways: Float
83+
desc: String
84+
lon: Float
85+
region: String
86+
elev: Float
87+
}
88+
89+
type Contains @alias(property:"contains") {
90+
_id: ID! @id
91+
}
92+
93+
type Route @alias(property:"route") {
94+
_id: ID! @id
95+
dist: Float
96+
}
97+
98+
input RouteInput {
99+
dist: Float
100+
}
101+
102+
input Options {
103+
limit:Int
104+
}
105+
106+
type Query {
107+
getNodeContinent(filter: ContinentInput): Continent
108+
getNodeContinents(filter: ContinentInput, options: Options): [Continent]
109+
getNodeCountry(filter: CountryInput): Country
110+
getNodeCountrys(filter: CountryInput, options: Options): [Country]
111+
getNodeVersion(filter: VersionInput): Version
112+
getNodeVersions(filter: VersionInput, options: Options): [Version]
113+
getNodeAirport(filter: AirportInput): Airport
114+
getNodeAirports(filter: AirportInput, options: Options): [Airport]
115+
}
116+
117+
schema {
118+
query: Query
119+
}

0 commit comments

Comments
 (0)