Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 46f02b1

Browse files
committed
style fixes during review
1 parent 7c9d229 commit 46f02b1

File tree

9 files changed

+231
-182
lines changed

9 files changed

+231
-182
lines changed

graphql/accessor_general.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ local function build_connection_indexes(indexes, collections)
646646

647647
connection_indexes[c.destination_collection][c.name] =
648648
set_connection_index(c, c.name, c.type, collection_name,
649-
indexes, connection_indexes)
649+
indexes, connection_indexes)
650650
end
651651

652652
if c.variants ~= nil then
@@ -655,8 +655,8 @@ local function build_connection_indexes(indexes, collections)
655655
connection_indexes[v.destination_collection] = {}
656656
end
657657
connection_indexes[v.destination_collection][c.name] =
658-
set_connection_index(v, c.name, c.type, collection_name,
659-
indexes, connection_indexes)
658+
set_connection_index(v, c.name, c.type, collection_name,
659+
indexes, connection_indexes)
660660
end
661661
end
662662
end

graphql/core/rules.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ function rules.fragmentSpreadIsPossible(node, context)
323323
local fragmentTypes = getTypes(fragmentType)
324324

325325
local valid = util.find(parentTypes, function(kind)
326+
local kind = kind
327+
if kind.__type == 'NonNull' then kind = kind.ofType end
326328
return fragmentTypes[kind]
327329
end)
328330

graphql/tarantool_graphql.lua

Lines changed: 151 additions & 162 deletions
Large diffs are not rendered by default.

graphql/utils.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function utils.show_trace(func, ...)
1313
function(err)
1414
log.info('ERROR: ' .. tostring(err))
1515
log.info(debug.traceback())
16+
print('ERROR: ' .. tostring(err))
17+
print(debug.traceback())
1618
end
1719
))
1820
end

test/local/union.result

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
RUN 1 {{{
2+
QUERY
3+
query obtainHeroes($hero_id: String) {
4+
hero_collection(hero_id: $hero_id) {
5+
hero_id
6+
hero_type
7+
hero_connection {
8+
... on human_collection {
9+
name
10+
}
11+
... on starship_collection {
12+
model
13+
}
14+
}
15+
}
16+
}
17+
VARIABLES
18+
---
19+
hero_id: hero_id_1
20+
...
21+
122
RESULT
223
---
324
hero_collection:
@@ -7,6 +28,29 @@ hero_collection:
728
hero_id: hero_id_1
829
...
930

31+
}}}
32+
33+
RUN 2 {{{
34+
QUERY
35+
query obtainHeroes($hero_id: String) {
36+
hero_collection(hero_id: $hero_id) {
37+
hero_id
38+
hero_type
39+
hero_connection {
40+
... on human_collection {
41+
name
42+
}
43+
... on starship_collection {
44+
model
45+
}
46+
}
47+
}
48+
}
49+
VARIABLES
50+
---
51+
hero_id: hero_id_2
52+
...
53+
1054
RESULT
1155
---
1256
hero_collection:
@@ -16,3 +60,5 @@ hero_collection:
1660
hero_id: hero_id_2
1761
...
1862

63+
}}}
64+

test/testdata/compound_index_testdata.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
local json = require('json')
2-
local yaml = require('yaml')
32
local utils = require('graphql.utils')
3+
local test_utils = require('test.utils')
44

55
local compound_index_testdata = {}
66

7+
local format_result = test_utils.format_result
8+
79
-- return an error w/o file name and line number
810
local function strip_error(err)
911
return tostring(err):gsub('^.-:.-: (.*)$', '%1')
@@ -14,11 +16,6 @@ local function print_and_return(...)
1416
return table.concat({...}, ' ') .. '\n'
1517
end
1618

17-
local function format_result(name, query, variables, result)
18-
return ('RUN %s {{{\nQUERY\n%s\nVARIABLES\n%s\nRESULT\n%s\n}}}\n'):format(
19-
name, query:rstrip(), yaml.encode(variables), yaml.encode(result))
20-
end
21-
2219
-- schemas and meta-information
2320
-- ----------------------------
2421

test/testdata/union_testdata.lua

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
local json = require('json')
2-
local yaml = require('yaml')
32
local utils = require('graphql.utils')
3+
local test_utils = require('test.utils')
44

55
local union_testdata = {}
66

7-
local function print_and_return(...)
8-
print(...)
9-
return table.concat({ ... }, ' ') .. '\n'
10-
end
11-
127
function union_testdata.get_test_metadata()
138
local schemas = json.decode([[{
149
"hero": {
@@ -203,15 +198,16 @@ function union_testdata.run_queries(gql_wrapper)
203198
utils.show_trace(function()
204199
local variables_1 = {hero_id = 'hero_id_1'}
205200
local result = gql_query:execute(variables_1)
206-
results = results .. print_and_return(
207-
('RESULT\n%s'):format(yaml.encode(result)))
201+
results = results .. test_utils.print_and_return(test_utils.format_result(
202+
'1', query, variables_1, result))
203+
208204
end)
209205

210206
utils.show_trace(function()
211207
local variables_2 = {hero_id = 'hero_id_2'}
212208
local result = gql_query:execute(variables_2)
213-
results = results .. print_and_return(
214-
('RESULT\n%s'):format(yaml.encode(result)))
209+
results = results .. test_utils.print_and_return(test_utils.format_result(
210+
'2', query, variables_2, result))
215211
end)
216212

217213
return results

test/utils.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--- Various utility function used across the graphql module tests.
2+
3+
local yaml = require('yaml')
4+
5+
local utils = {}
6+
7+
function utils.format_result(name, query, variables, result)
8+
return ('RUN %s {{{\nQUERY\n%s\nVARIABLES\n%s\nRESULT\n%s\n}}}\n'):format(
9+
name, query:rstrip(), yaml.encode(variables), yaml.encode(result))
10+
end
11+
12+
function utils.print_and_return(...)
13+
print(...)
14+
return table.concat({ ... }, ' ') .. '\n'
15+
end
16+
17+
return utils

0 commit comments

Comments
 (0)