movio / bramble

A federated GraphQL API gateway
https://movio.github.io/bramble/
MIT License
498 stars 55 forks source link

Handle nullable destinations in results merge of query execution #123

Closed pkqk closed 2 years ago

pkqk commented 2 years ago

For fields that are nullable, it is possible that the merge algorithm will encounter some destinations that are null. It makes sense to skip those fields.

For example:

# Service A
type Gizmo {
    id: ID!
    details: GizmoDetails
}

type GizmoDetails {
    creator: Person!
}

type Person @boundary {
    id: ID!
}

type Query {
    gizmos: [Gizmo!]!
}
# Service B
type Person @boundary {
    id: ID!
    name: String!
}
type Query {
    person(id: ID!): Person @boundary
}
query {
    gizmos {
        details {
            creator {
                name
            }
        }
    }
}

with results like:

{
    "data": {
        "gizmos": [
            {
                "id": "GIZMO1",
                "details": {
                    "creator": {
                        "name": "Alice"
                    }
                }
            },
            {
                "id": "GIZMO2",
                "details": null
            }
        ]
    }
}

The merge algorithm would have expected to be able to walk down the details, creator path on GIZMO2.