gentics / mesh-incubator

Project which is home for planned enhancements for Gentics Mesh
3 stars 0 forks source link

Allow ElasticSearch queries in subqueries in GraphQL #85

Open philippguertler opened 7 years ago

philippguertler commented 7 years ago

Proposal

At the moment, you can only search with Elastic Search on the top level of a GraphQL query via the nodes field. It should be possible to use queries in any node list field (children, node list field, etc.). When executing the query, mesh has to add a condition to only finds nodes within the current context. Example:

{
    node(path: "/") {
        children(query: "{term: {\"schema.name.raw\": \"region\"}}") {
            uuid
        }
    }
}

This query will find all uuids of nodes that are children of the root node AND have the region schema.

Implementation

When a query in an inner field is encountered, Mesh could simply wrap the query like this:

{
    "query": {
        "bool": {
            "must": [
                { "terms": {"uuid": [...uuids]}},
                {
                    ...userQuery
                }
            ]
        }
    }
}
Jotschi commented 7 years ago

Related to #27