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

Add support for avro-type union #109

Closed
opomuc opened this issue Apr 5, 2018 · 5 comments
Closed

Add support for avro-type union #109

opomuc opened this issue Apr 5, 2018 · 5 comments
Assignees
Labels
customer enhancement New feature or request

Comments

@opomuc
Copy link

opomuc commented Apr 5, 2018

Error catched: unrecognized avro-schema type: ["string",{"type":"map","values":"string"},{"type":"array","items":{"type":"map","values":"string"}}]
Error occured at '/usr/share/tarantool/graphql/tarantool_graphql.lua:784'

[C   ] function 'error' at <[C]:-1>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:784>
[Lua ] function 'convert_record_fields' at </usr/share/tarantool/graphql/tarantool_graphql.lua:295>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:739>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:777>
[Lua ] function 'convert_record_fields' at </usr/share/tarantool/graphql/tarantool_graphql.lua:295>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:739>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:777>
 [Lua ] function 'convert_record_fields' at </usr/share/tarantool/graphql/tarantool_graphql.lua:295>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:739>
[Lua ] function 'convert_record_fields' at </usr/share/tarantool/graphql/tarantool_graphql.lua:295>
[Lua ] function 'gql_type' at </usr/share/tarantool/graphql/tarantool_graphql.lua:739>
[Lua ] function 'parse_cfg' at </usr/share/tarantool/graphql/tarantool_graphql.lua:956>
[Lua ] function 'new' at </usr/share/tarantool/graphql/tarantool_graphql.lua:1131>
***
[C   ] at <[C]:-1>
[C   ] function 'pcall' at <[C]:-1>
[Lua ] function 'cmd_function' at </usr/bin/tarantoolctl:518>
[Lua ] function 'process' at </usr/bin/tarantoolctl:924>
[main] at </usr/bin/tarantoolctl:1271>
@Totktonada Totktonada added enhancement New feature or request customer labels Apr 5, 2018
@Totktonada
Copy link
Member

ETA for merging into master: 2018-04-13 23:59.

@SudoBobo
Copy link
Contributor

SudoBobo commented Apr 9, 2018

GraphQL unions and avro-schema unions (Also see JSON Encoding section below) are different.
Instance of GraphQL union (let's imagine FooObject | BarObject union type):

{ "FooObjectField1": value, "FooObjectField2": anotherValue }
or 
{ "BarObjectField1": value, "BarObjectField2": anotherValue }

with following form of query:

{
    search(...) {
        ... on Foo {
            FooObjectField1
            FooObjectField2
        }
        ... on Bar {
            BarObjectField1
            BarObjectField2
        }
}

Instance of avro-schema union:

{ "FooObject": { "FooObjectField1": value, "FooObjectField2": anotherValue } }
or
{ "BarObject": { "BarObjectField1": value, "BarObjectField2": anotherValue } }

After verbal discussion with @Totktonada we came up with 2 solutions. So we want to convert avro-schema union to GraphQL union. We have the following avro-schema union:
{ "name": "union_field" , "type": ["null", "string", "Foo"] }
The first solution (GraphQL union and queries with types conditional fragments):

{
    ...
    union_field (some_arguments) {
        ... on String (String_value_argument) {
            String
        }
        ... on Foo (some_Foo_arguments) {
            FooObjectField1
            FooObjectField2
        }
}

and union_field also is nullable.
The second one (GraphQL object with nullable fields and no types conditional fragments):

{
    ...
    union_field (some_arguments) {
        string
        Foo (some_Foo_arguments) {
            FooObjectField1
            FooObjectField2
        }
}

So union_field is GraphQL object with all fields nullable.

@SudoBobo
Copy link
Contributor

SudoBobo commented Apr 9, 2018

I think that second solution is better because it is closer to avro-schema conception of unions.

@SudoBobo
Copy link
Contributor

@opomuc
Do you need to filter over union field?

query ($union_type: union_type) {
    user_collection(union_type: $union_type) {
        union_type {
        ...
}

variables {
  "union_type": ...
}

@opomuc
Copy link
Author

opomuc commented Apr 11, 2018

@SudoBobo I think that we discussed it with @Totktonada and @Kasen: decided that we might need it, but it is currently not a priority

SudoBobo added a commit that referenced this issue Apr 13, 2018
(including unions with arrays, maps and
records), closes #109
SudoBobo added a commit that referenced this issue Apr 13, 2018
(including unions with arrays, maps and
records), closes #109
SudoBobo added a commit that referenced this issue Apr 13, 2018
(including unions with arrays, maps and
records), closes #109
SudoBobo added a commit that referenced this issue Apr 13, 2018
(including unions with arrays, maps and
records), closes #109
SudoBobo added a commit that referenced this issue Apr 13, 2018
(including unions with arrays, maps and
records), closes #109
SudoBobo added a commit that referenced this issue Apr 13, 2018
SudoBobo added a commit that referenced this issue Apr 13, 2018
SudoBobo added a commit that referenced this issue Apr 13, 2018
SudoBobo added a commit that referenced this issue Apr 13, 2018
Totktonada added a commit that referenced this issue Sep 4, 2018
* fix format_process function
* print whole reject file when test failed (#102)
* print reproduce file when test failed at -j -1 mode (#104)
* print reproduce file content in parallel mode (#104)
* allow to pass arguments to create_cluster
* allow grep_log to not reset search results after tarantool restart
* support comments in config files
* don't kill default if non-default crash expected (#109)
* don't inherit unneeded file descriptors (#117)
* list task for hung workers (#107)
* add new config param 'show_reproduce_content' (#113)
Totktonada added a commit that referenced this issue Sep 4, 2018
* fix format_process function
* print whole reject file when test failed (#102)
* print reproduce file when test failed at -j -1 mode (#104)
* print reproduce file content in parallel mode (#104)
* allow to pass arguments to create_cluster
* allow grep_log to not reset search results after tarantool restart
* support comments in config files
* don't kill default if non-default crash expected (#109)
* don't inherit unneeded file descriptors (#117)
* list task for hung workers (#107)
* add new config param 'show_reproduce_content' (#113)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants