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

Multi-head connections does not support nullability #200

Closed
SudoBobo opened this issue Jul 29, 2018 · 1 comment
Closed

Multi-head connections does not support nullability #200

SudoBobo opened this issue Jul 29, 2018 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@SudoBobo
Copy link
Contributor

SudoBobo commented Jul 29, 2018

Consider the schema:

"hero": {
    "name": "hero",
    "type": "record",
    "fields": [
        { "name": "hero_id", "type": "string" },
        { "name": "hero_subtype_id", "type": "string*" },
        { "name": "hero_type", "type": "string*" },
    ]
},
"human": {
    "name": "human",
    "type": "record",
    "fields": [
        { "name": "human_id", "type": "string" }
    ]
},
"starship": {
    "name": "starship",
    "type": "record",
    "fields": [
        { "name": "starship_id", "type": "string" }
    ]
}

And collections:

"hero_collection": {
    "schema_name": "hero",
    "connections": [
        {
            "name": "hero_connection",
            "type": "1:1",
            "variants": [
                {
                    "determinant": {"hero_type": "human"},
                    "destination_collection": "human_collection",
                    "parts": [
                        {
                            "source_field": "hero_subtype_id",
                            "destination_field": "human_id"
                        }
                    ],
                    "index_name": "human_id_index"
                },
                {
                    "determinant": {"hero_type": "starship"},
                    "destination_collection": "starship_collection",
                    "parts": [
                        {
                            "source_field": "hero_subtype_id",
                            "destination_field": "starship_id"
                        }
                    ],
                    "index_name": "starship_id_index"
                }
            ]
        }
    ]
},
"human_collection": {
    "schema_name": "human",
    "connections": []
},
"starship_collection": {
    "schema_name": "starship",
    "connections": []
}

We can have a hero object like:

hero_collection:
- hero_id: hero_id_3

The above query is expected to work, but it does not:

{ hero_id = "hero_id_3" }
query obtainHeroes($hero_id: String) {
    hero_collection(hero_id: $hero_id) {
        hero_id
        hero_type
        hero_connection {
            ... on box_human_collection {
                human_collection {
                    human_id
                }
            }
            ... on box_starship_collection {
                starship_collection {
                    starship_id
                }
            }
        }
    }
}

Executing produces an error:

errors:
- message: 'Parent object of union object doesn''t have determinant fields which are
    necessary to determine which resolving variant should be used. Union parent object:

    "--- {''hero_type'': null, '''hero_subtype_id'': null,
    ''hero_id'': ''hero_id_3''}

    ...
    Determinant keys:

    "---

    - hero_type

    ...
@SudoBobo SudoBobo added the bug Something isn't working label Jul 29, 2018
@SudoBobo SudoBobo self-assigned this Jul 29, 2018
@Totktonada
Copy link
Member

I want to clarify a bit why I think hero_type should be allowed to have auxiliary value when hero_subtype_id is null. It is possible that we don't want to set any specific type for a hero when it has no connected part.

Now we determine 'orphan connection' inside a resolve function of a certain connection variant. But it is possible to determine it before choosing a variant in case when determinant fields are the same for all connection vairants.

SudoBobo added a commit that referenced this issue Aug 2, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#123
SudoBobo added a commit that referenced this issue Aug 2, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#123
SudoBobo added a commit that referenced this issue Aug 2, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#123
SudoBobo added a commit that referenced this issue Aug 2, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#85
SudoBobo added a commit that referenced this issue Aug 3, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#85, closes #85
SudoBobo added a commit that referenced this issue Aug 3, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#85, closes #84
SudoBobo added a commit that referenced this issue Aug 6, 2018
SudoBobo added a commit that referenced this issue Aug 7, 2018
SudoBobo added a commit that referenced this issue Aug 8, 2018
SudoBobo added a commit that referenced this issue Aug 8, 2018
SudoBobo added a commit that referenced this issue Aug 8, 2018
SudoBobo added a commit that referenced this issue Aug 9, 2018
SudoBobo added a commit that referenced this issue Aug 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants