async-graphql + MongoService for document reads/writes without Prisma in the Rust path.
Canonical walkthrough: Recipe D (D.11 single-file sample).
Cargo.toml
Resolver shape
After
MongoModule::for_root, Arc::new(MongoService) is enough for QueryRoot / MutationRoot—connection state lives in module statics (MongoService is a unit handle).
Curl smoke tests
display_name → displayName).
Production GraphQL + Mongo
Authorization at the resolver boundary
Treat Mongo collections like any other datastore: derivetenant_id (or viewer_id) from GraphQL Context (populated by an HTTP guard), and always merge it into filter documents:
tenant_id without verifying it matches the authenticated principal.
Performance and safety
Writes
Useupdate_one with $set for partial patches; reserve replace_one for true “overwrite document” semantics. Return modified_count / matched_count so mutations can expose success: Boolean! vs NotFound extensions.
Pair with Recipe B for REST + same BSON types; reuse
ProfileDoc everywhere for consistent serialization.