File tree 4 files changed +39
-3
lines changed 4 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1
1
local json = require (' json' )
2
- local shard = require (' shard' )
3
2
local utils = require (' graphql.utils' )
3
+ local shard = utils .optional_require (' shard' )
4
4
local request_batch = require (' graphql.request_batch' )
5
5
local accessor_shard_index_info = require (' graphql.accessor_shard_index_info' )
6
6
Original file line number Diff line number Diff line change
1
+ error (' shard should not be mandatory dependency' )
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env tarantool
2
+
3
+ -- https://github.com/tarantool/graphql/issues/218
4
+
5
+ local fio = require (' fio' )
6
+ local tap = require (' tap' )
7
+
8
+ -- require in-repo version of graphql/ sources despite current working directory
9
+ local cur_dir = fio .abspath (debug.getinfo (1 ).source :match (" @?(.*/)" )
10
+ :gsub (' /./' , ' /' ):gsub (' /+$' , ' ' ))
11
+ package.path =
12
+ cur_dir .. ' /../../?/init.lua' .. ' ;' ..
13
+ cur_dir .. ' /../../?.lua' .. ' ;' ..
14
+ package.path
15
+
16
+ -- require no_shard/shard.lua instead of the real shard module
17
+ package.path =
18
+ cur_dir .. ' /no_shard/?/init.lua' .. ' ;' ..
19
+ cur_dir .. ' /no_shard/?.lua' .. ' ;' ..
20
+ package.path
21
+
22
+ local graphql = require (' graphql' )
23
+ local testdata = require (' test.testdata.common_testdata' )
24
+
25
+ local test = tap .test (' optional shard' )
26
+ test :plan (1 )
27
+
28
+ box .cfg {wal_mode = ' none' }
29
+
30
+ local cfg = testdata .get_test_metadata ()
31
+ cfg .accessor = ' space'
32
+ local ok = pcall (graphql .new , cfg )
33
+ test :ok (ok , ' shard is optional' )
34
+
35
+ os.exit (test :check () == true and 0 or 1 )
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ local log = require('log')
10
10
local yaml = require (' yaml' )
11
11
local avro_schema = require (' avro_schema' )
12
12
local digest = require (' digest' )
13
- local shard = require (' shard' )
13
+ local utils = require (' graphql.utils' )
14
+ local shard = utils .optional_require (' shard' )
14
15
local graphql = require (' graphql' )
15
16
local multirunner = require (' test.common.multirunner' )
16
- local utils = require (' graphql.utils' )
17
17
local test_run = utils .optional_require (' test_run' )
18
18
test_run = test_run and test_run .new ()
19
19
You can’t perform that action at this time.
0 commit comments