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

Support of nesting a record into a record #56

Merged
merged 1 commit into from
Feb 28, 2018

Conversation

Totktonada
Copy link
Member

@Totktonada Totktonada commented Feb 26, 2018

@Totktonada Totktonada added bug Something isn't working prio1 labels Feb 26, 2018
@Totktonada Totktonada self-assigned this Feb 26, 2018
---
--- @tparam table state for read state.accessor and previously filled
--- state.types
--- @tparam table fields fields part from an avro-schema
---
--- @treturn table res XXX
Copy link
Contributor

@Khatskevich Khatskevich Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 'XXX' mean obvious? Or it is TODO?
In case it is TODO, I would like to see there 'todo' instead of 'xxx', because first option do not require any explanations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XXX is like TODO, but is not commitment. It means 'smth is not good here'. When I add that to the ldoc comment it means 'I’ll fix it before considering the PR as ready'. XXX is standard mark for such things.

$ echo $((`ag -c '\bXXX\b' /usr/src/linux | cut -d: -f2 | tr '\n' '+'; echo 0`))
3182
$ echo $((`ag -c '\bTODO\b' /usr/src/linux | cut -d: -f2 | tr '\n' '+'; echo 0`))
4703

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

shard.init(config)
end)
initialized = true
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain, please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I added the 2nd test. When the default (master) instance stops (the suite has core = app) and starts from a snap/xlog from the previous test, the box.once will not invoke their function, so shard become uninitialized.
  2. Not it works, but is not correct. We avoid the another problem: the shard module cannot be initialized twice, so we omit the 2nd initialization and proceed twice with the same (the first one) configuration.

Copy link
Member Author

@Totktonada Totktonada Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code with the comment.

Copy link
Member Author

@Totktonada Totktonada Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed the following issue for this problem: tarantool/graphql#57

}
}]]),
service_fields = {
user = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does user = {}, mean? Is it neccessary?

Copy link
Member Author

@Totktonada Totktonada Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty list of service fields. Don’t sure we allow to skip it, but that has sense, yep.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipped for now.

@@ -149,27 +149,30 @@ local function gql_argument_type(state, avro_schema)
end
end

local function convert_record_fields_to_args(state, fields)
local function convert_record_fields_to_args(state, fields, skip_compound)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer skip_compound -> skip_nested

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scalar fields are nested too.

@Totktonada Totktonada force-pushed the tkn/gh-46-nested-record branch from 310d378 to 62f9673 Compare February 27, 2018 21:59
@Totktonada Totktonada changed the title WIP: support of nesting a record into a record Support of nesting a record into a record Feb 27, 2018
@Totktonada Totktonada mentioned this pull request Feb 27, 2018
3 tasks
@Totktonada Totktonada force-pushed the tkn/gh-46-nested-record branch from 62f9673 to 050ee8e Compare February 27, 2018 22:56
--- Convert each field of an avro-schema to a scalar graphql type or an input
--- object.
---
--- @tparam table fields list of fields the avro-schema record fields format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you forgot "in"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add 'of'.

---
--- @tparam[opt] table opts optional options:
---
--- * skip_compound -- do not add fields of record type to the arguments;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to wrap things like skip_compound into back quotes. However I im not sure is it is a good practice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like such visual accents too.

--- * skip_compound -- do not add fields of record type to the arguments;
--- default: false.
---
--- @treturn table `args` -- map with type names as keys and graphql types as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you wrap args in ` while in other similar cases you do not to this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tparam marks the parameter name monotyped automatically, but @treturn is not.

args[field.name] = nullable(gql_class)
if not skip_compound or avro_type(field.type) ~= 'record' then
local gql_class = gql_argument_type(field.type)
args[field.name] = nullable(gql_class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you call nullable without any conditions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was that you can omit any argument. But AFAIR it is so even if you don’t use 'nullable'.

@Totktonada Totktonada force-pushed the tkn/gh-46-nested-record branch from 050ee8e to efc542f Compare February 28, 2018 06:57
@Totktonada Totktonada force-pushed the tkn/gh-46-nested-record branch from efc542f to 2eecc27 Compare February 28, 2018 16:24
@Totktonada Totktonada merged commit 3bb0528 into master Feb 28, 2018
@Totktonada Totktonada deleted the tkn/gh-46-nested-record branch February 28, 2018 18:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working prio1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants