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

Sb/union clean #81

Closed
wants to merge 13 commits into from
Closed

Sb/union clean #81

wants to merge 13 commits into from

Conversation

SudoBobo
Copy link
Contributor

@SudoBobo SudoBobo commented Mar 14, 2018

Add new type of connections - union connections, as they described in #8. With this connection type it is possible to represent a situation when entities in child table reference different parent tables. For example, let us have child table User and parent tables Basic and Premium. One user in User table may reference to a basic user info in Basic table, while another may reference to a premium info in Premium table. In GraphQL it is represented as Union type like this:

User {
   user_id: ID
   connection_field_name: Basic | Premium
}

@SudoBobo SudoBobo self-assigned this Mar 14, 2018
@SudoBobo SudoBobo requested a review from Totktonada March 14, 2018 10:46
Totktonada and others added 11 commits March 14, 2018 19:54
Add goods (item) and order_item relation.
This patch is important for graphql query -> avro schema convertor
implementation, because both executor and convertor walks over query
AST.

Part of #7
Extend query object: add `avro_schema` method, which produces Avro
schema which can be used to verify or flatten any `query_exequte`
result.

Closes #7
The changes are debatable, but I'm trying to improve code readability as
stated in the comments to [1].

[1]: tarantool/graphql#58
The criteria of correctness is that the following queries should produce
the same results.

```
local gql = ...
local query = [[
    query foo_list($offset: foo_offset) {
        foo(offset: $offset) {
            ...
        }
    }
]]
local variables = {
    offset = {
        bar = ...,
        baz = ...,
    }
}
print(yaml.encode(gql:compile(query):execute(variables)))
```

```
local gql = ...
local query = [[
    query foo_list($bar: String, $baz: Long) {
        foo(offset: {bar: $bar, baz: $baz}) {
            ...
        }
    }
]]
local variables = {
    bar = ...,
    baz = ...,
}
print(yaml.encode(gql:compile(query):execute(variables)))
```
It is for make the function general and don't have fears of corner
cases. It will loop in case of x = { ofType = x }, but it is anyway
incorrect input.
This follows up the PR #58 (the work in the scope of the issue #7).
@SudoBobo SudoBobo closed this Mar 14, 2018
@SudoBobo SudoBobo deleted the sb/union_clean branch March 15, 2018 12:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants