@@ -1419,6 +1419,10 @@ end
1419
1419
1420
1420
--- XXX
1421
1421
local function extra_args (self , collection_name )
1422
+ if not self .settings .enable_mutations then
1423
+ return {}, {}
1424
+ end
1425
+
1422
1426
local collection = self .collections [collection_name ]
1423
1427
local schema_name = collection .schema_name
1424
1428
@@ -1480,29 +1484,23 @@ end
1480
1484
--- Provided `funcs` argument determines certain functions for retrieving
1481
1485
--- tuples.
1482
1486
---
1483
- --- @tparam table opts `schemas`, `collections`, `service_fields`, `indexes` and
1484
- --- `collection_use_tomap` ({[collection_name] = whether objects in collection
1485
- --- collection_name intended to be unflattened using tuple:tomap({names_only = true})
1486
- --- method instead of compiled_avro_schema.unflatten(tuple), ...})
1487
- --- to give the data accessor all needed meta-information re data; the format is
1488
- --- shown below; additional attributes `resulting_object_cnt_max` and
1489
- --- `fetched_object_cnt_max` are optional positive numbers which help to control
1490
- --- query behaviour in case it requires more resources than expected _(default
1491
- --- value is 10,000)_; `timeout_ms` _(default is 1000)_
1492
- ---
1493
- --- @tparam table funcs set of functions:
1494
- ---
1495
- --- * `is_collection_exists`,
1496
- --- * `get_index`,
1497
- --- * `get_primary_index`,
1498
- --- * `unflatten_tuple`,
1499
- --- * `flatten_object`,
1500
- --- * `insert_tuple`.
1501
- ---
1502
- --- They allows this abstract data accessor behaves in the certain way (say,
1503
- --- like space data accessor or shard data accessor); consider the
1504
- --- `accessor_space` and the `accessor_shard` modules documentation for these
1505
- --- functions description.
1487
+ --- @tparam table opts set of options:
1488
+ ---
1489
+ --- * `schemas`,
1490
+ --- * `collections`,
1491
+ --- * `service_fields`,
1492
+ --- * `indexes`,
1493
+ --- * `collection_use_tomap`: ({[collection_name] = whether objects in
1494
+ --- collection `collection_name` intended to be unflattened using
1495
+ --- `tuple:tomap({names_only = true}` method instead of
1496
+ --- `compiled_avro_schema.unflatten(tuple), ...}`),
1497
+ --- * `resulting_object_cnt_max` and `fetched_object_cnt_max` are optional
1498
+ --- positive numbers which help to control query behaviour in case it
1499
+ --- requires more resources than expected _(default value is 10,000 for
1500
+ --- both)_,
1501
+ --- * `timeout_ms` _(default is 1000)_,
1502
+ --- * `enable_mutations`: boolean flag _(default is `false` for avro-schema-2*
1503
+ --- and `true` for avro-schema-3*)_.
1506
1504
---
1507
1505
--- For examples of `opts.schemas` and `opts.collections` consider the
1508
1506
--- @{tarantool_graphql.new} function description.
@@ -1529,6 +1527,20 @@ end
1529
1527
--- ...
1530
1528
--- }
1531
1529
---
1530
+ --- @tparam table funcs set of functions:
1531
+ ---
1532
+ --- * `is_collection_exists`,
1533
+ --- * `get_index`,
1534
+ --- * `get_primary_index`,
1535
+ --- * `unflatten_tuple`,
1536
+ --- * `flatten_object`,
1537
+ --- * `insert_tuple`.
1538
+ ---
1539
+ --- They allows this abstract data accessor behaves in the certain way (say,
1540
+ --- like space data accessor or shard data accessor); consider the
1541
+ --- `accessor_space` and the `accessor_shard` modules documentation for these
1542
+ --- functions description.
1543
+ ---
1532
1544
--- @treturn table data accessor instance, a table with the two methods
1533
1545
--- (`select` and `arguments`) as described in the @{tarantool_graphql.new}
1534
1546
--- function description.
@@ -1548,6 +1560,14 @@ function accessor_general.new(opts, funcs)
1548
1560
DEF_FETCHED_OBJECT_CNT_MAX
1549
1561
-- TODO: move this setting to `tgql.compile` after #59
1550
1562
local timeout_ms = opts .timeout_ms or DEF_TIMEOUT_MS
1563
+ -- Mutations are disabled for avro-schema-2*, because it can work
1564
+ -- incorrectly for schemas with nullable types.
1565
+ local enable_mutations
1566
+ if opts .enable_mutations == nil then
1567
+ enable_mutations = avro_helpers .major_avro_schema_version () == 3
1568
+ else
1569
+ enable_mutations = opts .enable_mutations
1570
+ end
1551
1571
1552
1572
assert (type (schemas ) == ' table' ,
1553
1573
' schemas must be a table, got ' .. type (schemas ))
@@ -1569,6 +1589,7 @@ function accessor_general.new(opts, funcs)
1569
1589
assert (timeout_ms <= TIMEOUT_INFINITY ,
1570
1590
(' timeouts more then graphql.TIMEOUT_INFINITY (%s) ' ..
1571
1591
' do not supported' ):format (tostring (TIMEOUT_INFINITY )))
1592
+ check (enable_mutations , ' enable_mutations' , ' boolean' )
1572
1593
1573
1594
local models , service_fields_defaults = compile_schemas (schemas ,
1574
1595
service_fields )
@@ -1598,7 +1619,8 @@ function accessor_general.new(opts, funcs)
1598
1619
settings = {
1599
1620
resulting_object_cnt_max = resulting_object_cnt_max ,
1600
1621
fetched_object_cnt_max = fetched_object_cnt_max ,
1601
- timeout_ms = timeout_ms
1622
+ timeout_ms = timeout_ms ,
1623
+ enable_mutations = enable_mutations ,
1602
1624
}
1603
1625
}, {
1604
1626
__index = {
0 commit comments