@@ -56,8 +56,23 @@ local function gql_execute(qstate, variables, operation_name)
56
56
assert (operation_type == ' query' or operation_type == ' mutation' ,
57
57
' only "query" and "mutation" operation types are supported' )
58
58
local accessor = state .accessor
59
-
60
- if operation_type == ' query' and accessor .name == ' shard' then
59
+ local cfg_use_bfs_executor = qstate .query_settings .use_bfs_executor or
60
+ state .use_bfs_executor
61
+
62
+ local use_bfs_executor = operation_type == ' query'
63
+ if use_bfs_executor then
64
+ if cfg_use_bfs_executor == ' never' then
65
+ use_bfs_executor = false
66
+ elseif cfg_use_bfs_executor == ' shard' then
67
+ use_bfs_executor = accessor .name == ' shard'
68
+ elseif cfg_use_bfs_executor == ' always' then
69
+ use_bfs_executor = true
70
+ else
71
+ error (' Unknown use_bfs_executor: ' ..
72
+ tostring (state .use_bfs_executor ))
73
+ end
74
+ end
75
+ if use_bfs_executor then
61
76
return bfs_executor .execute (state .schema , qstate .ast , variables ,
62
77
operation_name , {
63
78
qcontext = qcontext ,
117
132
--- * resulting_object_cnt_max
118
133
--- * fetched_object_cnt_max
119
134
--- * timeout_ms
135
+ --- * use_bfs_executor
120
136
---
121
137
--- @treturn table compiled query with `execute` and `avro_schema` functions
122
138
local function gql_compile (state , query , opts )
@@ -138,6 +154,7 @@ local function gql_compile(state, query, opts)
138
154
resulting_object_cnt_max = opts .resulting_object_cnt_max ,
139
155
fetched_object_cnt_max = opts .fetched_object_cnt_max ,
140
156
timeout_ms = opts .timeout_ms ,
157
+ use_bfs_executor = opts .use_bfs_executor ,
141
158
}
142
159
}
143
160
291
308
--- timeout_ms = <number>,
292
309
--- enable_mutations = <boolean>,
293
310
--- disable_dangling_check = <boolean>,
311
+ --- use_bfs_executor = 'never' | 'shard' (default) | 'always'
294
312
--- })
295
313
function impl .new (cfg )
296
314
local cfg = cfg or {}
@@ -320,8 +338,17 @@ function impl.new(cfg)
320
338
cfg .indexes = cfg .accessor .indexes
321
339
end
322
340
341
+ check (cfg .disable_dangling_check , ' disable_dangling_check' , ' boolean' ,
342
+ ' nil' )
343
+ check (cfg .use_bfs_executor , ' use_bfs_executor' , ' string' , ' nil' )
344
+ assert (cfg .use_bfs_executor == ' never' or cfg .use_bfs_executor == ' shard'
345
+ or cfg .use_bfs_executor == ' always' or cfg .use_bfs_executor == nil ,
346
+ " use_bfs_executor must be 'never', 'shard' (default) or 'always', '" ..
347
+ " got " .. tostring (cfg .use_bfs_executor ))
348
+
323
349
local state = {
324
350
disable_dangling_check = cfg .disable_dangling_check ,
351
+ use_bfs_executor = cfg .use_bfs_executor or ' shard' ,
325
352
}
326
353
convert_schema .convert (state , cfg )
327
354
return setmetatable (state , {
0 commit comments