Added
- Adds CLI command to manage native queries with automatic type inference (#131)
Changed
- Updates MongoDB Rust driver from v2.8 to v3.1.0 (#124)
Fixed
- The connector previously used Cloudflare's DNS resolver. Now it uses the locally-configured DNS resolver. (#125)
- Fixed connector not picking up configuration changes when running locally using the ddn CLI workflow. (#133)
Managing native queries with the CLI
New in this release is a CLI plugin command to create, list, inspect, and delete
native queries. A big advantage of using the command versus writing native query
configurations by hand is that the command will type-check your query's
aggregation pipeline, and will write type declarations automatically.
This is a BETA feature - it is a work in progress, and will not work for all
cases. It is safe to experiment with since it is limited to managing native
query configuration files, and does not lock you into anything.
You can run the new command like this:
$ ddn connector plugin --connector app/connector/my_connector/connector.yaml -- native-query
To create a native query create a file with a .json
extension that contains
the aggregation pipeline for you query. For example this pipeline in
title_word_frequency.json
outputs frequency counts for words appearing in
movie titles in a given year:
[
{
"$match": {
"year": "{{ year }}"
}
},
{
"$replaceWith": {
"title_words": { "$split": ["$title", " "] }
}
},
{ "$unwind": { "path": "$title_words" } },
{
"$group": {
"_id": "$title_words",
"count": { "$count": {} }
}
}
]
In your supergraph directory run a command like this using the path to the pipeline file as an argument,
$ ddn connector plugin --connector app/connector/my_connector/connector.yaml -- native-query create title_word_frequency.json --collection movies
You should see output like this:
Wrote native query configuration to your-project/connector/native_queries/title_word_frequency.json
input collection: movies
representation: collection