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

Commit d54f583

Browse files
committed
Allow to use options with auto configuration
1 parent d1ec5bc commit d54f583

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

graphql/impl.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ end
267267
--- service_fields = <table>,
268268
--- accessor = <table> or <string>,
269269
--- accessor_funcs = <table>,
270+
--- connections = <table>, -- for auto configuration from space formats
270271
--- collection_use_tomap = <boolean>,
271272
--- resulting_object_cnt_max = <number>,
272273
--- fetched_object_cnt_max = <number>,
@@ -279,11 +280,17 @@ function impl.new(cfg)
279280
cfg = table.deepcopy(cfg) -- prevent change of user's data
280281

281282
-- auto config case
282-
if not next(cfg) or utils.has_only(cfg, 'connections') then
283+
local perform_auto_configuration =
284+
cfg['schemas'] == nil and
285+
cfg['indexes'] == nil and
286+
cfg['service_fields'] == nil and
287+
cfg['accessor'] == nil and
288+
cfg['accessor_funcs'] == nil
289+
if perform_auto_configuration then
283290
local generated_cfg = simple_config.graphql_cfg_from_tarantool()
284291
generated_cfg.accessor = 'space'
285292
generated_cfg.connections = cfg.connections or {}
286-
cfg = generated_cfg
293+
cfg = utils.merge_tables(cfg, generated_cfg)
287294
cfg = config_complement.complement_cfg(cfg)
288295
end
289296

graphql/utils.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,6 @@ function utils.check(obj, obj_name, type_1, type_2, type_3)
191191
end
192192
end
193193

194-
--- Check if given table has only one specific key.
195-
function utils.has_only(t, key)
196-
local fst_key = next(t)
197-
local snd_key = next(t, fst_key)
198-
return fst_key == key and snd_key == nil
199-
end
200-
201194
function utils.table_size(t)
202195
local count = 0
203196
for _, _ in pairs(t) do

0 commit comments

Comments
 (0)