-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/testdata/common_testdata.lua
Outdated
@@ -15,7 +15,7 @@ function common_testdata.get_test_metadata() | |||
"type": "record", | |||
"name": "user", | |||
"fields": [ | |||
{ "name": "user_id", "type": "string" }, | |||
{ "name": " user_id", "type": "string" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be sure you read entire git diff
before propose changes to review. This is typo, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. Fixed.
graphql/config_complement.lua
Outdated
|
||
local config_complement = {} | ||
|
||
--- The function determines connection type by fully qualified connection.parts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with fully qualified? Usually that means that a name has all its namespaces as parts of the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that connection.parts must have a format of:
"parts": [
{ "source_field": "user_id", "destination_field": "user_id" },
...
],
I am not sure about naming here. The logic of config_complement is about converting from:
{
name='order_connection',
source_collection = 'user_collection',
destination_collection = 'order_collection',
index_name = 'user_id_index'
}
to (in source_collection)
{
"type": "1:N",
"name": "order_connection",
"destination_collection": "order_collection",
"parts": [
{ "source_field": "user_id", "destination_field": "user_id" }
],
"index_name": "user_id_index"
}
How to name this two formats? Simplified and full connections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially / fully defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to partially / fully defined.
graphql/accessor_general.lua
Outdated
@@ -827,7 +827,7 @@ local function process_tuple(state, tuple, opts) | |||
|
|||
-- convert tuple -> object | |||
local obj = opts.unflatten_tuple(collection_name, tuple, | |||
opts.default_unflatten_tuple) | |||
opts.default_unflatten_tuple, opts.is_collection_formatted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it worth to keep profile of the default_unflatten_tuple
function the same as unflatten_tuple
(except the last parameter, default
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discucced verbally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed.
graphql/accessor_general.lua
Outdated
@@ -1285,6 +1288,7 @@ function accessor_general.new(opts, funcs) | |||
indexes = indexes, | |||
models = models, | |||
default_unflatten_tuple = default_unflatten_tuple, | |||
formatted_collections = opts.formatted_collections, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re naming: maybe space_format_layout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it is a map with {collection_name: is_formatted}. We may extend it to be like: {collection_name: related_space_format}, but currently we does not need this information in accessor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed. We both ok with have_space_format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
graphql/accessor_space.lua
Outdated
local function unflatten_tuple(collection_name, tuple, default) | ||
local function unflatten_tuple(collection_name, tuple, default, is_collection_formatted) | ||
if is_collection_formatted then | ||
return tuple:tomap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What with number fields? tarantool/tarantool#3281
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why it works w/o extra hacks. Because of fields selection in executor. So, okay to leave as is, but add the option for future tarantool versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You propose to clarify our intensions with this?
return tuple:tomap{{only_names=true})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
|
||
|
||
local gql_wrapper = graphql.new({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is difference from space_common test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In simple_config we just test new constructor format.
space_common:
local accessor = graphql.accessor_space.new({
schemas = schemas,
collections = collections,
service_fields = service_fields,
indexes = indexes,
})
local gql_wrapper = graphql.new({
schemas = schemas,
collections = collections,
accessor = accessor,
})
simple_config:
local gql_wrapper = graphql.new({
schemas = schemas,
collections = collections,
service_fields = service_fields,
indexes = indexes,
accessor = 'space'
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
test/local/zero_config.test.lua
Outdated
local shard = shard or box.space | ||
|
||
shard.user_collection:replace( | ||
{'user_id_1', 'Ivan', 42}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fxd.
test/local/zero_config.test.lua
Outdated
local gql_query_1 = gql_wrapper:compile(query_1) | ||
local result = gql_query_1:execute(variables_1) | ||
results = results .. print_and_return( | ||
('RESULT\n%s'):format(yaml.encode(result))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fxd.
test/local/zero_config.test.lua
Outdated
box.once('test_space_init_spaces', function() | ||
box.schema.create_space('user_collection') | ||
box.space.user_collection:create_index('user_id_index', | ||
{type = 'tree', unique = true, parts = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fxd.
test/local/zero_config.test.lua
Outdated
box.cfg { background = false } | ||
init_spaces() | ||
fill_test_data() | ||
local gql_wrapper = graphql.new({auto_cfg = true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want graphql:compile() method (and create zero configuration graphql instance under hood) and graphql:execute() method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do. Except for graphql:execute(). Currently we do not use it like graphql:execute(), we use it like compiled_quer.execute(). Do you suggest to support graphql:execute() anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? Consider box.sql.execute for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just call compile + execute at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, Done.
c2cec15
to
82c0bad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of comments are about my feelings and can be ignored. The PR generally LGTM, so you can do what you want on it and merge. Please, squash commits and rebase on current master.
test/testdata/common_testdata.lua
Outdated
{ "source_field": "user_id", "destination_field": "user_id" } | ||
], | ||
"index_name": "user_id_index" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason. Fxd.
graphql/accessor_general.lua
Outdated
@@ -827,7 +827,7 @@ local function process_tuple(state, tuple, opts) | |||
|
|||
-- convert tuple -> object | |||
local obj = opts.unflatten_tuple(collection_name, tuple, | |||
opts.default_unflatten_tuple) | |||
{ has_space_format = opts.has_space_format }, opts.default_unflatten_tuple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fxd.
graphql/accessor_general.lua
Outdated
@@ -1179,6 +1180,7 @@ local function get_pcre_argument_type(self, collection_name) | |||
return pcre_type | |||
end | |||
|
|||
--todo add comments about opts.formatted_collections (also assertions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you going to do it in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
graphql/accessor_general.lua
Outdated
@@ -1285,6 +1287,7 @@ function accessor_general.new(opts, funcs) | |||
indexes = indexes, | |||
models = models, | |||
default_unflatten_tuple = default_unflatten_tuple, | |||
has_space_format = opts.has_space_format or {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a boolean or a table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified names, so now there is no such uncertain names.
graphql/accessor_shard.lua
Outdated
@@ -84,12 +84,19 @@ end | |||
--- | |||
--- @tparam string collection_name | |||
--- @tparam cdata/table tuple | |||
--- @tparam table opts | |||
--- * `has_space_format` (boolean, if collection 'collection_name' generated | |||
--- from space:format() or not). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to rephrase it to avoid misinterpret as 'boolean if ..., but other type otherwise':
boolean, default: false; whether objects in collection
collection_name
intended to be unflattened usingtuple:tomap({names_only = true})
method instead ofcompiled_avro_schema.unflatten(tuple)
.
Here I proposed more concrete wording about how exactly behaviour will be changed by enabling this flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Fxd.
graphql/utils.lua
Outdated
end | ||
|
||
--- Check if given table has only one specific key. | ||
function utils.has_only(t, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No copy (and certainly deepcopy) need, try this:
local fst_key = next(t)
local snd_key = next(t, fst_key)
return fst_key == key and snd_key == nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good, fxd.
graphql/utils.lua
Outdated
return has_key and not_has_another_key | ||
end | ||
|
||
function utils.size(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer less general name like table_size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fxd.
('RESULT\n%s'):format(yaml.encode(result))) | ||
end) | ||
|
||
utils.show_trace(function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don’t need to try-catch such prints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Fxd.
@@ -0,0 +1,56 @@ | |||
#!/usr/bin/env tarantool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding this test as one of configurations of test/local/space_common.test.lua. Use suite.cfg file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be part of test refactoring ticket we discussed verbaly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File it to issues, please.
@@ -0,0 +1,74 @@ | |||
env = require('test_run') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this can be added as one of configuration of the shard_common.test.lua test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
1. Zero config 2. require('graphql').execute()/compile() functionality 3. GraphiQL 4. Config complementation
82c0bad
to
a2e918f
Compare
Related to #59 and #60.