Closed ujibang closed 12 months ago
Brief overview
aggregation and GraphQL app definition mappings allow using the $var and $arg operators respectively.
$var
$arg
The argument value can be any bson, as a sting or an object.
This feature is about allowing to use the dot notation when the argument value is an object to reference nested values.
aggregation
This would allow to define an aggregation as follows (the same applies to GraphQL mappings):
{ "stages": [ { "$match": { "name": { "$var": "user.name" } } }, { "$match": { "age": { "$var": "user.age" } } }, ], "uri": "foo" }
The user arg is passed as follows:
user
GET /coll/_aggrs/foo?avars={"user": { "name": "Sara", "age": 1 }}
Currently this can only be achieved using with two variables:
{ "stages": [ { "$match": { "name": { "$var": "name" } } }, { "$match": { "age": { "$var": "age" } } }, ], "uri": "foo" }
GET /coll/_aggrs/foo?avars={"name": "Sara", "age": 1 }
graphql mapping
Consider the following GraphQL app definition that uses an input type:
{ "descriptor": { ... }, "schema": "type User { _id: String } input Options {limit: Int, skip: Int } type Query { users(options: Options): [User] }", "mappings": { "Query": { "users": { "db": "restheart", "collection": "the-users", "limit": {"$arg": "options.limit"}, <--- dot notation "skip": {"$arg": "options.skip"} <--- dot notation } } } }
We can request the following query:
{ users(options: { skip: 0, limit:5 }) { _id } }
Rationale
Referencing nested arguments would be useful for implementing querying operations like filtering and sorting on specific fields.
Support the dot notation in GraphQL mappings enables using complex input types.
Detailed documentation
Support of dot notation in:
documented in https://restheart.org/docs/mongodb-rest/aggregations#parametric-aggregations and https://restheart.org/docs/mongodb-graphql/#mappings-operators
Brief overview
aggregation and GraphQL app definition mappings allow using the
$var
and$arg
operators respectively.The argument value can be any bson, as a sting or an object.
This feature is about allowing to use the dot notation when the argument value is an object to reference nested values.
aggregation
This would allow to define an aggregation as follows (the same applies to GraphQL mappings):
The
user
arg is passed as follows:Currently this can only be achieved using with two variables:
graphql mapping
Consider the following GraphQL app definition that uses an input type:
We can request the following query:
Rationale
Referencing nested arguments would be useful for implementing querying operations like filtering and sorting on specific fields.
Support the dot notation in GraphQL mappings enables using complex input types.
Detailed documentation
Support of dot notation in:
$arg
operator: https://restheart.org/docs/mongodb-graphql/#dot-notation-support-for-arg-and-fk