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

Commit ec86556

Browse files
committed
Minor: prettify code of create_default_accessor()
Fixed ldoc comment.
1 parent 320e98e commit ec86556

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

graphql/tarantool_graphql.lua

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,14 +1706,9 @@ end
17061706
--- The function creates an accessor of desired type with default configuration.
17071707
---
17081708
--- @tparam table cfg general tarantool_graphql config (contains schemas,
1709-
--- collections, service_fields and indexes)
1710-
--- @tparam string accessor type of desired accessor (space or shard)
1711-
--- @tparam table accessor_funcs set of functions to overwrite accessor
1712-
--- inner functions (`is_collection_exists`, `get_index`, `get_primary_index`,
1713-
--- `unflatten_tuple`, For more detailed description see @{accessor_general.new})
1714-
--- These function allow this abstract data accessor behaves in the certain way.
1715-
--- Note that accessor_space and accessor_shard have their own set of these functions
1716-
--- and accessorFuncs argument (if passed) will be used to overwrite them
1709+
--- collections, service_fields, indexes and so on)
1710+
---
1711+
--- @treturn table `accessor` created accessor instance
17171712
local function create_default_accessor(cfg)
17181713
check(cfg.accessor, 'cfg.accessor', 'string')
17191714
assert(cfg.accessor == 'space' or cfg.accessor == 'shard',
@@ -1723,32 +1718,24 @@ local function create_default_accessor(cfg)
17231718
check(cfg.collection_use_tomap, 'cfg.collection_use_tomap', 'table', 'nil')
17241719
check(cfg.accessor_funcs, 'cfg.accessor_funcs', 'table', 'nil')
17251720

1721+
local accessor_cfg = {
1722+
schemas = cfg.schemas,
1723+
collections = cfg.collections,
1724+
service_fields = cfg.service_fields,
1725+
indexes = cfg.indexes,
1726+
collection_use_tomap = cfg.collection_use_tomap,
1727+
resulting_object_cnt_max = cfg.resulting_object_cnt_max,
1728+
fetched_object_cnt_max = cfg.fetched_object_cnt_max,
1729+
timeout_ms = cfg.timeout_ms,
1730+
enable_mutations = cfg.enable_mutations,
1731+
}
1732+
17261733
if cfg.accessor == 'space' then
1727-
return accessor_space.new({
1728-
schemas = cfg.schemas,
1729-
collections = cfg.collections,
1730-
service_fields = cfg.service_fields,
1731-
indexes = cfg.indexes,
1732-
collection_use_tomap = cfg.collection_use_tomap,
1733-
resulting_object_cnt_max = cfg.resulting_object_cnt_max,
1734-
fetched_object_cnt_max = cfg.fetched_object_cnt_max,
1735-
timeout_ms = cfg.timeout_ms,
1736-
enable_mutations = cfg.enable_mutations,
1737-
}, cfg.accessor_funcs)
1734+
return accessor_space.new(accessor_cfg, cfg.accessor_funcs)
17381735
end
17391736

17401737
if cfg.accessor == 'shard' then
1741-
return accessor_shard.new({
1742-
schemas = cfg.schemas,
1743-
collections = cfg.collections,
1744-
service_fields = cfg.service_fields,
1745-
indexes = cfg.indexes,
1746-
collection_use_tomap = cfg.collection_use_tomap,
1747-
resulting_object_cnt_max = cfg.resulting_object_cnt_max,
1748-
fetched_object_cnt_max = cfg.fetched_object_cnt_max,
1749-
timeout_ms = cfg.timeout_ms,
1750-
enable_mutations = cfg.enable_mutations,
1751-
}, cfg.accessor_funcs)
1738+
return accessor_shard.new(accessor_cfg, cfg.accessor_funcs)
17521739
end
17531740
end
17541741

0 commit comments

Comments
 (0)